new FileSystem()
A (potential) blocking and non blocking version of each operation is provided.
The non blocking versions take a handler which is called when the operation completes or an error occurs.
- Source:
Methods
-
chmod(path, perms, handler) → {FileSystem}
-
Change the permissions on the file represented by
path
toperms
, asynchronously.The permission String takes the form rwxr-x--- as specified here.
Parameters:
Name Type Description path
string the path to the file perms
string the permissions string handler
function the handler that will be called on completion - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- FileSystem
-
chmodBlocking(path, perms) → {FileSystem}
-
Blocking version of [#chmod(String, String, Handler)] FileSystem
Parameters:
Name Type Description path
string perms
string - Source:
Returns:
- Type
- FileSystem
-
chmodRecursive(path, perms, dirPerms, handler) → {FileSystem}
-
Change the permissions on the file represented by
path
toperms
, asynchronously.The permission String takes the form rwxr-x--- as specified in {here}.
If the file is directory then all contents will also have their permissions changed recursively. Any directory permissions will be set to
dirPerms
, whilst any normal file permissions will be set toperms
.Parameters:
Name Type Description path
string the path to the file perms
string the permissions string dirPerms
string the directory permissions handler
function the handler that will be called on completion - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- FileSystem
-
chmodRecursiveBlocking(path, perms, dirPerms) → {FileSystem}
-
Blocking version of FileSystem#chmodRecursive
Parameters:
Name Type Description path
string perms
string dirPerms
string - Source:
Returns:
- Type
- FileSystem
-
chown(path, user, group, handler) → {FileSystem}
-
Change the ownership on the file represented by
path
touser
and {code group}, asynchronously.Parameters:
Name Type Description path
string the path to the file user
string the user name group
string the user group handler
function the handler that will be called on completion - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- FileSystem
-
chownBlocking(path, user, group) → {FileSystem}
-
Blocking version of FileSystem#chown
Parameters:
Name Type Description path
string user
string group
string - Source:
Returns:
- Type
- FileSystem
-
copy(from, to, handler) → {FileSystem}
-
Copy a file from the path
from
to pathto
, asynchronously.The copy will fail if the destination already exists.
Parameters:
Name Type Description from
string the path to copy from to
string the path to copy to handler
function the handler that will be called on completion - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- FileSystem
-
copyBlocking(from, to) → {FileSystem}
-
Blocking version of FileSystem#copy
Parameters:
Name Type Description from
string to
string - Source:
Returns:
- Type
- FileSystem
-
copyRecursive(from, to, recursive, handler) → {FileSystem}
-
Copy a file from the path
from
to pathto
, asynchronously.If
recursive
istrue
andfrom
represents a directory, then the directory and its contents will be copied recursively to the destinationto
.The copy will fail if the destination if the destination already exists.
Parameters:
Name Type Description from
string the path to copy from to
string the path to copy to recursive
boolean handler
function the handler that will be called on completion - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- FileSystem
-
copyRecursiveBlocking(from, to, recursive) → {FileSystem}
-
Blocking version of FileSystem#copyRecursive
Parameters:
Name Type Description from
string to
string recursive
boolean - Source:
Returns:
- Type
- FileSystem
-
createFile(path, perms, handler) → {FileSystem}
-
Creates an empty file with the specified
path
and permissionsperms
, asynchronously.Parameters:
Name Type Description path
string path to the file perms
string the permissions string handler
function the handler that will be called on completion - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- FileSystem
-
createFileBlocking(path, perms) → {FileSystem}
-
Blocking version of FileSystem#createFile
Parameters:
Name Type Description path
string perms
string - Source:
Returns:
- Type
- FileSystem
-
delete(path, handler) → {FileSystem}
-
Deletes the file represented by the specified
path
, asynchronously.Parameters:
Name Type Description path
string path to the file handler
function the handler that will be called on completion - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- FileSystem
-
deleteBlocking(path) → {FileSystem}
-
Blocking version of FileSystem#delete
Parameters:
Name Type Description path
string - Source:
Returns:
- Type
- FileSystem
-
deleteRecursive(path, recursive, handler) → {FileSystem}
-
Deletes the file represented by the specified
path
, asynchronously.If the path represents a directory and
recursive = true
then the directory and its contents will be deleted recursively.Parameters:
Name Type Description path
string path to the file recursive
boolean delete recursively? handler
function the handler that will be called on completion - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- FileSystem
-
deleteRecursiveBlocking(path, recursive) → {FileSystem}
-
Blocking version of FileSystem#deleteRecursive
Parameters:
Name Type Description path
string recursive
boolean - Source:
Returns:
- Type
- FileSystem
-
exists(path, handler) → {FileSystem}
-
Determines whether the file as specified by the path
path
exists, asynchronously.Parameters:
Name Type Description path
string path to the file handler
function the handler that will be called on completion - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- FileSystem
-
existsBlocking(path) → {boolean}
-
Blocking version of FileSystem#exists
Parameters:
Name Type Description path
string - Source:
Returns:
- Type
- boolean
-
fsProps(path, handler) → {FileSystem}
-
Returns properties of the file-system being used by the specified
path
, asynchronously.Parameters:
Name Type Description path
string path to anywhere on the filesystem handler
function the handler that will be called on completion - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- FileSystem
-
fsPropsBlocking(path) → {FileSystemProps}
-
Blocking version of FileSystem#fsProps
Parameters:
Name Type Description path
string - Source:
Returns:
- Type
- FileSystemProps
-
link(link, existing, handler) → {FileSystem}
-
Create a hard link on the file system from
link
toexisting
, asynchronously.Parameters:
Name Type Description link
string the link existing
string the link destination handler
function the handler that will be called on completion - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- FileSystem
-
linkBlocking(link, existing) → {FileSystem}
-
Blocking version of FileSystem#link
Parameters:
Name Type Description link
string existing
string - Source:
Returns:
- Type
- FileSystem
-
lprops(path, handler) → {FileSystem}
-
Obtain properties for the link represented by
path
, asynchronously.The link will not be followed.
Parameters:
Name Type Description path
string the path to the file handler
function the handler that will be called on completion - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- FileSystem
-
lpropsBlocking(path) → {FileProps}
-
Blocking version of FileSystem#lprops
Parameters:
Name Type Description path
string - Source:
Returns:
- Type
- FileProps
-
mkdir(path, perms, handler) → {FileSystem}
-
Create the directory represented by
path
, asynchronously.The new directory will be created with permissions as specified by
perms
.The permission String takes the form rwxr-x--- as specified in here.
The operation will fail if the directory already exists.
Parameters:
Name Type Description path
string path to the file perms
string the permissions string handler
function the handler that will be called on completion - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- FileSystem
-
mkdirBlocking(path, perms) → {FileSystem}
-
Blocking version of FileSystem#mkdir
Parameters:
Name Type Description path
string perms
string - Source:
Returns:
- Type
- FileSystem
-
mkdirs(path, perms, handler) → {FileSystem}
-
Create the directory represented by
path
and any non existent parents, asynchronously.The new directory will be created with permissions as specified by
perms
.The permission String takes the form rwxr-x--- as specified in here.
The operation will fail if the directory already exists.
Parameters:
Name Type Description path
string path to the file perms
string the permissions string handler
function the handler that will be called on completion - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- FileSystem
-
mkdirsBlocking(path, perms) → {FileSystem}
-
Blocking version of FileSystem#mkdirs
Parameters:
Name Type Description path
string perms
string - Source:
Returns:
- Type
- FileSystem
-
move(from, to, handler) → {FileSystem}
-
Move a file from the path
from
to pathto
, asynchronously.The move will fail if the destination already exists.
Parameters:
Name Type Description from
string the path to copy from to
string the path to copy to handler
function the handler that will be called on completion - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- FileSystem
-
moveBlocking(from, to) → {FileSystem}
-
Blocking version of FileSystem#move
Parameters:
Name Type Description from
string to
string - Source:
Returns:
- Type
- FileSystem
-
open(path, options, handler) → {FileSystem}
-
Open the file represented by
path
, asynchronously.The file is opened for both reading and writing. If the file does not already exist it will be created.
Parameters:
Name Type Description path
string path to the file options
Object options describing how the file should be opened handler
function - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- FileSystem
-
openBlocking(path, options) → {AsyncFile}
-
Blocking version of FileSystem#open
Parameters:
Name Type Description path
string options
Object - Source:
Returns:
- Type
- AsyncFile
-
props(path, handler) → {FileSystem}
-
Obtain properties for the file represented by
path
, asynchronously.If the file is a link, the link will be followed.
Parameters:
Name Type Description path
string the path to the file handler
function the handler that will be called on completion - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- FileSystem
-
propsBlocking(path) → {FileProps}
-
Blocking version of FileSystem#props
Parameters:
Name Type Description path
string - Source:
Returns:
- Type
- FileProps
-
readDir(path, filter, handler) → {FileSystem}
-
Read the contents of the directory specified by
path
, asynchronously.The parameter
filter
is a regular expression. Iffilter
is specified then only the paths that match @{filter}will be returned.The result is an array of String representing the paths of the files inside the directory.
Parameters:
Name Type Description path
string path to the directory filter
string the filter expression handler
function the handler that will be called on completion - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- FileSystem
-
readDirBlocking(path, filter) → {Array.<string>}
-
Blocking version of FileSystem#readDir
Parameters:
Name Type Description path
string filter
string - Source:
Returns:
- Type
- Array.<string>
-
readFile(path, handler) → {FileSystem}
-
Reads the entire file as represented by the path
path
as a , asynchronously.Do not user this method to read very large files or you risk running out of available RAM.
Parameters:
Name Type Description path
string path to the file handler
function the handler that will be called on completion - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- FileSystem
-
readFileBlocking(path) → {Buffer}
-
Blocking version of FileSystem#readFile
Parameters:
Name Type Description path
string - Source:
Returns:
- Type
- Buffer
-
readSymlink(link, handler) → {FileSystem}
-
Returns the path representing the file that the symbolic link specified by
link
points to, asynchronously.Parameters:
Name Type Description link
string the link handler
function the handler that will be called on completion - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- FileSystem
-
readSymlinkBlocking(link) → {string}
-
Blocking version of FileSystem#readSymlink
Parameters:
Name Type Description link
string - Source:
Returns:
- Type
- string
-
symlink(link, existing, handler) → {FileSystem}
-
Create a symbolic link on the file system from
link
toexisting
, asynchronously.Parameters:
Name Type Description link
string the link existing
string the link destination handler
function the handler that will be called on completion - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- FileSystem
-
symlinkBlocking(link, existing) → {FileSystem}
-
Blocking version of FileSystem#link
Parameters:
Name Type Description link
string existing
string - Source:
Returns:
- Type
- FileSystem
-
truncate(path, len, handler) → {FileSystem}
-
Truncate the file represented by
path
to lengthlen
in bytes, asynchronously.The operation will fail if the file does not exist or
len
is less thanzero
.Parameters:
Name Type Description path
string the path to the file len
number the length to truncate it to handler
function the handler that will be called on completion - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- FileSystem
-
truncateBlocking(path, len) → {FileSystem}
-
Blocking version of FileSystem#truncate
Parameters:
Name Type Description path
string len
number - Source:
Returns:
- Type
- FileSystem
-
unlink(link, handler) → {FileSystem}
-
Unlinks the link on the file system represented by the path
link
, asynchronously.Parameters:
Name Type Description link
string the link handler
function the handler that will be called on completion - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- FileSystem
-
unlinkBlocking(link) → {FileSystem}
-
Blocking version of FileSystem#unlink
Parameters:
Name Type Description link
string - Source:
Returns:
- Type
- FileSystem
-
writeFile(path, data, handler) → {FileSystem}
-
Creates the file, and writes the specified
Buffer data
to the file represented by the pathpath
, asynchronously.Parameters:
Name Type Description path
string path to the file data
Buffer handler
function the handler that will be called on completion - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- FileSystem
-
writeFileBlocking(path, data) → {FileSystem}
-
Blocking version of FileSystem#writeFile
Parameters:
Name Type Description path
string data
Buffer - Source:
Returns:
- Type
- FileSystem