Solid File System

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

OnFileOpen 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 storage needs to be opened.

Declaration

[Pascal]
    TSolFSOpenFileEvent = procedure( Sender : TObject; const FileName : TSolFSString; var FileHandle : THandle; var ReadOnly : boolean; IsJournalFile : boolean; var Result : LongInt) of object;

[Plain C]
    typedef Error (__stdcall *SolFSOpenFileFunc)( LongWord UserData, PWideChar FileName, PHandle FileHandle, Bool *ReadOnly, Bool IsJournalFile);

[C++ (DLL/Lib)]
    typedef Error (__stdcall *SolFSOpenFileFunc)( LongWord UserData, PWideChar FileName, PHandle FileHandle, Bool *ReadOnly, Bool IsJournalFile);

[C++ (VCL)]
    typedef void (__closure *TSolFSOpenFileEvent)( System::TObject* Sender, PWideChar FileName, PHandle FileHandle, Bool *ReadOnly, Bool IsJournalFile, Error& Result);

[C++ (.NET)]
    public __delegate void SolFSOpenFileEvent( SolFSStorage* Sender, System::String* FileName, UInt32 __gc &FileHandle, Boolean __gc &ReadOnly, bool IsJournalFile, Int32 __gc &Result);

[C#]
    public void SolFSOpenFileEvent( SolFS.SolFSStorage Sender, string FileName, ref uint FileHandle, ref bool ReadOnly, bool IsJournalFile, ref int Result);

[VB.NET]
    Sub SolFSOpenFileEvent( ByVal Sender As SolFS.SolFSStorage, ByVal FileName As String, ByRef FileHandle As UInt32, ByRef ReadOnly As Boolean, ByVal IsJournalFile As Boolean, ByRef Result As Int32)

[Java]
    boolean ISolFSFileEvents.onFileOpen( String fileName, boolean readOnly, boolean isJournalFile)

Parameters

  • Sender - reference to the class that called the delegate/event handler.
  • FileName - the name of the storage as passed to SolFSStorage.Create constructor.
  • FileHandle - the place where the event handler must place some handle, that uniquely identifies the storage object. This handle is later passed to other events. Set this parameter to -1 ($FFFFFFFF, 0xFFFFFFFF) if the file could not be opened.
  • ReadOnly - set this parameter to true if the storage was opened in read-only mode or false if SolFS can write to storage.
  • IsJournalFile - specifies if the storage to be created is a data storage or journal storage. In SolFS 3 and later this parameter is always false.
  • 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

Returns True if the file was opened in read-only mode and false otherwise.

Description

The event is fired when storage is to be opened. The application must create the storage and return some handle to theis storage. The handle will be passed to other delegate/event handlers for further file manipulation.

The handler must open the storage in read-only mode if ReadOnly parameter was set to true by the caller. The handler may open the storage in read-only mode when it was asked to open it in read-write mode. If the handler opens the storage in read-only mode, it must set ReadOnly parameter to true (in Java, return true as a return value).

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)     OnFileClose     OnFileCreate    

Back to top