Skip to content

Reference

Constructor Functions

Functions to create Directory and File objects.

FunctionDescription
dir(path)Create a directory object from a filesytem path
bin()Create a directory object for the parent of the executing script
cwd()Create a directory object for the current working directory
file(path)Create a file object from a filesystem path

Directory Methods

MethodDescription
file(name)Return a file object for a file in the directory
dir(name)Return a directory object for a sub-directory of the directory
parent()Return a directory object for the parent directory
up(n)Return a directory object for a parent n levels up
path()Return the filesystem path for the directory
exists()Determine if the directory exists
mustExist(options)Assert that the directory exists and optionally create it
isEmpty()Determine if the directory is empty
notEmpty()Determine if the directory is not empty
mkdir(options)Create the directory
create()Create the directory and any intermediate directories
rmdir(options)Delete the directory
destroy()Delete the directory and anything it contains
empty(options)Delete any files or sub-directories in the directory
read()Read the contents of the directory
entries()Return file/directory objects for the contents of the directory
files()Return file objects for each file in the directory
directories()Return directory objects for each sub-directory of the directory

File Methods

MethodDescription
read(options)Read the contents of the file
write(data, options)Write the data to the file
delete(options)Delete the file
directory()Return a directory object for the parent directory
dir()Alias for directory()
copyTo(destination, options)Copy the file to a new location
copyFrom(source, options)Copy the file from another location
moveTo(destination, options)Move the file to a new location
moveFrom(source, options)Move the file from another location

Path Methods

MethodDescription
path(name)Return the current path or a relative path
type()Return the type of object: file or directory
parse()Parse the path to extract filename, extension, etc.
unparse()Delete the cached parse data
dirname()Return the directory name
base()Return the complete file or directory name
name()Return the file or directory name without any extension
ext()Return the file extension
relativePath(name)Return a path relative to the current one
exists()Determine if the file or directory exists
stat()Fetch the stat data for the filesystem entry
unstat()Delete any cached stat data
isFile()Determine (from the filesystem) if this is a file
isDirectory()Determine (from the filesystem) if this is a directory
mode()Return the file mode
size()Return the size in bytes
accessed()Return the last accessed time
modified()Return the modified time
changed()Return the changed time
created()Return the created time