Accessing file system properties

Any property that the file system interface defines and understands is called a file system property.

Each file system entity provides accessor functions for the properties associated with it. All file system properties are readable, and each has a Get function associated with it. If a property can also be modified, the class includes a Set member function. For example, the TFileSystemEntity class contains declarations for GetModificationTime and SetModificationTime, so that you can read and modify the property that stores the entity's modification time.

In addition to the accessor functions, the file system entity classes provide pre-constructed identifiers for each file system property in the form of references to TPropertyID instances. You can use these identifiers to access specific properties. For example, TFileSystemEntity declares a reference to the modification time property using the identifier kModificationTime. You can access the modification time using this identifier instead of an accessor function.

Whether you access properties using accessor functions or identifiers is up to you. Accessor functions are often more convenient. When you retrieve multiple file system properties, however, you can optimize performance by using identifiers. If you retrieve three properties using accessor functions, the system makes three round trips to get each property. If you construct a property set with identifiers instead, and retrieve the values for the set, the system makes a single round trip to return all three property values.

Table 1 shows each of the properties defined by the file system. All of these properties are readable and none are polymorphic.

Entity Kind Property Identifier Write

File System Properties
All TPropertyIDFor<FileSystemEntityName> TFileSystemEntity::kName Yes
All TPropertyIDFor<TTime> TFileSystemEntity::kCreationTime Yes
All TPropertyIDFor<TTime> TFileSystemEntity::kModification Time Yes
TFile TPropertyIDFor<FSEntitySize> TFile::kEndOfFile No
TVolume TPropertyIDFor<FSEntitySize> TVolume::kTotalSpace No
TVolume TPropertyIDFor<FSEntitySize> TVolume::kFreeSpace No

NOTE These properties represent only a subset of the file system properties planned for later releases.

Behavior of file system properties

Not all of the file system properties behave the same way. While you can read all properties associated with file system entities, you can only write to some of them (using WriteProperty or WriteProperties) and you cannot delete any of them.

When you make a request to delete a file system property, or to write to a property that does not allow modification, the system ignores the request. You do not get an exception if you attempt one of these actions. This means that you can follow a ReadProperties call with a WriteProperties call, without adding exception handling for a common case.

Every file system entity always has the file system properties associated with that particular type of entity. For example, any TFile instance has an End of File property, and any TDirectory instance has a Member Count. It follows, then, that file system entities do not have properties not associated with that type of entity. For example, a TFile never has a Free Space property, because that property does not apply to a file.

NOTE File system properties do not allow polymorphic values.

Accessing file system properties using functions

This example uses accessor functions to read a file name of myFile--an existing TFile instance--and write out a new file name.

      TFileSystemEntityName fileName = myFile.GetName;
      myFile.SetName("NewFilename");

Accessing file system properties using identifiers

This example:

      TPropertyIDFor<TTime> prop(TFileSystemEntity::kModificationTime)
      anEntity->ReadProperty(prop);
      TTime           modifyTime = prop.GetValue();

[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker