Module fs
This module provides an implementation of "fs" as defined by the CommonJS Filesystem/A proposal.
The "fs" module provides a file system API for the manipulation of paths, directories, files, links, and the construction of file streams in addition to the functions exported by fs-base.
Functions
- absolute (path)
- base (path, ext)
- copy (from, to)
- copyTree (from, to)
- directory (path)
- extension (path)
- isAbsolute (path)
- isRelative (path)
- join ()
- listDirectoryTree (path)
- listTree (path)
- makeTree (path)
- normal (path)
- open (path, options)
- read (path, options)
- relative (source, target)
- removeTree (path)
- resolve ()
- split (path)
- write (path, content, options)
Properties
Path ()
Path constructor. Path is a chainable shorthand for working with paths.
Path.prototype.toString ()
Path.prototype.prototype
Path.prototype.from (target)
Return the relative path from the given source path to this path. Equivalent
to fs.Path(fs.relative(source, this)).
Parameters
| target |
Path.prototype.join ()
Join a list of paths to this path.
Path.prototype.listPaths ()
Return the names of all files in this path, in lexically sorted order and wrapped in Path objects.
Path.prototype.resolve ()
Resolve against this path.
Path.prototype.to (target)
Return the relative path from this path to the given target path. Equivalent
to fs.Path(fs.relative(this, target)).
Parameters
| target |
Path.prototype.valueOf ()
This is a non-standard extension, not part of CommonJS Filesystem/A.
absolute (path)
Make the given path absolute by resolving it against the current working directory.
Parameters
| path |
base (path, ext)
Return the basename of the given path. That is the path with any leading directory components removed. If specified, also remove a trailing extension.
Parameters
| path | ||
| ext |
copy (from, to)
Read data from one file and write it into another using binary mode.
Parameters
| from | ||
| to |
copyTree (from, to)
Copy files from a source path to a target path. Files of the below the source path are copied to the corresponding locations relative to the target path, symbolic links to directories are copied but not traversed into.
Parameters
| from | ||
| to |
directory (path)
Return the dirname of the given path. That is the path with any trailing non-directory component removed.
Parameters
| path |
extension (path)
Return the extension of a given path. That is everything after the last dot in the basename of the given path, including the last dot. Returns an empty string if no valid extension exists.
Parameters
| path |
isAbsolute (path)
Check whether the given pathname is absolute.
This is a non-standard extension, not part of CommonJS Filesystem/A.
Parameters
| path |
isRelative (path)
Check wheter the given pathname is relative (i.e. not absolute).
This is a non-standard extension, not part of CommonJS Filesystem/A.
Parameters
| path |
join ()
Join a list of paths using the local file system's path separator and normalize the result.
listDirectoryTree (path)
Return an array with all directories below (and including) the given path, as discovered by depth-first traversal. Entries are in lexically sorted order within directories. Symbolic links to directories are not traversed into.
Parameters
| path |
listTree (path)
Return an array with all paths (files, directories, etc.) below (and including) the given path, as discovered by depth-first traversal. Entries are in lexically sorted order within directories. Symbolic links to directories are returned but not traversed into.
Parameters
| path |
makeTree (path)
Create the directory specified by "path" including any missing parent directories.
Parameters
| path |
normal (path)
Normalize a path by removing '.' and simplifying '..' components, wherever possible.
Parameters
| path |
open (path, options)
Open an IO stream for reading/writing to the file corresponding to the given path.
Parameters
| path | ||
| options |
read (path, options)
Open, read, and close a file, returning the file's contents.
Parameters
| path | ||
| options |
relative (source, target)
Establish the relative path that links source to target by strictly traversing up ('..') to find a common ancestor of both paths. If the target is omitted, returns the path to the source from the current working directory.
Parameters
| source | ||
| target |
removeTree (path)
Remove the element pointed to by the given path. If path points to a directory, all members of the directory are removed recursively.
Parameters
| path |
resolve ()
Join a list of paths by starting at an empty location and iteratively "walking" to each path given. Correctly takes into account both relative and absolute paths.
write (path, content, options)
Open, write, flush, and close a file, writing the given content. If content is a binary.ByteArray or binary.ByteString, binary mode is implied.
Parameters
| path | ||
| content | ||
| options |