TBLFile
A thin abstraction over a native OS file IO.
A thin wrapper around a native OS file support. The file handle is always THandle
and it refers to either a file descriptor on POSIX targets and file handle on Windows targets.
Definition
Unit: Blend2D
Properties
Name | Description |
---|---|
IsOpen | Whether the file is open. |
Size | The size of the file. |
Constructors
Name | Description |
---|---|
Assign | Copying a file is not allowed. This will raise a EBlend2DError exception with result TBLResult.NotPermitted . |
Create | Creates a file instance from an existing file AHandle , which either represents a file descriptor or Windows handle. |
Finalize | Destroys this file instance - closes the file descriptor or handle when it's referencing an open file. |
Initialize | Creates an empty file instance, which doesn't represent any open file. |
Operators
Name | Description |
---|---|
Equal | Used to compare against nil (empty file instance). |
NotEqual | Used to compare against nil (empty file instance). |
Methods
Name | Description |
---|---|
Close | Closes the file (if open) and sets the file handle to THandle.MaxValue . |
GetInfo | Queries information of the file. |
Open | Attempts to open a file specified by AFilename with the given AOpenFlags . |
Read | Reads ACount bytes from the file into the given ABuffer and returns the number of bytes actually read. |
Seek | Sets the file position of the file to the given AOffset by using the specified ASeekType and returns the new position. |
Truncate | Truncates the file to the given maximum size AMaxSize . |
Write | Writes ACount bytes to the file from the given ABuffer and returns the number of bytes actually written. |
Property Descriptions
IsOpen
Whether the file is open.
property IsOpen: Boolean read GetIsOpen
Type: Boolean
Size
The size of the file.
property Size: Int64 read GetSize
Type: Int64
Exceptions
EBlend2DError
: Raised on failure.
Constructor Descriptions
Assign
Copying a file is not allowed. This will raise a EBlend2DError
exception with result TBLResult.NotPermitted
.
constructor Assign(var ADest: TBLFile; const ASrc: TBLFile); inline
Parameters
ADest
: TBLFile
ASrc
: TBLFile
Exceptions
EBlend2DError
: Raised on failure.
Create
Creates a file instance from an existing file AHandle
, which either represents a file descriptor or Windows handle.
constructor Create(const AHandle: THandle)
Parameters
AHandle
: THandle
Finalize
Destroys this file instance - closes the file descriptor or handle when it's referencing an open file.
destructor Finalize(var ADest: TBLFile)
Parameters
ADest
: TBLFile
Exceptions
EBlend2DError
: Raised on failure.
Initialize
Creates an empty file instance, which doesn't represent any open file.
constructor Initialize(out ADest: TBLFile)
Parameters
ADest
: TBLFile
Remarks
The internal file handle of non-opened files is set to THandle.MaxValue
.
Operator Descriptions
Equal(TBLFile, Pointer)
Used to compare against nil
(empty file instance).
class operator Equal(const ALeft: TBLFile; const ARight: Pointer): Boolean; inline; static
Parameters
ALeft
: TBLFile
ARight
: Pointer
Returns
Boolean
NotEqual(TBLFile, Pointer)
Used to compare against nil
(empty file instance).
class operator NotEqual(const ALeft: TBLFile; const ARight: Pointer): Boolean; inline; static
Parameters
ALeft
: TBLFile
ARight
: Pointer
Returns
Boolean
Method Descriptions
Close
Closes the file (if open) and sets the file handle to THandle.MaxValue
.
procedure Close; inline
Exceptions
EBlend2DError
: Raised on failure.
GetInfo
Queries information of the file.
function GetInfo: TBLFileInfo
Exceptions
EBlend2DError
: Raised on failure.
Returns
Open(String, TBLFileOpenFlags)
Attempts to open a file specified by AFilename
with the given AOpenFlags
.
procedure Open(const AFilename: String; const AOpenFlags: TBLFileOpenFlags); inline
Exceptions
EBlend2DError
: Raised on failure.
Parameters
AFilename
: String
AOpenFlags
: TBLFileOpenFlags
Read([untyped], Int64)
Reads ACount
bytes from the file into the given ABuffer
and returns the number of bytes actually read.
function Read(var ABuffer; const ACount: Int64): Int64; inline
Exceptions
EBlend2DError
: Raised on failure.
Parameters
ABuffer
:
ACount
: Int64
Returns
Int64
Seek(Int64, TBLFileSeekType)
Sets the file position of the file to the given AOffset
by using the specified ASeekType
and returns the new position.
function Seek(const AOffset: Int64; const ASeekType: TBLFileSeekType): Int64; inline
Exceptions
EBlend2DError
: Raised on failure.
Parameters
AOffset
: Int64
ASeekType
: TBLFileSeekType
Returns
Int64
Truncate(Int64)
Truncates the file to the given maximum size AMaxSize
.
procedure Truncate(const AMaxSize: Int64); inline
Exceptions
EBlend2DError
: Raised on failure.
Parameters
AMaxSize
: Int64
Write([untyped], Int64)
Writes ACount
bytes to the file from the given ABuffer
and returns the number of bytes actually written.
function Write(const ABuffer; const ACount: Int64): Int64; inline
Exceptions
EBlend2DError
: Raised on failure.
Parameters
ABuffer
:
ACount
: Int64
Returns
Int64