File-Functions

LA.Docs
March 1st, 2016

List of File-Functions


ChangeFileExt(const FileName, Extension: string): string

Changes the file extention of given file name. Does not actually change the physical file.

Example Pascal:
ShowMessage(ChangeFileExt(’/path/to/file.txt’, ’.data’));

CopyFile(SourceName, DestName: string; FailIfExists: bool = false): bool

Copies a source file to a destination file. If FailIfExists is set to true, the copy operation is aborted.

CreateDir(Dir: String): bool

Creates a directory. CreateDir does not create directories recursively. If you need to create directories recursively use the method ForceDir instead.

CurrentDir(): string

Returns the current working directory.

DateTimeToFileDate(value: datetime): int

Converts a datetime to file date

DeleteDir(Dir: String): bool

Deletes a empty directory. Fails if directory is not empty. If you need to delete a directory recursively use ForceDeleteDir instead.

DeleteFile(const FileName: string): bool

Deletes the given file physically from disk. No recovery possible!

DirExists(Dir: String): bool

Returns true when the given directory exists.

DirSep(): string

Returns the Directory Seperator char. On Windows systems \ on *nix systems /

DiskFree(Drive: Byte): int64

Returns the free space left on the disk in bytes. Drive is a sequential number of the drives/partions.

Example Basic:
println(IntToStr(DiskFree(0) / 1024 / 1024 / 1024)+” Gb")

DiskSize(Drive: Byte): int64

Returns the disk size in bytes. Drive is a sequential number of the drives/partions.

Example Basic:
println(IntToStr(DiskSize(0) / 1024 / 1024 / 1024)+” Gb")

ExpandFileName(const FileName: string): string

Expands the given file name to a fully qualified path and file name.

FileAge(FileName: string): int

Returns the File create date in File date format.

FileClose(Handle: int64)

Closes a open file handle.

FileCreate(FileName: string; Rights: int): int64

Creates a file and returns a handle to the open file.

FileDateToDateTime(value: int): datetime

Converts a File date to datetime.

FileDirOf(const FileName: string): string

Returns the directory portion of a full file path.

FileDriveOf(const FileName: string): string

Returns the drive portion of a full file path. On *nix systems that would be always root /

FileExists(FileName: String): bool

Returns true when the given file name exists.

FileExtOf(const FileName: string): string

Returns the extention portion of a file name.

FileGetAttr(FileName: String): int

Returns the file attribute flags of given file name.

FileGetDate(Handle: int64): int

Returns the last modified date of given file handle.

FileIsReadOnly(const FileName: string): bool

Returns true when given file name is read only.

FileNameOf(const FileName: string): string

Returns the file name portion and strips the path of a file name.

FileOpen(FileName: string; Mode: int): int64

Opens a file handle to the given file.

FilePathOf(const FileName: string): string

Returns the path portion of the given file name.

FileRead(Handle: int; Buffer: String; Count: int): int

Read from a file into the buffer.

FileSeek(Handle, Offset, Origin: int): int

Place the file cursor to the given offset.

FileSetAttr(const FileName: string; Attr: int): int

Sets the file attributes of the given file.

FileSetDate(const FileName: string; Age: int): int

Sets the modified date of the given file.

FileSize(FileHandle: int64): int64

Returns the file size in bytes.

FileSizeBytesOf(Filename: string): double

Returns the file size in bytes.

FileSizeGigaBytesOf(Filename: string): double

Returns the file size in Gigabytes.

FileSizeKiloBytesOf(Filename: string): double

Returns the file size in Kilobytes.

FileSizeMegaBytesOf(Filename: string): double

Returns the file size in Megabytes.

FileSizeOf(FileName: String): int64

Returns the file size in bytes.

FileWrite(Handle: int; Buffer: String; Count: int): int

Write the given buffer to the file handle.

ForceDeleteDir(DirName: String)

Deletes a directory recursively including all files and sub-folders.

ForceDir(Dir: String): bool

Creates a directory recursively.

Merge(FirstSplitFileName, OutFileName: String)

Merges a split file sequences into one file. This method can only merge files that was split with the method Split.

MoveFile(SourceName, DestName: string; FailIfExists: bool = false): bool

Copies the source file to the destination file and deletes the source file. If FailIfExists is set to true, the move operation is aborted.

ReadToStr(FileName: String): string

Reads the contents of a file and returns it as a string value.

RenameFile(const OldName, NewName: string): bool

Renames a file.

SearchDir(DirName, FileMask: string; FileList: TStrings)

Searches given directory name recursively and list the files into the given file string list.

SetCurrentDir(DirName: string): bool

Sets teh current working directory.

SetFileDateTime(Filename: string; year, month, day, hour, minute, second: int)

Sets the file date and time.

Split(FileName: String; SplitToBytes: int)

Splits the given file into many files. Split files can only be merged back together with the Merge method.