🟩 File System operations { exists, copy, delete } for { files and directories }
FileSystem executed executing operations on files and directories.
Path is able to parse and manipulate windows and posix paths.
SC::Path | Represents a posix or windows file system path. |
---|---|
SC::Path::join | Joins multiple StringView with a Separator into an output String. |
SC::Path::parseNameExtension | Splits a StringView of type "name.ext" into "name" and "ext". |
SC::Path::parse | Splits a Posix or Windows path into a ParsedView. |
SC::Path::dirname | Returns the directory name of a path. |
SC::Path::basename | Returns the base name of a path. |
SC::Path::isAbsolute | Checks if a path is absolute. |
SC::Path::normalize | Resolves all .. to output a normalized path String. |
SC::Path::relativeFromTo | Get relative path that appended to source resolves to destination . |
SC::Path::append | Append to an existing path a series of StringView with a separator. |
SC::Path::endsWithSeparator | Check if the path ends with a Windows or Posix separator. |
SC::Path::removeStartingSeparator | Return a path without its (potential) starting separator. |
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::removeEmptyDirectoryRecursive | Removes an empty directory that only contains other empty directories (but no files) |
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. |
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::FileSystemDirectories | Reports location of system directories (executable / application root) |
🟩 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::Path class allows parsing and manipulating windows and posix paths.
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).
Checks if a path is absolute. For example:
[in] | input | The StringView with path to be parsed. Trailing separators are ignored. |
[in] | type | Specify to parse as Windows or Posix path |
true
if input
is absoluteReturns the directory name of a path. Trailing separators are ignored.
For example:
[in] | input | The StringView with path to be parsed. Trailing separators are ignored. |
[in] | type | Specify to parse as Windows or Posix path |
repeat | how many directory levels should be removed dirname("/1/2/3/4", repeat=1) == "/1/2" |
input
holding the directory nameReturns the base name of a path. Trailing separators are ignored.
For example:
[in] | input | The StringView with path to be parsed. Trailing separators are ignored. |
[in] | type | Specify to parse as Windows or Posix path |
input
holding the base nameSplits a StringView of type "name.ext" into "name" and "ext".
[in] | input | An input path coded as UTF8 sequence (ex. "name.ext") |
[out] | name | Output string holding name ("name" in "name.ext") |
[out] | extension | Output string holding extension ("ext" in "name.ext") |
false
if both name and extension will be empty after trying to parse themExample:
Resolves all ..
to output a normalized path String. For example:
view | The path to be normalized (but it should not be a view() of the output String) | |
components | The parsed components that once joined will provide the normalized string | |
[out] | output | (Optional) pointer to String that will receive the normalized Path (if nullptr ) |
[in] | type | Specify to parse as Windows or Posix path |
true
if the Path was successfully parsed and normalizedGet relative path that appended to source
resolves to destination
. For example:
[in] | source | The source Path |
[in] | destination | The destination Path |
[out] | output | The output relative path computed that transforms source into destination |
[in] | type | Specify to parse as Windows or Posix path |
[in] | outputType | Specify if the output relative path should be formatted as a Posix or Windows path |
true
if source and destination paths can be properly parsed as absolute pathsCopy 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 pathWrites 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:
Reads contents of a file into a SC::Vector buffer.
file | Path to the file to read | |
[out] | data | Destination buffer that will receive data |
🟦 Complete Features:
stat
fstat
rename
chmod
chown
fsync
link
(hardlink)symlink
sendfile
💡 Unplanned Features: There are many fs operations tat can be added
fchmod
fchown
lchown
access
ftruncate
lstat
statfs
fdatasync
ftruncate
readlink