CBFS Connect 2020 Node.js Edition

Questions / Feedback?

GetFileInfo Event

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

Syntax

cbfs.on('GetFileInfo', [callback])

Callback

The 'callback' is called when the 'GetFileInfo' event is emited.

function(e){ }

The argument 'e' has the following properties:

e.fileName
e.fileExists
e.creationTime
e.lastAccessTime
e.lastWriteTime
e.changeTime
e.size
e.allocationSize
e.fileId
e.attributes
e.hardLinkCount
e.shortFileName
e.realFileName
e.resultCode

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 in UTC. Any non-applicable time values can be left unchanged, or set to January 1, 1970 00:00:00 UTC.
  • 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.
    • 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.
    • 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 Node.js Edition - Version 20.0 [Build 8164]