GetFileInfo Event

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

Syntax

ANSI (Cross Platform)
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; Unicode (Windows) 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;
#define EID_CBFS_GETFILEINFO 20

virtual INT CBFSCONNECT_CALL FireGetFileInfo(LPWSTR &lpszFileName, BOOL &bFileExists, LONG64 &lCreationTime, LONG64 &lLastAccessTime, LONG64 &lLastWriteTime, LONG64 &lChangeTime, LONG64 &lSize, LONG64 &lAllocationSize, LONG64 &lFileId, LONG64 &lAttributes, INT &iHardLinkCount, LPWSTR &lpShortFileName, INT &lenShortFileName, LPWSTR &lpRealFileName, INT &lenRealFileName, INT &iResultCode);

Remarks

This event fires when the OS needs information about the file or directory specified by FileName and in some other cases (see the notes below).

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, i.e., as FILETIME. 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. Please refer to the File IDs topic for more information.
  • 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.

Notes:

  1. 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.
  2. if the UpdateFileMetadataOnOpen config setting is true, this event will fire right after the OpenFile event but only if the file was fully closed before OpenFile.

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) 2022 Callback Technologies, Inc. - All rights reserved.
CBFS Connect 2020 C++ Edition - Version 20.0 [Build 8348]