GetFileInfo Event

Fires when the OS needs information about a file or directory.

Syntax

virtual int FireGetFileInfo(CBFSGetFileInfoEventParams *e);
typedef struct {
const char *FileName;
int FileExists;
int64 *pCreationTime;
int64 *pLastAccessTime;
int64 *pLastWriteTime;
int64 *pChangeTime;
int64 *pSize;
int64 *pAllocationSize;
int64 *pFileId;
int64 *pAttributes;
int HardLinkCount;
char *ShortFileName; int lenShortFileName;
char *RealFileName; int lenRealFileName;
int ResultCode; int reserved; } CBFSGetFileInfoEventParams;
virtual INT FireGetFileInfo(CBFSGetFileInfoEventParams *e);
typedef struct {
LPCWSTR FileName;
BOOL FileExists;
LONG64 *pCreationTime;
LONG64 *pLastAccessTime;
LONG64 *pLastWriteTime;
LONG64 *pChangeTime;
LONG64 *pSize;
LONG64 *pAllocationSize;
LONG64 *pFileId;
LONG64 *pAttributes;
INT HardLinkCount;
LPWSTR ShortFileName; INT lenShortFileName;
LPWSTR RealFileName; INT lenRealFileName;
INT ResultCode; INT reserved; } CBFSGetFileInfoEventParams;

Remarks

This event fires when the OS needs information about the file or directory specified by FileName.

To handle this event properly, applications should first check whether the specified file or directory exists, and set FileExists accordingly. If no such file or directory exists, set FileExists to false. If the file or directory exists, set FileExists to true and supply its information using the following parameters:

  • CreationTime, LastAccessTime, LastWriteTime, ChangeTime: Set to the corresponding time values of the file or directory, specified as a number of 100-nanosecond intervals since Jan 1, 1601 00:00:00 UTC. Any non-applicable time values can be left unchanged, or set to 0.
  • Size: For files, set to the size of the file, in bytes; for directories, set to 0.
  • AllocationSize: For files, set to the number of bytes allocated locally for the file; for directories, set to 0. The allocation size is typically a multiple of the ClusterSize.
  • FileId: Set to the unique Id of the file or directory; this Id should not change over time.
    • The Windows Network redirector module, and some third-party applications, open files by Id instead of by name.
    • If the returned Id is 0, the class will generate an Id. This generated Id is not guaranteed to be unique, especially under heavy load.
    • The root directory (\) always uses the predefined Id 0x7FFFFFFFFFFFFFFF.
  • Attributes: Set to the attributes of the file or directory.
  • HardLinkCount: If the UseHardLinks property is enabled, set to the number of hard links that point to the file. The default value is 1 (which is also the only valid value for directories). Please refer to the Hard Links topic for more information.
  • ShortFileName: If the UseShortFileNames property is enabled, set to the short (8.3) name of the file.
    • The name must be copied to ShortFileName; set lenShortFileName to the length of the copied string (measured in char/wchar_t, not including terminating nulls).
    • If UseShortFileNames is enabled, it's possible that FileName is already a short name. In such cases, return the same name in ShortFileName.
    • The short name must adhere to the 8.3 name format; please refer to the Short File Names topic for more information.
  • RealFileName: If the UseCaseSensitiveFileNames property is enabled, and FileName's casing differs from that of the actual file or directory name, set to the "real" name of said file or directory.
    • For example, if the requested FileName is QWERTY.txt, but the only similarly-named file in the virtual filesystem is qwErTy.TxT, then this parameter should be set to the latter.
    • The name must be copied to RealFileName; set lenRealFileName to the length of the copied string (measured in char/wchar_t, not including terminating nulls).
    • If the specified FileName includes a path, it must be preserved in the value returned via RealFileName; only the casing of the filename and extension may be corrected.
    • The length of the returned name (and path, if applicable) must not exceed the value of the MaxFilePathLength property.

Note: if the UseCaseSensitiveFileNames and UseAlternateDataStreams properties are both enabled, this event may also be used to obtain the "real name" of a named stream. When returning the name of a named stream via the RealFileName parameter, prepend a colon (:) to the stream's name so that it looks like, e.g, :Zone.Identifier.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), set it to a non-zero value to report an appropriate error. Please refer to the Error Reporting and Handling topic for more information.

 
 
Copyright (c) 2020 Callback Technologies, Inc. - All rights reserved.
CBFS Connect 2020 C++ Edition - Version 20.0 [Build 7545]