Module: vertx/file_system

vertx/file_system

Classes

AsyncFile

Members

<static> CREATE_NEW

Properties:
Name Type Description
CREATE_NEW Flag Create new file flag.
Source:

<static> OPEN_READ

Properties:
Name Type Description
OPEN_READ Flag Open file for reading flag.
Source:

<static> OPEN_WRITE

Properties:
Name Type Description
OPEN_WRITE Flag Open file for writing flag.
Source:

Methods

<static> chmod(path, perms, dir_perms, handler) → {module:vertx/file_system}

Change the permissions on a file, asynchronously. If the file is directory then all contents will also have their permissions changed recursively.
Parameters:
Name Type Argument Description
path string path of file to change permissions
perms string a permission string of the form rwxr-x--- as specified in http://download.oracle.com/javase/7/docs/api/java/nio/file/attribute/PosixFilePermissions.html. This is used to set the permissions for any regular files (not directories).
dir_perms string <optional>
similar to perms above, but refers only to directories.
handler ResultHandler The handler to call when the operation has completed
Source:
Returns:
Type
module:vertx/file_system

<static> chmodSync(path, perms, dir_perms) → {module:vertx/file_system}

Synchronous version of chmod.
Parameters:
Name Type Argument Description
path string path of file to change permissions
perms string a permission string of the form rwxr-x--- as specified in http://download.oracle.com/javase/7/docs/api/java/nio/file/attribute/PosixFilePermissions.html. This is used to set the permissions for any regular files (not directories).
dir_perms string <optional>
similar to perms above, but refers only to directories.
Source:
Returns:
Type
module:vertx/file_system

<static> chown(path, user, group, handler) → {module:vertx/file_system}

Change the ownership on the file represented by {@code path} to {@code user} and {code group}, asynchronously
Parameters:
Name Type Argument Description
path string path of file to change permissions
user string the username
group string <optional>
the groupname
handler ResultHandler The handler to call when the operation has completed
Source:
Returns:
Type
module:vertx/file_system

<static> chownSync(path, user, group) → {module:vertx/file_system}

Synchronous version of chown
Parameters:
Name Type Argument Description
path string path of file to change permissions
user string the username
group string <optional>
the groupname
Source:
Returns:
Type
module:vertx/file_system

<static> copy(from, to, recursive, handler) → {module:vertx/file_system}

Copy a file, asynchronously. The copy will fail if from does not exist, or if to already exists.
Parameters:
Name Type Argument Description
from string path of file to copy
to string path of file to copy to
recursive boolean <optional>
copy recursively (default is false)
handler ResultHandler the handler which is called on completion.
Source:
Returns:
Type
module:vertx/file_system

<static> copySync(from, to, recursive) → {module:vertx/file_system}

Synchronous version of copy
Parameters:
Name Type Description
from string the path of the file to copy
to string the path to copy the file to
recursive boolean copy recursively (default is false)
Source:
Returns:
Type
module:vertx/file_system

<static> createFile(path, handler) → {module:vertx/file_system}

Create a new empty file, asynchronously.
Parameters:
Name Type Description
path string path of the file to create.
handler ResultHandler the function to call when complete
Source:
Returns:
Type
module:vertx/file_system

<static> createFileSync(path) → {module:vertx/file_system}

Synchronous version of createFile.
Parameters:
Name Type Description
path string path of the file to create.
Source:
Returns:
Type
module:vertx/file_system

<static> delete(path, recursive, handler) → {module:vertx/file_system}

Delete a file on the file system, asynchronously. The delete will fail if the file does not exist, or is a directory and is not empty.
Parameters:
Name Type Argument Description
path string path of the file to delete.
recursive boolean <optional>
recurse into subdirectories (default: false)
handler ResultHandler The handler to call when complete
Source:
Returns:
Type
module:vertx/file_system

<static> deleteSync(path, recursive) → {module:vertx/file_system}

Synchronous version of delete.
Parameters:
Name Type Argument Description
path string path of the file to delete.
recursive boolean <optional>
recurse into subdirectories (default: false)
Source:
Returns:
Type
module:vertx/file_system

<static> exists(path, handler) → {module:vertx/file_system}

Check if a file exists, asynchronously.
Parameters:
Name Type Description
path string Path of the file to check.
handler ResultHandler the function to call when complete
Source:
Returns:
Type
module:vertx/file_system

