![]() |
Cyclone 3DR Script
from Technodigit, part of Hexagon. Copyright 1997-2025.
|
Provide an interface for reading from and writing to files on disk. More...
Public Types | |
| enum | EntriesType { Files = 1 , Directories = 2 } |
| Type of entries. More... | |
| enum | OpenModeEnum { ReadOnly = 1 , WriteOnly = 2 , ReadWrite = 3 , Append = 4 , Truncate = 8 } |
| The opening modes. More... | |
Public Member Functions | |
| boolean | AtEnd () |
| Return if the current read and write position is at the end of the file (i.e. there is no more data available for reading on the file). | |
| Close () | |
| Close the file. | |
| boolean | Exists () |
| Check if the file exists. | |
| string | FileName () |
| Get the path of the SFile. | |
| boolean | IsOpen () |
| Return if the file is open or not. A file is open if it can be read from and/or written to. | |
| boolean | Open (OpenModeEnum openMode) |
| Open the existing file (The file is always open in text mode). | |
| string | ReadAll () |
| Read all available data from the file. | |
| string | ReadLine () |
| Read a line from the file. | |
| boolean | Remove () |
| Remove the file specified by the FileName(). | |
| boolean | Rename (string newName) |
| Rename the file currently specified by FileName() with the given name. | |
| SFile (string name) | |
| Construct a new file object to represent the file with the given name. | |
| string | toString () |
| Get the type of the variable. | |
| boolean | Write (string toWrite) |
| Write the content of a string to the file. | |
Static Public Member Functions | |
| static string | GetDirectory (string path) |
| Get the parent directory of a given path. | |
| static string | GetFileExtension (string path) |
| Get the file extension of a given file. | |
| static string | GetFileName (string path, boolean withExtension=true) |
| Get the file name of a given file path. | |
| static Object | ListEntries (string dirPath, EntriesType entriesType, boolean recursive=false, Array< string > extensionFilter=[]) |
| List all entries in a given directory. | |
| static SFile | New (string name) |
| Construct a new file object to represent the file with the given name. | |
| static boolean | Remove (string fileName) |
| Remove the file specified by the fileName given. | |
Provide an interface for reading from and writing to files on disk.
| enum SFile::EntriesType |
| enum SFile::OpenModeEnum |
The opening modes.
| SFile::SFile | ( | string | name | ) |
Construct a new file object to represent the file with the given name.
| name | (string) The name of the file. |
| boolean SFile::AtEnd | ( | ) |
Return if the current read and write position is at the end of the file (i.e. there is no more data available for reading on the file).
| boolean SFile::Exists | ( | ) |
Check if the file exists.
| string SFile::FileName | ( | ) |
|
static |
Get the parent directory of a given path.
If the given path corresponds to a directory, the parent directory is still returned.
The path is not checked for existence.
Only forward slashes are used in the returned path.
| path | (string) The path to analyse. |
|
static |
Get the file extension of a given file.
If the given path corresponds to a directory, empty is returned.
The path is not checked for existence.
| path | (string) The path to analyse. |
|
static |
Get the file name of a given file path.
If the given path corresponds to a directory, the directory name is returned.
The path is not checked for existence.
| path | (string) The path to analyse. |
| withExtension | (boolean) If true, the returned file name includes the extension if any. If false, the extension is removed. |
| boolean SFile::IsOpen | ( | ) |
Return if the file is open or not. A file is open if it can be read from and/or written to.
|
static |
List all entries in a given directory.
Entries ordering has no guarantee to be consistent.
| dirPath | (string) The path of the directory to explore. |
| entriesType | (EntriesType) The type of entries to list (files and/or directories).
|
| recursive | (boolean) If true, all sub-directories will be explored recursively. Don't use for large directory trees as it may take a long time or too much memory. Prefer implementing your own recursive logic using this function. |
| extensionFilter | (Array<string>) An array of extension filters to apply. If empty, all files are listed. This filter only applies to file entries. You can include the leading dot in the extensions or not. |
| ret.ErrorCode | (number) Error code
|
| ret.Entries | (Array<string>) The list of absolute paths to the entries. |
|
static |
| boolean SFile::Open | ( | OpenModeEnum | openMode | ) |
Open the existing file (The file is always open in text mode).
| openMode | (OpenModeEnum) The opening mode to use.
|
| string SFile::ReadAll | ( | ) |
Read all available data from the file.
| string SFile::ReadLine | ( | ) |
Read a line from the file.
| boolean SFile::Remove | ( | ) |
Remove the file specified by the FileName().
|
static |
Remove the file specified by the fileName given.
| fileName | (string) The name of the file to remove. |
| boolean SFile::Rename | ( | string | newName | ) |
Rename the file currently specified by FileName() with the given name.
| newName | (string) The new name of the file. |
| string SFile::toString | ( | ) |
Get the type of the variable.
| boolean SFile::Write | ( | string | toWrite | ) |
Write the content of a string to the file.
| toWrite | (string) The string to write in the file |