CPGuide - Extended Attributes
Reprint Courtesy of International Business Machines Corporation, © International Business Machines Corporation
OS/2 file systems maintain a standard set of information on file objects. This standard set of information is referred to as Level 1 file information. Level 1 file information includes the name and size of the file object, and the date and time the file object was created, last accessed, and last written to.
Applications can attach additional information to a file object in the form of an extended attribute (EA). There can be many EAs associated with a file object and, because of their flexibility, almost any information about the file can be stored in one.
The following topics are related to the information in this chapter:
- File Systems
- File Names
- File Management
About Extended Attributes
Level 1 file information is the basic information describing files that is stored by the file system. Level 1 file information includes the size of the file, and the date and time it was created, last written, and last accessed. A subset of this information is typically displayed by entering the DIR command on the OS/2 command line. Applications can obtain Level 1 file information by calling DosQueryPathInfo and DosQueryFileInfo. Applications can set Level 1 File Information by calling DosSetPathInfo and DosSetFileInfo.
Applications can attach additional information to a file object in the form of an extended attribute (EA). Extended attributes can be used to describe the file object to another application, to OS/2, and to the file system that is managing that object.
This information can be used to:
- Store notes on file objects (for example, the name of the file creator)
- Categorize file objects (for example, source, samples, icons, bit maps)
- Describe the format of data contained in the file object (for example, a data record)
- Append additional data to the file object.
An application uses extended attributes to provide a description of a file or directory but the application does not place the description in the file or directory itself. Extended attributes associated with a file object are not part of the file object or its data. They are stored separately from the file they are linked to and the file system manages the storage and maintenance of the EA.
Each extended attribute has two parts, a name and a value. The name is a NULL-terminated string; any convenient name can be chosen. EA names are restricted to the same character set as file names.
The value of the EA can be text, a bit map, binary data, anything at all. OS/2 does not check data that is associated with an EA. The application that creates the extended attributes and the applications that read them must recognize the format and meaning of the data associated with a given EA name.
Applications can examine, add, and replace extended attributes at any time. Any application can read the extended attributes by using the DosQueryFileInfo or DosQueryPathInfo function. Applications can use DosFindFirst and DosFindNext to search for files that have specific extended attributes.
A file can have any number of extended attributes. Each extended attribute can be up to 64KB in size. The sum of all extended attributes for a file must not exceed 64KB.
So that extended attribute data can be understood by other applications, conventions have been established for naming EAs and indicating the type of data they contain.
In addition, a set of Standard Extended Attributes (SEAs) have been defined. SEAs define a common set of information that can be associated with most files (for example, file type and file purpose). Through SEAs, many applications can access the same, useful information associated with files.
Applications are not limited to using SEAs to associate information with files. They can define their own application-specific extended attributes.
Extended attributes associated with a file object are not part of the file object or its data.
Extended attributes are supported by the OS/2 High Performance File System (HPFS) and by the OS/2 FAT file system.
Applications define and associate extended attributes with a file object through file system functions. The file system functions that use and manipulate EAs are: