The paths
module
The paths
module provides utilities for working with file and directory paths. It also provides functions for reading and writing files.
Fields
separator: string
The path separator for the current platform. This is either /
or \
.
Free functions
absolute(path: string): string
Returns the absolute path of the given path.
fileName(path: string): string
Returns the filename of the given path.
copy(from: string, to: string): null
Copies the file at the given path from
to the given path to
.
createDir(path: string): string
Creates a directory at the given path and returns the path of the created directory.
createDirs(path: string): string
Creates a directory at the given path and all parent directories that do not exist yet. Returns the path of the created directory.
delete(path: string): null
Deletes the file or directory at the given path. Directories must be empty.
deleteRecursive(path: string): null
Deletes the file or directory at the given path recursively.
exists(path: string): boolean
Returns a boolean value indicating whether the file or directory at the given path exists.
isAbsolute(path: string): boolean
Returns a boolean value indicating whether the given path is absolute.
isDir(path: string): boolean
Returns a boolean value indicating whether the given path points to a directory.
isFile(path: string): boolean
Returns a boolean value indicating whether the given path points to a file.
isHidden(path: string): boolean
Returns a boolean value indicating whether the given path is hidden.
isSymlink(path: string): boolean
Returns a boolean value indicating whether the given path is a symbolic link.
listDir(path: string): list[string]
Returns a list of the files and directories in the given directory.
move(from: string, to: string): null
Moves the file at the given path from
to the given path to
.
normalize(path: string): string
Normalizes the given path and returns the normalized path as a string.
openRead(path: string): native
Opens the file at the given path for reading and returns an input stream.
openWrite(path: string): native
Opens the file at the given path for writing and returns an output stream.
parent(path: string): string
Returns the parent directory of the given path.
readAll(path: string): bytes
Reads the entire file at the given path and returns the contents as a byte array.
readText(path: string): string
Reads the entire file at the given path and returns the contents as a string.
resolve(base: string, other: string): string
Resolves the given path other
against the base path base
and returns the resolved path as a string.
root(path: string): string
Returns the root of the given path.
writeAll(path: string, data: bytes)
Writes the given byte array to the file at the given path.
writeText(path: string, data: string)
Writes the given string to the file at the given path.