GEOS SDK TechDocs
|
|
5.2 Files and File Handles
|
5.4 File Utilities
FileGetHandleExtAttributes(), FileGetPathExtAttributes(), FileSetHandleExtAttributes(), FileSetPathExtAttributes(), FileExtAttrDesc, FileDateAndTime, FileAttrs
All GEOS files, whether they contain code or data, have special extended attributes . Geodes cannot look at these directly; instead, they make calls to the file system when they want to examine or change the attributes. There are many different extended attributes; however, they are all accessed and changed in a uniform way. Some of the extended attributes are also supported for non-GEOS files. The following extended attributes are currently available:
FEA_MODIFICATION FEA_FILE_ATTR FEA_SIZE FEA_FILE_TYPE FEA_FLAGS FEA_RELEASE FEA_PROTOCOL FEA_TOKEN FEA_CREATOR FEA_USER_NOTES FEA_NOTICE FEA_CREATION FEA_PASSWORD FEA_CUSTOM FEA_NAME FEA_GEODE_ATTR FEA_PATH_INFO FEA_FILE_ID FEA_DESKTOP_INFO FEA_DRIVE_STATUS FEA_DISK FEA_DOS_NAME FEA_OWNER FEA_RIGHTS
There are also two special constants, FEA_MULTIPLE and FEA_END_OF_LIST. These are also described below.
There are two different routines to read a file's extended attributes:
FileGetHandleExtAttributes()
and
FileGetPathExtAttributes()
. These routines are the same except in the way the file is specified: in one, the handle of an open file is passed, whereas in the other, the address of a path string is passed.
FileGetHandleExtAttributes()
takes four arguments. The first is the handle of the file whose attributes are desired; this may be a VM file handle or a byte-file handle. The second is a constant specifying the attribute desired. All extended attributes which are currently supported are listed above; more may be added later. The third is a pointer to a buffer; the attribute's value will be written into that buffer. The fourth argument is the size of the buffer (in bytes). Before it returns,
FileGetHandleExtAttributes()
will write the value of the attribute into the buffer. If successful, it will return zero; otherwise, it will return one of the following error codes:
FileGetHandleExtAttrs()
can also fetch several attributes at once. For details on this, see the section on FEA_MULTIPLE ( FEA_MULTIPLE
).
You can get a file's extended attributes without having it open by calling
FileGetPathExtAttributes()
. This routine takes a pointer to a null-terminated path string instead of a file handle. This makes it suitable for examining the attributes of an executable file or directory. Note that the file system will still have to open the file in order to get the attributes. If any geode (including the caller) has the file open with "deny-read" exclusive, the call will fail with error condition ERROR_ACCESS_DENIED. If it could not find the file specified, it will return ERROR_FILE_NOT_FOUND.
To change one of a file's extended attributes, make a call either to
FileSetHandleExtAttributes()
or
to
FileSetPathExtAttributes
(). These routines take the same arguments as the
FileGet...()
routines above; however, they copy the data from the buffer into the attribute, instead of vice versa. These routines return zero if the operation was successful. Otherwise, they return one of the following error codes:
FileSetHandleExtAttributes()
returns this if the caller does not have write-access to the file.
FileSetPathExtAttributes()
returns this if any geode (including the caller) has the file open with "deny-write" exclusive access, or if the file is not writable.
FileSet...()
routines.
By passing this extended attribute, you can get or set several extended attributes at once. This is also the only way to get, set, or create a custom attribute. If you pass this, the other arguments are slightly different. The first argument is still the file specifier (handle or path), and the second argument is FEA_MULTIPLE.
However, the third argument is the base address of an array of
FileExtAttrDesc
structures, and the fourth argument is the number of these structures in the array. The array has one element for each attribute you wish to get or set. Each
FileExtAttrDesc
structure has the following fields:
FEAD_attr
FEAD_value
FEAD_size
FEAD_value
.
FEAD_name
FEAD_attr
is set to FEA_CUSTOM, this is the address of a null-terminated string containing the custom attribute's name. If
FEAD_attr
is set to anything else, this field is ignored.
In addition to the system-defined extended attributes, any GEOS file may have any number of custom attributes. Each custom attribute is named by a null-terminated ASCII string. To create a custom attribute, call one of the
FileSet...()
routines, specifying the new attribute with a
FileExtAttrDesc
structure (as described immediately above). If you try to read a custom attribute which has not been defined for that file, the routine will fail with error condition ERROR_ATTR_NOT_FOUND.
Note that not all file systems support the use of custom extended attributes; therefore, you should write your applications so they can perform correctly without using them.
Every file has a "last modified" time. This is automatically updated whenever the file is written to.
To find the modification time of a file, get the extended attribute FEA_MODIFICATION. The modification time is returned as a 32-bit
FileDateAndTime
value. The value has the following fields, each of which is small enough to fit in a signed-byte variable:
The macros
FDATExtractYear()
,
...Month()
,
...Day()
,
...Hour()
,
...Minute()
, and
...2Second()
all extract the specified field from a
FileDateAndTime
value. The macro
FDATExtractSecond()
extracts the FDAT_2SECOND field and doubles it before returning it. The
FDATExtractYearAD()
extracts the year field and adds the base year, thus producing a word-sized year value.
There are certain attributes which all files have. These attributes specify such things as whether the file is hidden, whether it is read-only, and several other things. To get these attributes, call an extended attribute routine with argument FEA_FILE_ATTRIBUTES.
The attributes are passed or returned in a
FileAttrs
record. This record has the following fields:
Many file systems (including DOS) require that files be closed when you set these attributes. For that reason, you cannot change these attributes with
FileSetHandleExtAttributes()
. You must use either
FileSetPathExtAttributes()
or
FileSetAttributes()
(described below in Getting and Setting Information about a Byte File
). If you try to set this field with
FileSetHandleExtAttributes()
, you will be returned ERROR_ATTR_CANNOT_BE_SET.
This attribute is simply the size of the file in bytes. It is dword-sized (allowing for files as large as 4096 megabytes). The attribute can be read, but not directly changed.
This attribute is a member of the
GeosFileType
enumerated type and should not be altered. The type has the following values:
This attribute is a word-sized flag field, named
GeosFileHeaderFlags
. The following flags are implemented:
Shared-single and shared-multiple access are described in the VM chapter. For more details, see the VM chapter.
This attribute is a
ReleaseNumber
structure. Generally, only geodes have release numbers. The structure has the following fields:
RN_major
RN_minor
_change
_engineering
This attribute contains the file's protocol numbers. A
ProtocolNumber
structure is returned. For a discussion of file protocols, see the Document Objects chapter.
This attribute is the file's token. It consists of a
GeodeToken
structure. For more information about tokens, see the Applications and Geodes chapter.
This attribute is the token of the document's creator. It consists of a
GeodeToken
structure. For more information about tokens, see the Applications and Geodes chapter.
This attribute is a null-terminated string. It is displayed in the file's "Info" box. Users can edit this string with GeoManager.
This attribute contains the file's copyright notice.
This attribute is a
FileDateAndTime
structure. It contains the time when the file was created.
This attribute contains the file's encrypted password, if any.
This attribute contains the file's virtual name. It is a null-terminated character string.
This attribute contains information about the geode. If the file is not a geode, this field's value will be zero. If it is a geode, it will contain a record of
GeodeAttrs
. This record has the following fields:
This field contains information about the file's path. It is for internal use by the kernel.
This field is for internal use by the kernel.
This field is for use by the desktop manager.
This attribute contains the
DriveExtendedStatus
word for the drive containing the file. The
DriveExtendedStatus
value is described in Accessing Drives
.
GEOS SDK TechDocs
|
|
5.2 Files and File Handles
|
5.4 File Utilities