Discuss this help topic in CBFS Forum

OnWriteFile event/delegate/callback

Filter:

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

CallbackFileSystem     See also    

Overview

This event is fired when the OS needs to write the data to the open file or volume.

Declaration

[Pascal]
    property OnWriteFile : TCbFsWriteFileEvent;
    TCbFsWriteFileEvent = procedure( Sender : TObject; FileInfo: TCbFsFileInfo; Position: Int64; var Buffer; BytesToWrite: LongWord; var BytesWritten: LongWord ) of object;

[C++ (Lib)]
    void (__stdcall *CbFsWriteFileEvent)(void* Sender, CbFsFileInfo* FileInfo, long long Position, void * Buffer, unsigned long BytesToWrite, unsigned long & BytesWritten );

[C++ (VCL)]
    typedef void (__closure *TCbFsWriteFileEvent)( System::TObject* Sender, TCbFsFileInfo* FileInfo, __int64 Position, void * Buffer, unsigned long BytesToWrite, unsigned long & BytesWritten );

[C++ (.NET)]
    public __delegate void CbFsWriteFileEvent( CallbackFileSystem^ Sender, CbFsFileInfo^ FileInfo, Int64 Position, Byte Buffer[], Int32 BytesToWrite, Int32% BytesWritten );

    public __delegate void CbFsWriteFileNativeEvent( CallbackFileSystem^ Sender, CbFsFileInfo^ FileInfo, Int64 Position, IntPtr Buffer, Int32 BytesToWrite, Int32% BytesWritten );

[C#]
    public void CbFsWriteFileEvent( CallbackFileSystem Sender, CbFsFileInfo FileInfo, Int64 Position, byte[] Buffer, Int32 BytesToWrite, ref Int32 BytesWritten );

    public void CbFsWriteFileNativeEvent( CallbackFileSystem Sender, CbFsFileInfo FileInfo, Int64 Position, IntPtr Buffer, Int32 BytesToWrite, ref Int32 BytesWritten );

[VB.NET]
    Sub CbFsWriteFileEvent( ByVal Sender As CallbackFileSystem, ByVal FileInfo As CbFsFileInfo, ByVal Position As Int64, ByVal Buffer As Byte(), ByVal BytesToWrite As Int32, ByRef BytesWritten As Int32 )

    Sub CbFsWriteFileNativeEvent( ByVal Sender As CallbackFileSystem, ByVal FileInfo As CbFsFileInfo, ByVal Position As Int64, ByVal Buffer As IntPtr, ByVal BytesToWrite As Int32, ByRef BytesWritten As Int32 )

[Java]
    void ICbFsFileEvents.onWriteFile( CallbackFileSystem sender, CbFsFileInfo fileInfo, long position, byteArrayRef buffer, int bytesToWrite, intRef bytesWritten );

Parameters

  • Sender - reference to the class that called the delegate/event handler
  • FileInfo - contains the information about the file
  • Position - starting position to write the file data to
  • Buffer - the buffer with data to be written
  • BytesToWrite - the number of bytes to write to the file.
  • BytesWritten - the event handler must set the parameter to the number of bytes actually written to the file.

Description

This event is fired when the OS needs to write the data to the open file or volume. Note, that unless you create the virtual disk for some specific application, your callback handler should be able to write exactly BytesToWrite bytes of data. Writing less data than expected is an unexpected situation for many applications, and they will fail if you write less bytes than requested.

Read more about contexts.

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

MaxWriteBlockSize property     GetHandleInfo method     OnCreateFile event     OnOpenFile event     OnReadFile event    

Discuss this help topic in CBFS Forum