OnReadFileC event/delegate/callback

Filter:

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

CBFSFilter     See also    

Overview

This callback is called right after the OS reads the data from the open file.

Declaration

[Pascal]
    property OnReadFileC : TCBFSFltReadFileEventC;
    TCBFSFltReadFileEventC = procedure(Sender : TObject; FileName: TCBString; Position: Int64; var Buffer; BytesToRead: LongWord; Direction: LongWord; Status : DWORD; var FileContext: pointer; var HandleContext: pointer) of object;
    type TCBString = {$ifdef UNICODE}UnicodeString{$else}WideString{$endif};

[C++ (Lib)]
    typedef void (*CBFSFltReadFileEventC)(CBFSFilter* Sender, LPWSTR FileName, __int64 Position, PVOID Buffer, DWORD BytesToRead, CBFSFltDataFlow Direction, LONG Status, PVOID* FileContext, PVOID* HandleContext);

[C++ (VCL)]
    typedef void __fastcall (__closure *TCBFSFltReadFileEventC)(System::TObject* Sender, TCBString FileName, __int64 Position, void *Buffer, unsigned long BytesToRead, unsigned Direction, DWORD Status, void* *FileContext, void* *HandleContext);

[C++ (.NET)]
    public delegate void CBFSFltReadFileEventC(CBFSFilter^ Sender, String^ FileName, Int64 Position, IntPtr Buffer, Int32 BytesToRead, CBFSFltDataFlow Direction, Int32 Status, IntPtr% FileContext, IntPtr% HandleContext);

[C#]
    delegate void CBFSFltReadFileEventC(CBFSFilter^ Sender, string FileName, long Position, IntPtr Buffer, Int32 BytesToRead, CBFSFltDataFlow Direction, Int32 Status, ref IntPtr FileContext, ref IntPtr HandleContext);

[VB.NET]
    Delegate Sub CBFSFltReadFileEventC(ByVal Sender As CBFSFilter, ByVal FileName As String, ByVal Position As Long, ByVal Buffer As IntPtr, ByVal BytesToRead As Int32, ByVal Direction As CBFSFltDataFlow, ByVal Status As Int32, ByRef FileContext As IntPtr, ByRef HandleContext as IntPtr)

Parameters

  • Sender - reference to the class that called the delegate/event handler
  • FileName - contains the name of the file
  • Position - the starting position to read the file data from
  • Buffer - the buffer to put the read data
  • BytesToRead - the number of bytes to read from the file. The Buffer contains not more space, than this value.
  • Direction - specifies the direction of the data fllow (see below)
  • Status - status code of the completed operation
  • FileContext - the placeholder for the application-defined data, common to all concurrent file operations on the file
  • HandleContext - the placeholder for the application-defined data, local to each opened file handle

Values of CBFSFltDataFlow

Description

This callback is called when the OS needs to read the data from the open file, after the request was processed by the underlying file system. In the callback handler for this callback you can perform postprocessing of the data which have been read from the file.

If you need to modify the data which were read, write the data (no more than BytesToRead bytes) to the provided Buffer.

To report the failure and cancel reading operation you need to throw an instance of ECBFSFilterError.

[.NET]
In .NET you should not try to replace the Buffer. Instead you need to copy the data to the provided buffer. You can use Array.Copy method for this.

Read more about contexts.

Attention: HandleContext can be empty, if the operation is performed by the cache manager or memory manager. In these situation, the operation is not associated with any particular handle.

See also

OnReadFileN