Classes
Methods
closeFile(handle)
Closes an open file handle.
Parameters:
| Name | Type | Description |
|---|---|---|
handle |
number | The file handle to close. |
- Source:
copyFile(sourcePath, destPath) → {boolean}
Copies a file from a source path to a destination path.
Parameters:
| Name | Type | Description |
|---|---|---|
sourcePath |
string | The path of the file to copy. |
destPath |
string | The destination path for the new file. |
- Source:
Returns:
True on success, false on failure.
- Type
- boolean
deleteDir(path) → {boolean}
Deletes an empty directory.
Parameters:
| Name | Type | Description |
|---|---|---|
path |
string | The path of the directory to delete. |
- Source:
Returns:
True on success, false if the directory is not found or not empty.
- Type
- boolean
deleteFile(path) → {boolean}
Deletes a file.
Parameters:
| Name | Type | Description |
|---|---|---|
path |
string | The path of the file to delete. |
- Source:
Returns:
True on success, false if the file is not found or is currently open.
- Type
- boolean
downloadFile(path, downloadNameopt) → {boolean}
Triggers a browser download for a file stored in the VFS.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
path |
string | The path of the file within the VFS to download. | |
downloadName |
string |
<optional> |
Optional. The name for the downloaded file. Defaults to the file's name in the path. |
- Source:
Returns:
True if the download was initiated, false if the file was not found.
- Type
- boolean
eof(handle) → {boolean}
Checks if the end of an open file has been reached.
Parameters:
| Name | Type | Description |
|---|---|---|
handle |
number | The file handle. |
- Source:
Returns:
True if the file cursor is at or beyond the end of the file.
- Type
- boolean
fileExists(path) → {boolean}
Checks if a file exists at the given path.
Parameters:
| Name | Type | Description |
|---|---|---|
path |
string | The path to check. |
- Source:
Returns:
True if a file exists, false otherwise.
- Type
- boolean
fileSize(path) → {number}
Gets the size of a file in bytes.
Parameters:
| Name | Type | Description |
|---|---|---|
path |
string | The path to the file. |
- Source:
Returns:
The size of the file, or 0 if not found or it's a directory.
- Type
- number
fileType(path) → {number}
Determines the type of a path.
Parameters:
| Name | Type | Description |
|---|---|---|
path |
string | The path to check. |
- Source:
Returns:
0 for not found, 1 for a file, 2 for a directory.
- Type
- number
(async) loadTextFile(path) → {Promise.<(string|null)>}
Asynchronously loads a text file. It first checks the VFS. If not found,
it tries to fetch it from the server and caches it in the VFS for future use.
Parameters:
| Name | Type | Description |
|---|---|---|
path |
string | The path to the text file. |
- Source:
Returns:
A promise that resolves with the file content or null if not found.
- Type
- Promise.<(string|null)>
nextFile(handle) → {string}
Reads the next entry from an open directory handle.
Parameters:
| Name | Type | Description |
|---|---|---|
handle |
number | The directory handle. |
- Source:
Returns:
The name of the next file or directory, or an empty string if no more entries exist.
- Type
- string
openFile(path) → {number}
Opens a file for reading/writing. Creates the file if it doesn't exist.
Parameters:
| Name | Type | Description |
|---|---|---|
path |
string | The path to the file. |
- Source:
Returns:
A file handle, or 0 on failure.
- Type
- number
readDir(path) → {number}
Opens a directory for reading its contents.
Parameters:
| Name | Type | Description |
|---|---|---|
path |
string | The path to the directory. |
- Source:
Returns:
A directory handle, or 0 on failure.
- Type
- number
readFile(handle) → {string}
Reads the next line from an open file.
Parameters:
| Name | Type | Description |
|---|---|---|
handle |
number | The file handle returned by `openFile`. |
- Source:
Returns:
The content of the line, or an empty string if at the end of the file.
- Type
- string
seekFile(handle, pos)
Sets the read/write position for an open file.
Parameters:
| Name | Type | Description |
|---|---|---|
handle |
number | The file handle. |
pos |
number | The new position to seek to. |
- Source:
writeFile(handle, text)
Appends a line of text (with a newline character) to an open file.
Parameters:
| Name | Type | Description |
|---|---|---|
handle |
number | The file handle. |
text |
string | The text to write. |
- Source: