This document describes the filesystem-related commands used in the provided Lua code snippets within the Control environment.
Overview
The PIXERA API exposes filesystem functionality via:
pixc.getRoot().Utils.FilesystemAll filesystem operations must be accessed through this path.
Common Workflow Pattern
Both scripts follow a consistent pattern when working with files or folders:
- Retrieve a path from properties
- Validate the input
- Check existence
- Validate type (file or directory)
- Perform filesystem operation
- Log output
Helper Usage
self.helper:getProperty(propertyName)
Retrieves a property value defined in the action.
-
Parameters:
-
propertyName(string): Name of the property (e.g., "Folder", "File")
-
- Returns: string (path)
Read more: Property Builder
Filesystem Commands
1. exists(path)
Checks whether a given path exists.
- Returns: boolean
2. isDir(path)
Checks whether the path is a directory.
- Returns: boolean
3. isFile(path)
Checks whether the path is a file.
- Returns: boolean
4. ls(path)
Lists the contents of a directory.
- Returns: table
5. list(path)
Alias for ls.
- Returns: table
6. cat(path)
Reads the contents of a file.
- Returns: string or table
7. readAllText(path)
Alias for cat.
- Returns: string or table
8. rm(path)
Deletes a file or an empty directory.
- Returns: boolean (implementation dependent)
-
Notes:
- Directory must be empty
9. remove(path)
Alias for rm.
10. writeAllText(path, content)
Writes text content to a file.
-
Parameters:
-
path(string) -
content(string)
-
-
Notes:
- Overwrites existing file
- File will not be attached automatically in PIXERA
11. mkdir(path)
Creates a new directory.
- Returns: boolean (implementation dependent)
Example Code
This is a code snippet used to get a file path from the properties of a Module, open the selected file, and read its content.
-- as of now with 26.2 inter 43 Options Actions are not supported with type File and Folder,
-- therefore only getProperties can be used.
if self.helper == nil then
require "pixcHelper"
self.helper = createPixcHelper(pixc,self())
end
-- load path as sting
local filePath = self.helper:getProperty("File")
-- check if there is something selected
if filePath == nil or filePath == "" then
pixc.log(currentActionFullName .. " No file selected in Properties")
return -- leave ation if nothing selected
end
-- check if it exists
if not pixc.getRoot().Utils.Filesystem.exists(filePath) then
pixc.log(currentActionFullName .. " Selected File path does not exist")
return
end
-- check if it is a file
if not pixc.getRoot().Utils.Filesystem.isFile(filePath) then
pixc.log(currentActionFullName .. " Selected File path is not a File ".. filePath)
return
end
-- this needs to use pixc.getRoot() in order to use the Filesystem commands
-- cat is to return the content of a file
local fileContent = pixc.getRoot().Utils.Filesystem.cat(filePath)
-- logdump is used to pretty print the returned table.
pixc.log(self.helper.dump(fileContent))
You can view this example directly in Control, in the PropertiesExample module
PIXERA 26.2 Inter 43 | 25. March 2026 | J.B.
