Examples
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 }
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
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 }
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 |
---|---|
! | |
& | |
| |
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.
Examples
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 }