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
pathtoperms, asynchronously.The permission String takes the form rwxr-x--- as specified here.
Parameters:
Name Type Description pathstring the path to the file permsstring the permissions string handlerfunction 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 pathstring permsstring - Source:
Returns:
- Type
- FileSystem
-
chmodRecursive(path, perms, dirPerms, handler) → {FileSystem}
-
Change the permissions on the file represented by
pathtoperms, 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 pathstring the path to the file permsstring the permissions string dirPermsstring the directory permissions handlerfunction 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 pathstring permsstring dirPermsstring - Source:
Returns:
- Type
- FileSystem
-
chown(path, user, group, handler) → {FileSystem}
-
Change the ownership on the file represented by
pathtouserand {code group}, asynchronously.Parameters:
Name Type Description pathstring the path to the file userstring the user name groupstring the user group handlerfunction 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 pathstring userstring groupstring - Source:
Returns:
- Type
- FileSystem
-
copy(from, to, handler) → {FileSystem}
-
Copy a file from the path
fromto pathto, asynchronously.The copy will fail if the destination already exists.
Parameters:
Name Type Description fromstring the path to copy from tostring the path to copy to handlerfunction 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 fromstring tostring - Source:
Returns:
- Type
- FileSystem
-
copyRecursive(from, to, recursive, handler) → {FileSystem}
-
Copy a file from the path
fromto pathto, asynchronously.If
recursiveistrueandfromrepresents 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 fromstring the path to copy from tostring the path to copy to recursiveboolean handlerfunction 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 fromstring tostring recursiveboolean - Source:
Returns:
- Type
- FileSystem
-
createFile(path, perms, handler) → {FileSystem}
-
Creates an empty file with the specified
pathand permissionsperms, asynchronously.Parameters:
Name Type Description pathstring path to the file permsstring the permissions string handlerfunction 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 pathstring permsstring - Source:
Returns:
- Type
- FileSystem
-
delete(path, handler) → {FileSystem}
-
Deletes the file represented by the specified
path, asynchronously.Parameters:
Name Type Description pathstring path to the file handlerfunction 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 pathstring - 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 = truethen the directory and its contents will be deleted recursively.Parameters:
Name Type Description pathstring path to the file recursiveboolean delete recursively? handlerfunction 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 pathstring recursiveboolean - Source:
Returns:
- Type
- FileSystem
-
exists(path, handler) → {FileSystem}
-
Determines whether the file as specified by the path
pathexists, asynchronously.Parameters:
Name Type Description pathstring path to the file handlerfunction 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 pathstring - 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 pathstring path to anywhere on the filesystem handlerfunction 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 pathstring - Source:
Returns:
- Type
- FileSystemProps
-
link(link, existing, handler) → {FileSystem}
-
Create a hard link on the file system from
linktoexisting, asynchronously.Parameters:
Name Type Description linkstring the link existingstring the link destination handlerfunction 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 linkstring existingstring - 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 pathstring the path to the file handlerfunction 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 pathstring - 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 pathstring path to the file permsstring the permissions string handlerfunction 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 pathstring permsstring - Source:
Returns:
- Type
- FileSystem
-
mkdirs(path, perms, handler) → {FileSystem}
-
Create the directory represented by
pathand 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 pathstring path to the file permsstring the permissions string handlerfunction 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 pathstring permsstring - Source:
Returns:
- Type
- FileSystem
-
move(from, to, handler) → {FileSystem}
-
Move a file from the path
fromto pathto, asynchronously.The move will fail if the destination already exists.
Parameters:
Name Type Description fromstring the path to copy from tostring the path to copy to handlerfunction 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 fromstring tostring - 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 pathstring path to the file optionsObject options describing how the file should be opened handlerfunction - 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 pathstring optionsObject - 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 pathstring the path to the file handlerfunction 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 pathstring - Source:
Returns:
- Type
- FileProps
-
readDir(path, filter, handler) → {FileSystem}
-
Read the contents of the directory specified by
path, asynchronously.The parameter
filteris a regular expression. Iffilteris 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 pathstring path to the directory filterstring the filter expression handlerfunction 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 pathstring filterstring - Source:
Returns:
- Type
- Array.<string>
-
readFile(path, handler) → {FileSystem}
-
Reads the entire file as represented by the path
pathas a , asynchronously.Do not user this method to read very large files or you risk running out of available RAM.
Parameters:
Name Type Description pathstring path to the file handlerfunction 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 pathstring - Source:
Returns:
- Type
- Buffer
-
readSymlink(link, handler) → {FileSystem}
-
Returns the path representing the file that the symbolic link specified by
linkpoints to, asynchronously.Parameters:
Name Type Description linkstring the link handlerfunction 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 linkstring - Source:
Returns:
- Type
- string
-
symlink(link, existing, handler) → {FileSystem}
-
Create a symbolic link on the file system from
linktoexisting, asynchronously.Parameters:
Name Type Description linkstring the link existingstring the link destination handlerfunction 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 linkstring existingstring - Source:
Returns:
- Type
- FileSystem
-
truncate(path, len, handler) → {FileSystem}
-
Truncate the file represented by
pathto lengthlenin bytes, asynchronously.The operation will fail if the file does not exist or
lenis less thanzero.Parameters:
Name Type Description pathstring the path to the file lennumber the length to truncate it to handlerfunction 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 pathstring lennumber - 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 linkstring the link handlerfunction 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 linkstring - Source:
Returns:
- Type
- FileSystem
-
writeFile(path, data, handler) → {FileSystem}
-
Creates the file, and writes the specified
Buffer datato the file represented by the pathpath, asynchronously.Parameters:
Name Type Description pathstring path to the file dataBuffer handlerfunction 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 pathstring dataBuffer - Source:
Returns:
- Type
- FileSystem