Dir¶
| Spice | |
|---|---|
Functions¶
mkDir¶
| Spice | |
|---|---|
Creates an empty directory at the specified path, with the specified mode. Creates at max one directory. If the second last path element does not exist, the operation fails
There are predefined constants for the mode available:
MODE_ALL_RWX, MODE_ALL_RW, MODE_ALL_R,
MODE_OWNER_RWX, MODE_OWNER_R, MODE_OWNER_W, MODE_OWNER_X,
MODE_GROUP_RWX, MODE_GROUP_R, MODE_GROUP_W, MODE_GROUP_X,
MODE_OTHER_RWX, MODE_OTHER_R, MODE_OTHER_W, MODE_OTHER_X
Parameters
| Name | Type | Description |
|---|---|---|
path |
string |
|
mode |
int |
Returns: int — Result code of the create operation: 0 = successful, -1 = failed
rmDir¶
| Spice | |
|---|---|
Deletes an empty directory at the specified path.
Parameters
| Name | Type | Description |
|---|---|---|
path |
string |
Returns: int — Result code of the delete operation: 0 = successful, -1 = failed
renameDir¶
| Spice | |
|---|---|
Renames a directory.
Parameters
| Name | Type | Description |
|---|---|---|
oldPath |
string |
|
newPath |
string |
Returns: int — Result code of the rename operation: 0 = successful, -1 = failed
dirExists¶
| Spice | |
|---|---|
Checks if a directory is existing.
Parameters
| Name | Type | Description |
|---|---|---|
path |
string |
Returns: bool — Existing or not
mkDirs¶
| Spice | |
|---|---|
Creates an empty directory at the specified path, with the specified mode. Unlike mkDir, mkDirs can also create nested path structures: any missing parent directories are created along the way, in order. Directories that already exist anywhere along the path (including the target itself) are left as is.
There are predefined constants for the mode available:
MODE_ALL_RWX, MODE_ALL_RW, MODE_ALL_R,
MODE_OWNER_RWX, MODE_OWNER_R, MODE_OWNER_W, MODE_OWNER_X,
MODE_GROUP_RWX, MODE_GROUP_R, MODE_GROUP_W, MODE_GROUP_X,
MODE_OTHER_RWX, MODE_OTHER_R, MODE_OTHER_W, MODE_OTHER_X
Parameters
| Name | Type | Description |
|---|---|---|
path |
string |
|
mode |
int |
Returns: int — Result code of the create operation: 0 = successful, -1 = failed
listDir¶
| Spice | |
|---|---|
Lists the names of all files and subdirectories directly inside the given directory. The entries '.' and '..' are left out. The names are listed in the order, in which the operating system reports them.
Parameters
| Name | Type | Description |
|---|---|---|
path |
string |
Path to the directory |
Returns: Result<Vector<String>> — Names of the entries, or an error if the directory could not be opened
listDirRecursive¶
| Spice | |
|---|---|
Lists all files and subdirectories inside the given directory and, recursively, inside its subdirectories. Each entry is reported as a path relative to the given directory, with '/' as separator. A directory is listed before its contents. Symbolic links to directories are listed, but not descended into. Subdirectories, that cannot be opened (e.g. due to missing permissions) are listed, but their contents are left out.
Parameters
| Name | Type | Description |
|---|---|---|
path |
string |
Path to the directory |
Returns: Result<Vector<String>> — Relative paths of the entries, or an error if the directory could not be opened