C_FileSystem
Usability-focused abstraction of the underlying file system APIs
Status
Experimental: Functionality may change for any reason, without semantic versioning guarantees
Availability
This is a global namespace and can be accessed directly:
C_FileSystem.MakeDirectory("test")
Functions
AppendFile
This operation is synchronous; it will prevent the event loop from running while the request is being handled.
Opens the given filePath
in append mode and writes contents
to the end of the file.
Available since: v0.0.1Arguments |
---|
# | Name | Type | Fallback |
---|
| filePath | string | |
| contents | string | |
Return values |
---|
# | Name | Type |
---|
| success | boolean |
Delete
This operation is synchronous; it will prevent the event loop from running while the request is being handled.
Removes the file or directory referenced by the given fileSystemPath
. This operation cannot be undone.
Available since: v0.0.1Arguments |
---|
# | Name | Type | Fallback |
---|
| fileSystemPath | string | |
Return values |
---|
# | Name | Type |
---|
| success | boolean |
Exists
This operation is synchronous; it will prevent the event loop from running while the request is being handled.
Returns true
if the given fileSystemPath
exists (can be accessed in read-only mode), and false
otherwise.
Available since: v0.0.1Arguments |
---|
# | Name | Type | Fallback |
---|
| fileSystemPath | string | |
Return values |
---|
# | Name | Type |
---|
| isReadableFileSystemEntry | boolean |
IsDirectory
This operation is synchronous; it will prevent the event loop from running while the request is being handled.
Returns true
if the given fileSystemPath
refers to a directory
type entry, and false
otherwise.
Available since: v0.0.1Arguments |
---|
# | Name | Type | Fallback |
---|
| fileSystemPath | string | |
Return values |
---|
# | Name | Type |
---|
| isDirectory | boolean |
IsFile
This operation is synchronous; it will prevent the event loop from running while the request is being handled.
Returns true
if the given fileSystemPath
refers to a file
type entry, and false
otherwise.
Available since: v0.0.1Arguments |
---|
# | Name | Type | Fallback |
---|
| fileSystemPath | string | |
Return values |
---|
# | Name | Type |
---|
| isFile | boolean |
MakeDirectory
This operation is synchronous; it will prevent the event loop from running while the request is being handled.
Creates a new directory with the given directoryPath
if one doesn't already exist. Will not create parent directories automatically.
Available since: v0.0.1Arguments |
---|
# | Name | Type | Fallback |
---|
| directoryPath | string | |
Return values |
---|
# | Name | Type |
---|
| success | boolean |
MakeDirectoryTree
This operation is synchronous; it will prevent the event loop from running while the request is being handled.
Creates a new directory with the given directoryPath
if one doesn't already exist. Will create parent directories (recursively) if needed.
Available since: v0.0.3Arguments |
---|
# | Name | Type | Fallback |
---|
| directoryPath | string | |
Return values |
---|
# | Name | Type |
---|
| success | boolean |
ReadDirectory
This operation is synchronous; it will prevent the event loop from running while the request is being handled.
Reads the contents of the given directory, and returns a list of all files found within it. Will process only the root directory.
The isFile
flag is always true
in the current implementation as directories are removed after their contents have been processed.
Available since: v0.0.1Arguments |
---|
# | Name | Type | Fallback |
---|
| directoryPath | string | |
Return values |
---|
# | Name | Type |
---|
| directoryContents | table |
directoryContents |
---|
Keys | Values |
Name | Type | Name | Type |
---|
absoluteFilePath | string | isFile | boolean |
ReadDirectoryTree
This operation is synchronous; it will prevent the event loop from running while the request is being handled.
Reads the contents of the given directory tree (including nested subdirectories), and returns a list of all files found within it.
The isFile
flag is always true
in the current implementation as directories are removed after their contents have been processed.
Available since: v0.0.4Arguments |
---|
# | Name | Type | Fallback |
---|
| directoryPath | string | |
Return values |
---|
# | Name | Type |
---|
| directoryContents | table |
directoryContents |
---|
Keys | Values |
Name | Type | Name | Type |
---|
absoluteFilePath | string | isFile | boolean |
ReadFile
This operation is synchronous; it will prevent the event loop from running while the request is being handled.
Opens the given filePath
in read-only mode and returns the file contents as a Lua string.
Available since: v0.0.1Arguments |
---|
# | Name | Type | Fallback |
---|
| filePath | string | |
Return values |
---|
# | Name | Type |
---|
| fileContents | string |
WriteFile
This operation is synchronous; it will prevent the event loop from running while the request is being handled.
Opens the given filePath
in write mode and writes contents
to the file. Overwrites the file if it already exists.
Available since: v0.0.1Arguments |
---|
# | Name | Type | Fallback |
---|
| filePath | string | |
| contents | string | |
Return values |
---|
# | Name | Type |
---|
| success | boolean |
Changelog
Version | What happened? |
---|
v0.0.4 | Added ReadDirectoryTree |
v0.0.3 | Added MakeDirectoryTree |
v0.0.1 | Initial release |