Provides helper functions for manipulating and querying the filesystem. Most functions are static,
so they should be called directly on the cFile class itself:
Name | Parameters | Return value | Notes |
ChangeFileExt |
FileName, NewExt |
string |
(STATIC) Returns FileName with its extension changed to NewExt. NewExt may begin with a dot, but needn't, the result is the same in both cases (the first dot, if present, is ignored). FileName may contain path elements, extension is recognized as the last dot after the last path separator in the string. |
Copy |
SrcFileName, DstFileName |
bool |
(STATIC) Copies a single file to a new destination. Returns true if successful. Fails if the destination already exists. |
CreateFolder |
FolderPath |
bool |
(STATIC) Creates a new folder. Returns true if successful. Only a single level can be created at a time, use CreateFolderRecursive() to create multiple levels of folders at once. |
CreateFolderRecursive |
FolderPath |
bool |
(STATIC) Creates a new folder, creating its parents if needed. Returns true if successful. |
Delete |
Path |
bool |
(STATIC) Deletes the specified file or folder. Returns true if successful. Only deletes folders that are empty. NOTE: If you already know if the object is a file or folder, use DeleteFile() or DeleteFolder() explicitly. |
DeleteFile |
FilePath |
bool |
(STATIC) Deletes the specified file. Returns true if successful. |
DeleteFolder |
FolderPath |
bool |
(STATIC) Deletes the specified file or folder. Returns true if successful. Only deletes folders that are empty. |
DeleteFolderContents |
FolderPath |
bool |
(STATIC) Deletes everything from the specified folder, recursively. The specified folder stays intact. Returns true if successful. |
Exists |
Path |
bool |
(STATIC) Returns true if the specified file or folder exists. OBSOLETE, use IsFile() or IsFolder() instead |
GetExecutableExt |
|
string |
(STATIC) Returns the customary executable extension (including the dot) used by the current platform (".exe" on Windows, empty string on Linux). |
GetFolderContents |
FolderName |
array table of strings |
(STATIC) Returns the contents of the specified folder, as an array table of strings. Each filesystem object is listed. Use the IsFile() and IsFolder() functions to determine the object type. |
GetLastModificationTime |
Path |
number |
(STATIC) Returns the last modification time (in current timezone) of the specified file or folder. Returns zero if file not found / not accessible. The returned value is in the same units as values returned by os.time(). |
GetPathSeparator |
|
string |
(STATIC) Returns the primary path separator used by the current platform. Returns "\" on Windows and "/" on Linux. Note that the platform or CRT may support additional path separators, those are not reported. |
GetSize |
FileName |
number |
(STATIC) Returns the size of the file, or -1 on failure. |
IsFile |
Path |
bool |
(STATIC) Returns true if the specified path points to an existing file. |
IsFolder |
Path |
bool |
(STATIC) Returns true if the specified path points to an existing folder. |
ReadWholeFile |
FileName |
string |
(STATIC) Returns the entire contents of the specified file. Returns an empty string if the file cannot be opened. |
Rename |
OrigPath, NewPath |
bool |
(STATIC) Renames a file or a folder. Returns true if successful. Undefined result if NewPath already exists. |