🟩 File System operations { exists, copy, delete } for { files and directories }
FileSystem executed executing operations on files and directories.
SC::FileSystem | Execute fs operations { exists, copy, delete } for { files and directories }. |
---|---|
Copy Files | |
SC::FileSystem::copyFile | Copy a single file. |
Delete Files | |
SC::FileSystem::removeFile | Remove a single file. |
SC::FileSystem::removeFileIfExists | Remove a single file, giving no error if it doesn't exist. |
Copy Directories | |
SC::FileSystem::copyDirectory | Copy a single directory. |
Delete Directories | |
SC::FileSystem::removeEmptyDirectory | Removes an empty directory. |
SC::FileSystem::removeDirectoryRecursive | Remove single directory with its entire content (like posix rm -rf ) |
Create Directories | |
SC::FileSystem::makeDirectory | Creates a new directory that does not already exist. |
SC::FileSystem::makeDirectoryIfNotExists | Creates a new directory, if it doesn't already exists at the given path. |
SC::FileSystem::makeDirectoryRecursive | Create a new directory, creating also intermediate non existing directories (like posix mkdir -p ) |
Check Existence | |
SC::FileSystem::exists | Check if a file or directory exists at a given path. |
SC::FileSystem::existsAndIsFile | Check if a file exists at given path. |
SC::FileSystem::existsAndIsDirectory | Check if a directory exists at given path. |
Rename files or directories | |
SC::FileSystem::rename | Rename a file or directory. |
Read / Change modification time | |
SC::FileSystem::getFileStat | Obtains stats (size, modified time) about a file. |
SC::FileSystem::setLastModifiedTime | Change last modified time of a given file. |
Miscellaneous Classes | |
---|---|
SC::FileSystem::Operations | Low level filesystem API, requiring paths in native encoding (UTF-16 on Windows, UTF-8 elsewhere) |
Get Executable / Application Path | |
SC::FileSystem::Operations::getExecutablePath | |
SC::FileSystem::Operations::getApplicationRootDirectory |
🟩 Usable
The library contains commonly used function but it's missing some notable ones like stat
. SC::FileSystem::getFileTime and SC::FileSystem::setLastModifiedTime will probably be refactored in a future dedicated class for handling stat
based operations.
SC::FileSystem allows all typical file operations ( exists | copy | delete | make files or directory). Some less used functions are SC::FileSystem::getFileTime and SC::FileSystem::setLastModifiedTime . The library doesn't allow reading or writing seeking inside a file, as that is domain of the File library. SC::FileSystem::init needs an absolute path to a directory and makes it a the base directory. All paths passed later on as arguments to all methods can be either absolute paths or relative. If they are relative, they will be interpreted as relative to the base directory and NOT current directory of the process. The class wants explicitly to make sure its behavior doesn't implicitly depend on current directory of process (unless it's passed explicitly to SC::FileSystem::init of course).
Use SC::Path from Strings library to parse and compose paths.
Copy a single file.
source | Source file path |
destination | Destination file path |
copyFlags | Copy flags (overwrite, use clone api etc.) |
Example:
Copy a single directory.
source | Source directory path |
destination | Destination directory path |
copyFlags | Copy flags (overwrite, use clone api etc.) |
Example:
Remove single directory with its entire content (like posix rm -rf
)
directory | Directory to remove |
Example:
Create a new directory, creating also intermediate non existing directories (like posix mkdir -p
)
directory | Path where to create such directory |
Check if a file exists at given path.
file | File path to check |
true
if a file exists at the given pathExample:
Check if a directory exists at given path.
directory | Directory path to check |
true
if a directory exists at the given path Rename a file or directory.
path | The path to the file or directory to rename |
newPath | The new path to the file or directory |
Example:
Writes a block of memory to a file.
file | Path to the file that is meant to be written |
data | Block of memory to write |
Example:
Read contents of a file into a String or Buffer.
[in] | file | Path to the file to read |
[out] | data | Destination String or Buffer that will receive file contents |
🟦 Complete Features:
access
chmod
chown
fchmod
fchown
fdatasync
fstat
fsync
ftruncate
ftruncate
lchown
link
(hardlink)lstat
readlink
sendfile
stat
statfs