<static> existsSync(path) → {boolean}

Synchronous version of exists.
Parameters:
Name Type Description
path string Path of the file to check.
Source:
Returns:
true if the file exists
Type
boolean

<static> fsProps(path, handler) → {module:vertx/file_system}

Asynchronously get properties for the file system being used by the path specified.
Parameters:
Name Type Description
path string the path in the file system.
handler ResultHandler the function to call with the FileSystemProps when complete
Source:
Returns:
Type
module:vertx/file_system

<static> fsPropsSync(path) → {FileSystemProps}

Synchronous version of fsProps.
Parameters:
Name Type Description
path string Path in the file system.
Source:
Returns:
Type
FileSystemProps
Create a hard link, asynchronously.
Parameters:
Name Type Description
link string path of the link to create.
existing string path of where the link points to.
handler ResultHandler the function to call when complete
Source:
Returns:
Type
module:vertx/file_system

<static> linkSync(link, existing) → {module:vertx/file_system}

Synchronous version of link.
Parameters:
Name Type Description
link string path of the link to create.
existing string path of where the link points to.
Source:
Returns:
Type
module:vertx/file_system

<static> lprops(path, handler) → {module:vertx/file_system}

Obtain properties for the link represented by path, asynchronously. The link will not be followed.
Parameters:
Name Type Description
path string path to file
handler ResultHandler the function to call when complete
Source:
Returns:
Type
module:vertx/file_system

<static> lpropsSync(path) → {FileProps}

Synchronous version of lprops.
Parameters:
Name Type Description
path string path to file
Source:
Returns:
Type
FileProps

<static> mkDir(path, createParents, permString, handler) → {module:vertx/file_system}

Create a directory, asynchronously. The create will fail if the directory already exists, or if it contains parent directories which do not already exist.
Parameters:
Name Type Argument Description
path string path of the directory to create.
createParents boolean <optional>
create parent directories if necesssary (default is false)
permString string <optional>
the permissions of the directory being created
handler ResultHandler the function to call when complete
Source:
Returns:
Type
module:vertx/file_system

<static> mkDirSync(path, createParents, permString) → {module:vertx/file_system}

Synchronous version of mkdir.
Parameters:
Name Type Argument Description
path string path of the directory to create.
createParents boolean <optional>
create parent directories if necesssary (default is false)
permString string <optional>
the permissions of the directory being created
Source:
Returns:
Type
module:vertx/file_system

<static> move(from, to, handler) → {module:vertx/file_system}

Move a file, asynchronously. The move will fail if from does not exist, or if to already exists.
Parameters:
Name Type Description
from string the path of file to move
to string the path to move the file to
handler ResultHandler the function to call when complete
Source:
Returns:
Type
module:vertx/file_system

<static> moveSync(from, to) → {module:vertx/file_system}

Synchronous version of move.
Parameters:
Name Type Description
from string the path of file to move
to string the path to move the file to
Source:
Returns:
Type
module:vertx/file_system

<static> open(path, openFlags, flush, permissions, handler) → {module:vertx/file_system}

Open a file on the file system, asynchronously.
Parameters:
Name Type Argument Description
path string the path of the file to open
openFlags Flag <optional>
an integer representing whether to open the file for reading, writing, creation, or some combination of these with bitwise or (e.g. fileSystem.OPEN_READ | fileSystem.OPEN_WRITE). If not specified the file will be opened for reading, wrting, and creation.
flush boolean <optional>
flush file writes immediately (default is false)
permissions string <optional>
the permissions to create the file with if the file is created when opened.
handler ResultHandler the function to be called when the file is opened. The handler will receieve an AsyncFile as a parameter when called.
Source:
Returns:
Type
module:vertx/file_system

<static> openSync(path, openFlags, flush, permissions) → {module:vertx/file_system.AsyncFile}

Synchronous version of open.
Parameters:
Name Type Argument Description
path string the path of the file to open
openFlags Flag <optional>
an integer representing whether to open the file for reading, writing, creation, or some combination of these with bitwise or (e.g. fileSystem.OPEN_READ | fileSystem.OPEN_WRITE). If not specified the file will be opened for reading, wrting, and creation.
flush boolean <optional>
flush file writes immediately (default is false)
permissions string <optional>
the permissions to create the file with if the file is created when opened.
Source:
Returns:
Type
module:vertx/file_system.AsyncFile

