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
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.
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
[c-c]--matches any of the characters in the range c through c
The following data type definition creates a data type based on the file name. The file name must begin with QS and end with .doc.
DATA_ATTRIBUTES QS_Doc { DESCRIPTION This file contains a document for the QS \ project. ICON Word_Doc ACTIONS Open } DATA_CRITERIA QS_Doc_Criteria { NAME_PATTERN QS*.doc DATA_ATTRIBUTES_NAME QS_Doc }
The following definition creates a data type for directories named Demo_n where n is 0 through 9.
DATA_ATTRIBUTES Demo_directory { DESCRIPTION This is a directory. Double-click to open it. ICON Demo ACTIONS OpenInPlace,OpenNewView } DATA_CRITERIA Demo_directory_criteria { NAME_PATTERN Demo_[0-9] MODE d DATA_ATTRIBUTES_NAME Demo_directory }
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/* }
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.
The QS_Source_Files data type defined below applies to all files named appn.c, where n= 1 through 9, located in subdirectories of */projects/QS.
DATA_ATTRIBUTES QS_Source_Files { ... } DATA_CRITERIA QS_Source_Files_Criteria { PATH_PATTERN */projects/QS/*/app[1-9].c DATA_ATTRIBUTES_NAME QS_Source_Files }
The following data type applies to all files in the directory /doc/project1 named chnn.xxx where n is 0 through 9, and xxx is any three-character file- name suffix.
DATA_ATTRIBUTES ChapterFiles { DESCRIPTION Chapter file for the project document. ICON chapter ACTIONS Edit,Print } DATA_CRITERIA Chapter_Criteria { PATH_PATTERN /doc/project1/ch[0-9][0-9].??? DATA_ATTRIBUTES_NAME ChapterFiles }
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 |
---|---|
! | |
& | |
| |
Table 13-5 MODE Field Characters and Descriptions
Character |
Description |
---|---|
The data type applies only to files |
|
The data type applies only to directories |
|
r |
The file is readable by any user |
The file is writable by any user |
|
The file is executable by any user |
|
The file is a link |
The default for a particular mode is that the mode does not matter.
The following mode fields restrict the data type as described:
f&!w--read-only files
!w--read-only files and directories
f&x--executable files
f&r&x--files that are both writable and executable
x|!w--files that are executable or read-only
The following data type definition creates an data type for read-only, non-executable files whose file names follow the naming convention *.doc. It assumes that a View action has been defined for the data type.
DATA_ATTRIBUTES ReadOnlyDocument { ICON read_only DESCRIPTION This document is not writable. Double- \ clicking runs your editor with a \ read-only copy of the file. ACTIONS View } DATA_CRITERIA ReadOnlyDocument_Criteria { NAME_PATTERN *.doc MODE !d&!x&!w DATA_ATTRIBUTES_NAME ReadOnlyDocument }
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.
For number content of a file, use the syntax:
CONTENT starting_byte byte number CONTENT starting_byte short number CONTENT starting_byte long number
For the contents of a directory, use the syntax:
CONTENT 0 filename "file_name"
Use standard C notation for octal (leading o) and hexidecimal (leading oX) numbers.
Use of content-based data typing will result in slower system performance. Wherever possible, use name- and location-based typing instead.
For example, the following data type, Writable_Wingz, applies to all files with write permission containing the string WNGZ at the beginning of the file.
DATA_ATTRIBUTES Writable_Wingz { ... } DATA_CRITERIA Writable_Wingz_Criteria { CONTENT 0 string WNGZ MODE w&!d DATA_ATTRIBUTES_NAME Writable_Wingz }
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.
Create the DATA_ATTRIBUTES
definition for the data type.
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 }