Skip to content

Dir

Spice
import "std/io/dir";

Functions

mkDir

Spice
public f<int> mkDir(string path, int mode)

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

mkDirs

Spice
public f<int> mkDirs(string path, int mode)

Creates an empty directory at the specified path, with the specified mode. Unlike mkDir, mkDirs can also create nested path structures.

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
public f<int> rmDir(string path)

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
public f<int> renameDir(string oldPath, string newPath)

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
public f<bool> dirExists(string path)

Checks if a directory is existing.

Parameters

Name Type Description
path string

Returns: bool — Existing or not

listDir

Spice
public p listDir(string path)

Lists all files/subdirectories at a given path.

Parameters

Name Type Description
path string

listDirRecursive

Spice
public p listDirRecursive(string path)

Lists all files/subdirectories at a given path recursively.

Parameters

Name Type Description
path string