<static> props(path, handler) → {module:vertx/file_system}

Get file properties for a file, asynchronously.
Parameters:
Name Type Description
path string path to file
handler ResultHandler the function to call when complete
Source:
Returns:
Type
module:vertx/file_system

<static> propsSync(path) → {FileProps}

Synchronous version of props.
Parameters:
Name Type Description
path string path to file
Source:
Returns:
Type
FileProps

<static> readDir(path, filter, handler) → {module:vertx/file_system}

Read a directory, i.e. list it's contents, asynchronously. The read will fail if the directory does not exist.
Parameters:
Name Type Argument Description
path string path of the directory to read.
filter string <optional>
a regular expression. If supplied, only paths that match filter will be passed to the handler.
handler ResultHandler the handler to call when complete. The handler will be passed an array of strings each representing a matched path name.
Source:
Returns:
Type
module:vertx/file_system

<static> readDirSync(path, filter) → {Array}

Synchronous version of readDir.
Parameters:
Name Type Argument Description
path string path of the directory to read.
filter string <optional>
a regular expression. If supplied, only paths that match filter will be passed to the handler.
Source:
Returns:
an array of strings, each representing a matched path name.
Type
Array

<static> readFile(path, handler) → {module:vertx/file_system}

Read the contents of the entire file.
Parameters:
Name Type Description
path string path of the file to read.
handler ResultHandler the function to call when complete. The handler function will receive a Buffer containing the contents of the file.
Source:
Returns:
Type
module:vertx/file_system

<static> readFileSync(path) → {Buffer}

Synchronous version of readFile.
Parameters:
Name Type Description
path string path of the file to read.
Source:
Returns:
a Buffer containing the contents of the file.
Type
Buffer
Read a symbolic link, asynchronously. I.e. tells you where the symbolic link points.
Parameters:
Name Type Description
link string path of the link to read.
handler ResultHandler the function to call when complete, the function will be called with a string representing the path of the file that the link symlink is linked to.
Source:
Returns:
Type
module:vertx/file_system

<static> readSymlinkSync(link) → {string}

Synchronous version of readSymlink.
Parameters:
Name Type Description
link string path of the link to read.
Source:
Returns:
the path of the file that the link symlink is linked to.
Type
string
Create a symbolic link, asynchronously.
Parameters:
Name Type Description
link string Path of the link to create.
existing string Path of where the link points to.
handler ResultHandler the function to call when complete
Source:
Returns:
Type
module:vertx/file_system

<static> symlinkSync(link, existing) → {module:vertx/file_system}

Synchronous version of symlink.
Parameters:
Name Type Description
link string Path of the link to create.
existing string Path of where the link points to.
Source:
Returns:
Type
module:vertx/file_system

<static> truncate(path, len, handler) → {module:vertx/file_system}

Truncate a file, asynchronously. The move will fail if path does not exist.
Parameters:
Name Type Description
path string Path of file to truncate
len number Length to truncate file to. Will fail if len < 0. If len > file size then will do nothing.
handler ResultHandler the function to call when complete
Source:
Returns:
Type
module:vertx/file_system

<static> truncateSync(path, len) → {module:vertx/file_system}

Synchronous version of truncate.
Parameters:
Name Type Description
path string Path of file to truncate
len number Length to truncate file to. Will fail if len < 0. If len > file size then will do nothing.
Source:
Returns:
Type
module:vertx/file_system
Unlink a hard link.
Parameters:
Name Type Description
link string path of the link to unlink.
handler ResultHandler the handler to notify on completion.
Source:
Returns:
Type
module:vertx/file_system

<static> unlinkSync(link) → {module:vertx/file_system}

Synchronous version of unlink.
Parameters:
Name Type Description
link string path of the link to unlink.
Source:
Returns:
Type
module:vertx/file_system

<static> writeFile(path, data, handler) → {module:vertx/file_system}

Write data to a file
Parameters:
Name Type Description
path string path of the file to write.
data string | Buffer the data to write
handler ResultHandler the function to call when complete
Source:
Returns:
Type
module:vertx/file_system

<static> writeFileSync(path, data) → {module:vertx/file_system}

Synchronous version of writeFile.
Parameters:
Name Type Description
path string path of the file to write.
data string | Buffer the data to write
Source:
Returns:
Type
module:vertx/file_system