Solid File System

Virtual file system enigne that can be embedded into your software.

OnFileRead event/delegate/callback

Filter:

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

SolFSStorage     See also    

Overview

This event is fired when SolFS wants to read the data from the storage.

Declaration

[Pascal]
    TSolFSReadFileEvent = procedure( Sender : TObject; FileHandle : THandle; Buffer : Pointer; Count : LongWord; var Result : LongInt) of object;

[Plain C]
    typedef Error (__stdcall *SolFSReadFileFunc)( LongWord UserData, void* Buffer, unsigned long Count, Handle FileHandle);

[C++ (DLL/Lib)]
    typedef Error (__stdcall *SolFSReadFileFunc)( LongWord UserData, void* Buffer, unsigned long Count, Handle FileHandle);

[C++ (VCL)]
    typedef void (__closure *TSolFSReadFileEvent)( System::TObject* Sender, Handle FileHandle, void* Buffer, unsigned long Count, Error& Result);

[C++ (.NET)]
    public __delegate void SolFSReadFileEvent( SolFSStorage* Sender, UInt32 FileHandle, unsigned char Buffer __gc[], unsigned long Count, Int32 __gc &Result);

[C#]
    public void SolFSReadFileEvent( SolFS.SolFSStorage Sender, uint FileHandle, uchar[] Buffer, ulong Count, ref int Result);

[VB.NET]
    Sub SolFSReadFileEvent( ByVal Sender As SolFS.SolFSStorage, ByVal FileHandle As UInt32, ByVal Buffer As Byte(), ByVal Count As UInt32, ByRef Result As Int32)

[Java]
    byte[] ISolFSFileEvents.onFileRead(long count)

Parameters

  • Sender - reference to the class that called the delegate/event handler.
  • FileHandle - Handle to the storage, from which the data is to be read.
  • Buffer - a reference to the buffer where application should store the data read from the file.
  • Count - the number of bytes to be read
  • Result - out parameter (return value for DLL) where the application places the result of the operation. If you are working with file system, Win32 error code is a good candidate for placing to Result parameter. Otherwise you can use any other error codes, just be sure that 0 means success.
    [Java]See Description for details about error reporting in Java.

  • [Plain C] UserData - application-defined parameter which is specified when creating the storage and passed back to callback function.

[Java]  Return values

The buffer with the read data.

Description

This event is fired when SolFS wants to read the data from the storage. Reading is always performed in chunks having size of multiple of storage page size. The position, from which to start reading, is determined by file pointer, which is adjusted using OnFileSeek event.
Read operation is successful only when Count bytes have been read. Otherwise the application must return non-zero error code in Result parameter.

The callback/event handler must be set before the storage is opened.

[Java]
You need to implement ISolFSFileEvents interface in your code and pass the object, that implements the events, to one of SolFSStorage constructors that accept storageEvents parameter.

[Java]
ERROR REPORTING: In Java you can't return more than one parameter, so the natural way is to throw an exception. You can throw any exception, and this exception will be passed back to the code, which called one of SolFS functions. So if you use callback mechanism and throw exception from within event handlers, be sure to wrap each call to SolFS methods with try/catch.

See also

Information about callbacks (Operating System edition only)     OnFileSeek     OnFileWrite    

Back to top