The API.FILESYSTEM class provides a set of interfaces for managing the file system on the controller. It includes methods for retrieving file and directory contents, creating, updating, and deleting files or directories, and checking file existence. This class simplifies file system operations, enabling developers to efficiently interact with and manage files on the controller.
- Source
Methods
copy(source, destination, overwrite)
Recursively copies a file or directory (including all subdirectories and files).
| Name | Type | Description |
|---|---|---|
source | string | Source path |
destination | string | Destination path |
overwrite | boolean | Overwrites the directory or file if it already exists in the destination path. |
- Source
await API.FILESYSTEM.copy("$HOME/EIO.cfg","$HOME/WebApps/EIO.cfg")createDirectory(directoryPath)
Creates a new directory.
| Name | Type | Description |
|---|---|---|
directoryPath | string | The directory path |
- Source
await API.FILESYSTEM.createDirectory("$HOME/testFolder")createNewFile(directoryPath, fileName, data, overwrite)
Create a new file
| Name | Type | Description |
|---|---|---|
directoryPath | string | directory path |
fileName | string | file name |
data | string | data content |
overwrite | boolean | Overwrite if the file already exists |
- Source
await API.FILESYSTEM.createNewFile("$HOME", "test.txt", "test new", true)deleteDirectory(directoryPath)
Delete directory
| Name | Type | Description |
|---|---|---|
directoryPath | string | directory path |
- Source
await API.FILESYSTEM.deleteDirectory("$HOME/testFolder")deleteDirectoryContent(directoryPath)
Delete all directories and files in a directory
| Name | Type | Description |
|---|---|---|
directoryPath | string | directory path |
- Source
await API.FILESYSTEM.deleteDirectoryContent("$HOME/testFolder")deleteFile(directoryPath, fileName)
Delete file
| Name | Type | Description |
|---|---|---|
directoryPath | string | directory path |
fileName | string | file name |
- Source
await API.FILESYSTEM.deleteFile("$HOME", "test.txt")fileExists(directoryPath, fileName) → {Promise.<boolean>}
Detect if the file already exists
| Name | Type | Description |
|---|---|---|
directoryPath | string | directory path |
fileName | string | file name |
- Source
- true if the file exists, false otherwise
- Type:
- Promise.<boolean>
const fileExists = await API.FILESYSTEM.fileExists("$HOME", "test.txt")getDirectoryContents(path)
Gets the content of a directory with specified path
| Name | Type | Description |
|---|---|---|
path | string | Path to the file, including file name |
- Source
// Get the content of the TEMP directory of controller
await API.FILESYSTEM.getDirectoryContents("$TEMP")getFile(path, file)
Get the content of a file with specified path
| Name | Type | Description |
|---|---|---|
path | string | Path to the file, optional - including file name |
file | string | Name of the file |
- Source
// Get the file content of the file EIO.cfg in Home directory
await API.FILESYSTEM.getFile("$HOME","EIO.cfg")getFiles(path) → {Promise.<Array.<object>>}
Get a list of files objects including name and content
| Name | Type | Description |
|---|---|---|
path | string | Path to the file, including file name |
- Source
- Array of file objects [ {name, content}]
- Type:
- Promise.<Array.<object>>
await API.FILESYSTEM.getFiles("$HOME")updateFile(directoryPath, fileName, data) → {Promise.<Array.<object>>}
Update the file content
| Name | Type | Description |
|---|---|---|
directoryPath | string | directory path |
fileName | string | fileName |
data | string | content to be updated |
- Source
- Array of file objects [ {name, content}]
- Type:
- Promise.<Array.<object>>
await API.FILESYSTEM.updateFile("$HOME","test.txt","testcontent")