Namespaces
fs
Methods
is_empty
Returns true if the provided file or directory is empty
function fs.is_empty(path: string): bool
-- example usage
local empty = fs.is_empty(--[[path]])
is_directory
Returns true if the provided path is a directory
function fs.is_directory(path: string): bool
-- example usage
local directory = fs.is_directory(--[[path]])
is_regular_file
Returns true if the provided path is a regular file
function fs.is_regular_file(path: string): bool
-- example usage
local regular_file = fs.is_regular_file(--[[path]])
get_workspace_path
Returns a path the script may use for any dynamic content
function fs.get_workspace_path(): string
-- example usage
local workspace_path = fs.get_workspace_path() -- example: "C:\\Users\\Default\\AppData\\Roaming\\Exodus Client\\Library\\Red Dead Redemption 2\\Client\\Scripting\\Workspace"
get_assets_path
Returns a path the script may use for any static content
function fs.get_assets_path(): string
-- example usage
local assets_path = fs.get_assets_path() -- example: "C:\\Users\\Default\\AppData\\Roaming\\Exodus Client\\Library\\Red Dead Redemption 2\\Client\\Scripting\\Assets"
get_extension
Returns the extension of a provided path
function fs.get_extension(path: string): string
-- example usage
local extension = fs.get_extension(--[[path]])
get_filename
Returns the filename of a provided path
function fs.get_filename(path: string): string
-- example usage
local filename = fs.get_filename(--[[path]])
create_directory
Creates a single directory using the provided path
function fs.create_directory(path: string): void
-- example usage
fs.create_directory(fs.get_workspace_path() .. "\\Dir") -- create a single directory in workspace
create_directories
Creates multiple directories using the provided path
function fs.create_directories(path: string): void
-- example usage
fs.create_directories(fs.get_workspace_path() .. "\\Dir\\Dir") -- create multiple directories in workspace
list_directory
Returns an array of all regular files and directories in a provided path,
recursive will also search all subdirectoriesfunction fs.list_directory(path: string, recursive: bool): string[]
-- example usage
for i, path in ipairs(fs.list_directory(fs.get_workspace_path(), true)) do
if fs.is_directory(path) then
if fs.is_empty(path) then
log.info("Empty Dir: " .. path)
else
log.info("Dir: " .. path)
end
end
end
file_size
Returns the size of the provided file
function fs.file_size(path: string): int
-- example usage
local size = fs.file_size(--[[path]])
exists
Returns true if the provided file or directory exists
function fs.exists(path: string): bool
-- example usage
local exists = fs.exists(--[[path]])