Solaris Common Desktop Environment: Advanced User's and System Administrator's Guide

Defining the Data Criteria for a Data Type

The DATA_CRITERIA definition defines the criteria used to assign an object type to a file or directory.

You can use the criteria show in Table 13–3 for object typing.

Table 13–3 DATA_CRITERIA Criteria and Descriptions

Criteria 

Description 

File name 

The file name must match a specified pattern. Use the NAME_PATTERN field.

File location 

The path must match a specified pattern. Use the PATH_PATTERN field.

File contents 

A specified portion of the file's contents must match specified data. Use the CONTENT field.

File mode 

The file must possess the specified permissions (read, write, execute, directory). Use the MODE field.

Symbolic links

The typing is based on the file to which the object is linked.  

You can use more than one criteria for a data type. However, you should not use the NAME_PATTERN and PATH_PATTERN criteria in the same data type.

Name-Based Data Types

Use the NAME_PATTERN field to specify the naming requirement. The field value can include the following wildcards:

?—matches any single character

*—matches any sequence of characters (including a null string)

[cc]—matches any of the characters (c) enclosed in brackets

[cc]—matches any of the characters in the range c through c

Examples

Location-Based Data Types

Use the PATH_PATTERN field to specify the path. You can use the same wildcard characters as with NAME_PATTERN.

For example, the following data type uses a criteria based on path.

DATA_ATTRIBUTES Project_Graphics
 {
     DESCRIPTION       Graphics file for the QS project. Double-click the \
                       icon to see the graphic.
 ICON                  QSgraphics
 }
 DATA_CRITERIA Project_Graphics_Criteria
 {
 DATA_ATTRIBUTES_NAME  Project_Graphics
 PATH_PATTERN          */projects/QS/graphics/*
 }

Data Types Based on Name and Location

To create a data type based on both file name and location, include the name in the PATH_PATTERN value. You cannot use both NAME_PATTERN and PATH_PATTERN in the same criteria definition.

Examples

Using File Modes as a Typing Criteria

Use the MODE field to specify the required permissions.

Mode criteria are usually used in combination with name-based, location-based, or content-based data typing. They allow you to limit a data type to a file or directory, or to specify the required read, write, and execute permissions.

The MODE field can include logical operators (Table 13–4) and characters (Table 13–5).

Table 13–4 MODE Field Logical Operators and Descriptions

Operator 

Description 

!

Logical operator NOT

&

Logical operator AND

|

Logical OR

Table 13–5 MODE Field Characters and Descriptions

Character 

Description 

f

The data type applies only to files 

d

The data type applies only to directories 

r

The file is readable by any user 

w

The file is writable by any user 

x

The file is executable by any user 

l

The file is a link 

The default for a particular mode is that the mode does not matter.

Examples

Content-Based Data Typing

Use the CONTENT field to specify data typing based on the content of the file. Content-based data typing can be used in combination with name- or location-based data typing.

The typing can be based on either string or numeric content for files. The first byte in the file is numbered 0.

To Create a Data Type with Several Independent Criteria

You can create a data type with several independent criteria—that is, the file is assigned to the data type if it meets either (or both) of the criteria.

  1. Create the DATA_ATTRIBUTES definition for the data type.

  2. Create a DATA_CRITERIA definition for each criteria.

    Use the DATA_ATTRIBUTES_NAME field to connect each criteria to the same DATA_ATTRIBUTES definition.

    For example, the following definitions create the Mif data type. Typing is based on name or content.

    DATA_ATTRIBUTES Mif
    {
     	ICON								Frame
     	ACTION_LIST						Open,Print
     }
    
     DATA_CRITERIA Mif_Name_Criteria
     {
     	DATA_ATTRIBUTES_NAME				Mif
     	NAME_PATTERN							*.mif
     }
    
     DATA_CRITERIA Mif_Content_Criteria
     {
     	DATA_ATTRIBUTES_NAME		Mif
     	CONTENT							1 string MIFFile
     }