function FileCreate(const FileName: UnicodeString): THandle;
function FileCreate(const FileName: UnicodeString; Rights: Integer): THandle;
function FileCreate(const FileName: UnicodeString; ShareMode: Integer; Rights: Integer): THandle;
function FileCreate(const FileName: RawByteString): THandle;
function FileCreate(const FileName: RawByteString; Rights: Integer): THandle;
function FileCreate(const FileName: RawByteString; ShareMode: Integer; Rights: Integer): THandle;
Creates a new file named FileName on disk (overwriting any existing file of the same name) and returns a file handle that can be used with FileRead and FileWrite; ShareMode controls file-sharing/locking behavior (a combination of fmShareCompat, fmShareDenyNone, fmShareDenyRead, fmShareDenyWrite, fmShareExclusive), while the optional Rights parameter sets the Unix file mode and is ignored on other platforms. Returns THandle(-1) on error (e.g. disk full or invalid path).
function FileOpen(const FileName: unicodestring; Mode: Integer): THandle;
function FileOpen(const FileName: RawByteString; Mode: Integer): THandle;
Opens an existing file named FileName in the given Mode (fmOpenRead, fmOpenWrite, or fmOpenReadWrite, optionally OR-ed with a sharing/locking flag such as fmShareExclusive, fmShareDenyWrite, fmShareDenyRead, or fmShareDenyNone) and returns a file handle for use with FileRead/FileWrite; it does not create the file if it does not already exist — use FileCreate for that. Returns THandle(-1) on error.
function FileRead(Handle: THandle; out Buffer; Count: LongInt): LongInt;
Reads Count bytes from the file identified by Handle (obtained via FileOpen) into Buffer, which must be at least Count bytes long since no bounds checking is performed; returns the number of bytes actually read, or -1 on error.
function FileSeek(Handle: THandle; FOffset: LongInt; Origin: LongInt): LongInt;
function FileSeek(Handle: THandle; FOffset: Int64; Origin: LongInt): Int64;
Moves the file pointer of Handle to FOffset relative to Origin (fsFromBeginning, fsFromCurrent, or fsFromEnd — note Offset must be zero or negative when Origin is fsFromEnd) and returns the new position relative to the start of the file, or -1 on error.
function FileTruncate(Handle: THandle; Size: Int64): Boolean;
Truncates the file identified by Handle, which must have been opened for writing, to Size bytes; returns True on success and False otherwise.
function FileWrite(Handle: THandle; const Buffer; Count: LongInt): LongInt;
Writes Count bytes from Buffer to the file identified by Handle, which must have been opened for writing beforehand; Buffer must be at least Count bytes long. Returns the number of bytes actually written, or -1 on error.
procedure FileClose(Handle: THandle);
Closes the file identified by Handle; any subsequent read or write attempt on that handle will result in an error.
Other routines in SysUtils:
File Name Handling Routines,
File Input/Output Routines,
Date/Time Routines,
Conversion Routines,
String Functions,
Formatting Strings,
PChar Related Functions.