FileUtil unit
Miscellaneous routines, types, and classes for manipulating files, file names, and paths.
fileutils.pas contains routines, types, and classes used to
maintain compatibility with the FileUtil unit in Delphi. File routines that
deal with UTF-8 file names are located in the
LazFileUtils unit.
File name handling in the unit is platform- or OS-specific. For the Windows, Darwin (macOS), and Amiga platforms, file names are NOT case sensitive. In addition, under Darwin, the NotLiteralFilenames define is enabled. This indicates that file names cannot be compared using the = string operator.
This unit contains basic functions similar to those in the RTL, but use UTF-8 instead of the default system encoding. Please note that AnsiToUTF8 and UTF8ToAnsi need a widestring manager under Linux, BSD, and macOS. Normally these operating systems use UTF-8 as the system encoding so the WideStringManager is not needed.
fileutil.pas is part of the
LazUtils package.
Classes and records
TFileIterator | class | Implements an iterator for file and directory names on the local file system. |
TFileSearcher | class | Implements an iterator used to search for files or directories. |
TListDirectoriesSearcher | class | Stores directory names matching a given search criteria in a TStrings class instance. |
TListFileSearcher | class | Stores file names matching a search criteria in a TStrings class instance. |
Procedures and functions
CompareFilenames | function | Compares two file names to see whether they are equal. |
ComparePhysicalFilenames | function | Compares file names after resolving symbolic links. |
CopyDirTree | function | Copies all file system entries in a source directory to the destination directory using the specified options. |
CopyFile | function | Copies the source file to the destination file using the specified options. |
DeleteDirectory | function | Deletes the specified directory (or only its contents when OnlyChildren is True). |
ExpandUNCFileNameUTF8 | function | Expands the specified UTF-8-encoded UNC file name to an absolute UNC file name. |
ExtractShortPathNameUTF8 | function | Gets a short path name using the 8.3 notation from the UTF-8-encoded value. |
FileIsInDirectory | function | Checks whether the specified file name shares the path specified in Directory. |
FileIsInPath | function | Checks whether the specified file name shares the path specified in Path. |
FilenameHasPascalExt | function | Indicates whether the specified file name uses a recognized Pascal file extension. |
FileSize | function | Gets the size for the specified file name. |
FindAllDirectories | function | Stores directory names matching the search criteria in a TStringList class instance. |
FindAllFiles | function | Returns the list of files in the specified path matching the search criteria. |
FindDefaultExecutablePath | function | Finds the default path to the named Executable file. |
FindDiskFileCaseInsensitive | function | FindDiskFileCaseInsensitive - searches for the given FileName in a case insensitive manner. |
FindDiskFilename | function | Finds the file name that most closely matches the specified file name. |
GetAllFilesMask | function | Gets the file mask representing all files in a file filter. |
GetExeExt | function | Returns the file extension (including the starting .) for an executable file on the platform. |
ProgramDirectory | function | Gets the directory where the current program is located. |
ProgramDirectoryWithBundle | function | Gets the directory for the current executable without the macOS bundle post-fix. |
ReadFileToBytes | function | Returns a TBytes value with the contents of the specified file. |
ReadFileToString | function | Returns a string with the contents of the specified file. |
SearchAllFilesInPath | function | SearchAllFilesInPath - searches for all files named Filename in the given SearchPath using the supplied BasePath with the specified Delimiter and the options listed in Flags. |
SearchFileInPath | function | Searches for a file name in a given path using the specified base path and options. |
Types
TCopyFileFlag | enumeration | Contains flags used to control actions performed in CopyFile or CopyDirTree. |
TCopyFileFlags | set | Set type used to store TCopyFileFlag enumeration values. |
TDirectoryEnterEvent | procedure type | Specifies an event handler signalled when a new directory is processed with the specified iterator. |
TDirectoryFoundEvent | procedure type | Specifies an event handler signalled when a directory is found for the specified iterator. |
TFileFoundEvent | procedure type | Specifies an event handler signalled when a file name is found for the specified iterator. |
TQueryDirectoryFoundEvent | procedure type | Specifies an event handler signalled when a directory name matching a search criteria is found in TFileSearcher. |
TQueryFileFoundEvent | procedure type | Specifies an event handler signalled when a file name matching a search criteria is found in TFileSearcher. |
TSearchFileInPathFlag | enumeration | Flags used to control options used when searching for file(s) in a given path. |
TSearchFileInPathFlags | set | Set type used to store values from the TSearchFileInPathFlag enumeration. |
Constants
AllDirectoryEntriesMask | constant | File mask used to match all directories entries on the local file system. |
FilenamesCaseSensitive | constant | When True, uppercase and lowercase file names are equivalent. |
FilenamesLiteral | constant | When True, file names can be compared using the = string operator. |
PascalFileExt | constant | File extensions used for Pascal source code files. |
PascalSourceExt | constant | File extensions considered to be a Pascal source, project or package file. |
sffFindProgramInPath | constant | Search flags used to find a program file in a path on the current platform. |
UTF8FileHeader | constant | Byte Order Mark (BOM) used at the beginning of UTF-8-encoded files. |
Uses
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
