Open Event
Fires when the OS wants to open a file.
Syntax
type TOpenEvent = procedure ( Sender: TObject; const Path: String; Flags: Integer; var DirectIO: Boolean; var KeepCache: Boolean; var NonSeekable: Boolean; var FileContext: Integer; var Result: Integer ) of Object;
property OnOpen: TOpenEvent read FOnOpen write FOnOpen;
Remarks
This event fires when the OS wants to open the existing file specified by Path using the open options reflected in Flags. The set of possible flags and options corresponds to the Flags parameter of Linux open(2) call.
The application may use the FileContext parameter to store a file handle or other information, related to the open file. Windows: the stored information will be shared between all concurrent file open operations performed on this file.
Linux: DirectIO parameter may be set by the application to tell the kernel that buffering or caching should be avoided. KeepCache parameter may be set by the application to tell the kernel that existing file caches (if any) should not be invalidated. NonSeekable parameter may be set by the application to tell the kernel that the file is not seekable.
The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), set it to a negative error code value (e.g. -ENOENT to indicate that the file does not exist) to report an appropriate error. Please refer to the Error Reporting and Handling topic for more information.