Skip to main content

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") -- Implicit global lookup: _G.C_FileSystem

Functions

AppendFile

Blocking API
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.1
Arguments
#NameTypeFallback
filePathstring
contentsstring
Return values
#NameType
successboolean

Delete

Blocking API
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.1
Arguments
#NameTypeFallback
fileSystemPathstring
Return values
#NameType
successboolean

Exists

Blocking API
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.1
Arguments
#NameTypeFallback
fileSystemPathstring
Return values
#NameType
isReadableFileSystemEntryboolean

IsDirectory

Blocking API
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.1
Arguments
#NameTypeFallback
fileSystemPathstring
Return values
#NameType
isDirectoryboolean

IsFile

Blocking API
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.1
Arguments
#NameTypeFallback
fileSystemPathstring
Return values
#NameType
isFileboolean

MakeDirectory

Blocking API
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.1
Arguments
#NameTypeFallback
directoryPathstring
Return values
#NameType
successboolean

MakeDirectoryTree

Blocking API
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.3
Arguments
#NameTypeFallback
directoryPathstring
Return values
#NameType
successboolean

ReadDirectory

Blocking API
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.1
Arguments
#NameTypeFallback
directoryPathstring
Return values
#NameType
directoryContentstable
directoryContents
KeysValues
NameTypeNameType
absoluteFilePathstringisFileboolean

ReadDirectoryTree

Blocking API
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.4
Arguments
#NameTypeFallback
directoryPathstring
Return values
#NameType
directoryContentstable
directoryContents
KeysValues
NameTypeNameType
absoluteFilePathstringisFileboolean

ReadFile

Blocking API
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.1
Arguments
#NameTypeFallback
filePathstring
Return values
#NameType
fileContentsstring

WriteFile

Blocking API
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.1
Arguments
#NameTypeFallback
filePathstring
contentsstring
Return values
#NameType
successboolean

Changelog

VersionWhat happened?
v0.0.4Added ReadDirectoryTree
v0.0.3Added MakeDirectoryTree
v0.0.1Initial release