Discuss this help topic in CBFS Forum

OnGetFileInfo event/delegate/callback

Filter:

Pascal    C++ (Lib)    C++ (VCL)    C++ (.NET)    C#    VB.NET    Java 

CallbackFileSystem     See also    

Overview

The event is fired when the OS needs to get information about the file or directory.

Declaration

[Pascal]
    property OnGetFileInfo : TCbFsGetFileInfoEvent;
    TCbFsGetFileInfoEvent = procedure( Sender : TObject; FileName: TCBString; var FileExists: Boolean; var CreationTime: TDateTime; var LastAccessTime: TDateTime; var LastWriteTime: TDateTime; var ChangeTime: TDateTime; var EndOfFile: Int64; var AllocationSize: Int64; var FileId: Int64; var FileAttributes: LongWord; var NumberOfLinks: LongWord; var ShortFileName: TCBString; var RealFileName: TCBString ) of object;
    type TCBString = {$ifdef UNICODE}UnicodeString{$else}WideString{$endif};

[C++ (Lib)]
    void (__stdcall *CbFsGetFileInfoEvent)(void* Sender, wchar_t* FileName, bool * FileExists, FILETIME * CreationTime, FILETIME * LastAccessTime, FILETIME * LastWriteTime, FILETIME * ChangeTime, long long * EndOfFile, long long * AllocationSize, long long * FileId, unsigned long * FileAttributes, unsigned long * NumberOfLinks, wchar_t* ShortFileName, ushort * ShortFileNameLength, wchar_t* RealFileName, ushort * RealFileNameLength );

[C++ (VCL)]
    typedef void (__closure *TCbFsGetFileInfoEvent)( System::TObject* Sender, TCBString FileName, bool& FileExists, TDateTime & CreationTime, TDateTime & LastAccessTime, TDateTime & LastWriteTime, TDateTime & ChangeTime, __int64 & EndOfFile, __int64 & AllocationSize, __int64 & FileId, unsigned long & FileAttributes, unsigned long & NumberOfLinks, TCBString & ShortFileName, TCBString & RealFileName );

[C++ (.NET)]
    public __delegate void CbFsGetFileInfoEvent( CallbackFileSystem^ Sender, String^ FileName, bool% FileExists, DateTime% CreationTime, DateTime% LastAccessTime, DateTime% LastWriteTime, DateTime% ChangeTime, Int64% EndOfFile, Int64% AllocationSize, Int64% FileId, UInt32% FileAttributes, UInt32% NumberOfLinks, String^% ShortFileName, String^% RealFileName );

[C#]
    public void CbFsGetFileInfoEvent( CallbackFileSystem Sender, String FileName, ref bool FileExists, ref DateTime CreationTime, ref DateTime LastAccessTime, ref DateTime LastWriteTime, ref DateTime ChangeTime, ref Int64 EndOfFile, ref Int64 AllocationSize, ref Int64 FileId, ref UInt32 FileAttributes, ref UInt32 NumberOfLinks, ref String ShortFileName, ref String RealFileName );

[VB.NET]
    Sub CbFsGetFileInfoEvent( ByVal Sender As CallbackFileSystem, ByVal FileName As String, ByRef FileExists As Boolean, ByRef CreationTime As DateTime, ByRef LastAccessTime As DateTime, ByRef LastWriteTime As DateTime, ByRef ChangeTime As DateTime, ByRef EndOfFile As Int64, ByRef AllocationSize As Int64, ByRef FileId As Int64, ByRef FileAttributes As UInt32, ByRef NumberOfLinks As UInt32, ByRef ShortFileName As String, ByRef RealFileName As String )

[Java]
    void ICbFsFileEvents.onGetFileInfo( CallbackFileSystem sender, String fileName, boolRef fileExists, dateRef creationTime, dateRef lastAccessTime, dateRef lastWriteTime, dateRef changeTime, longRef endOfFile, longRef allocationSize, longRef fileId, longRef fileAttributes, longRef numberOfLinks, stringRef shortFileName, stringRef realFileName );

Parameters

  • Sender - reference to the class that called the delegate/event handler.
  • FileName - the name of the file or directory whose status is queried
  • FileExists - the event handler must set this parameter to true if the file exists and the information is provided and false otherwise
  • CreationTime - the event handler must place the time of the object creation to this parameter. The value can be empty (zero in VCL, DateTime.MinValue in .NET) if the parameter is not supported.
  • LastAccessTime - the event handler must place the time of last access to the object to this parameter. The value can be empty (zero in VCL, DateTime.MinValue in .NET) or equal if the parameter is not supported.
  • LastWriteTime - the event handler may place the time of last modification of the object to this parameter. The value can be empty (zero in VCL, DateTime.MinValue in .NET) if the parameter is not supported.
  • ChangeTime - the event handler must place the time of last change of the object contents or metadata (eg. security attributes) to this parameter.
    Set ChangeTimeAttributeSupported property to true if you plan to use this parameter.
    Keep the parameter unchanged if you don't want to set the time. In this case the last modification time is used.
  • EndOfFile - the event handler must place the size of the file data in bytes to this parameter. The size is 0 for directories.
  • AllocationSize - the event handler must place the size of the space, allocated for the file to this parameter. The allocation size is in most cases a multiple of the allocation unit (cluster) size. The size is 0 for directories.
  • FileId - the event handler may place the unique ID of the file to this parameter. The parameter is optional.
  • FileAttributes - the event handler must place the file attributes to this parameter
  • NumberOfLinks - the event handler must put the number of links that point to the file to this parameter. Default is 1. For directories the number of links should always be 1.
  • ShortFileName - if the filesystem supports DOS (8.3) names, it can put the short name to ShortFileName
    [C++ (Lib)]
  • ShortFileNameLength - the length (in characters without trailing NULL) of the name, put by the application to ShortFileName parameter
  • RealFileName - if the filesystem supports case-sensitive names the application can put "real" file name to RealFileName
    [C++ (Lib)]
  • RealFileNameLength - the length (in characters without trailing NULL) of the name, put by the application to RealFileName parameter

Description

The event is fired when the OS needs to get information about the file or directory. If the file exists, FileExists parameter must be set to true and all information (besides optional parameters, as specified above) must be set. If the file doesn't exist, then FileExists must be set to false. In this case no parameters are read back.

Time-related parameters (CreationTime, LastAccessTime, LastWriteTime, ChangeTime) are in UTC timezone.

If you have enabled short file name support, your callback should return short name (which must not exceed 12 characters in 8.3 format) via ShortFileName parameter. Note, that it is possible that the OS sends you short filename in FileName parameter, in which case you still need to provide the same short name in ShortFileName parameter.

If you have enabled case-sensitive file name support, the driver might need to ask your code for "normalized" filename. This means that if the driver gets a request for "QWERTY.txt", but only "qwErTy.TxT" file exists on the filesystem, your code can return the existing file name using RealFileName parameter.

To speed-up operations (save one string length measurement per name) the driver doesn't measure the length of the passed short and real file names, so your code must put the length of the passed file names into ShortFileNameLength and RealFileNameLength parameters.

Error handling

See Error handling topic for detailed information about how to report errors, which occur in the event handlers, back to Callback File System.

See also

ChangeTimeAttributeSupported property     OnEnumerateDirectory event    

Discuss this help topic in CBFS Forum