namespace fs_base
Description
Low-level filesystem access.
NOTE:
This module is actually called fs-base. PDoc currently won’t parse that, so it has been documented as fs_base’
Methods
Class methods
-
canonial #
fs_base.canonial(path) ⇒ String- path (String):
Resolve symlinks and canonicalize
path. If it is a directory, the returned string will be guarenteed to have a trailing ’/’ -
changeWorkingDirectory #
fs_base.changeWorkingDirectory(dir) ⇒ undefined-
dir(String) – new working directory
Change the processes current working directory to
dir. -
-
exists #
fs_base.exists(path) ⇒ Boolean-
path(String) – path to test
Returns true if something exists on the filesystem at the given path, be it a directory, normal file, symlink or special file.
-
-
hardLink #
fs_base.hardLink(link_target, name) ⇒ undefined- link_target (String): path the hard link should point to
- name (String): name of hard link to create
Create a hard link in the same manner as
ln link_target name(this function doesn’t shell out, this is just an indicator of behaviour.) -
isDirectory #
fs_base.isDirectory(path) ⇒ Boolean-
path(String) – path to test
Test if
pathis a directory. -
-
isFile #
fs_base.isFile(path) ⇒ Boolean-
path(String) – path to test
Test if
pathis a ordinary file. -
-
isLink #
fs_base.isLink(path) ⇒ Boolean-
path(String) – path to test
Test if
pathis a symbolic link. -
-
isReadable #
fs_base.isReadable(path) ⇒ Boolean-
path(String) – path to test
Test if
pathis readable. -
-
isWriteable #
fs_base.isWriteable(path) ⇒ Boolean-
path(String) – path to test
Test if
pathis readable. -
-
lastModified #
fs_base.lastModified(path) ⇒ Date-
path(String) – path
Get the last modification time of
pathas a javascript Date object. -
-
link #
fs_base.link(link_target, name) ⇒ undefined- link_target (String): path the symbolic link should point to
- name (String): name of symbolic link to create
Create a symbolic link in the same manner as
ln -s link_target name(this function doesn’t shell out, this is just an indicator of behaviour.) -
list #
fs_base.list(dir) ⇒ Array-
dir(String) – directory to list
Return an array of the contents of the directory. The elements of the returned list will be prefixed with the directory name, for example:
fs.list('a/b'); // -> ['a/b/c.txt', 'a/b/d.js']The self (’.’) and parent (‘..’) directory entries will not be returned.
-
-
makeDirectory #
fs_base.makeDirectory(dir) ⇒ undefined-
dir(String) – directory to create
Creates a (single) directory. If parent directories do not exist they will not be created by this method.
-
-
move #
fs_base.move(source, target) ⇒ undefined-
source(String) – source file or directory -
target(String) – target destination
Move the file or directory
sourcetotargetusing the underlying OS semantics (atomicity, file -> directory etc.) -
-
rawOpen #
fs_base.rawOpen(name[, mode[, perms]]) ⇒ io.File-
name(String) – filename -
mode(String|Object) – file open mode (read/write etc) -
perms(?) – file creation permissions – not currently supported.
Open a file for reading
-
-
readLink #
fs_base.readLink(link) ⇒ String-
link(String) – symbolic link to read
Read the symbolic link and return the (relative) path it links to. Uses readlink for the underlying implementation.
-
-
remove #
fs_base.remove(file) ⇒ undefined-
file(String) – file to remove
Attempt to remove the
filefrom disk. To remove directories use fs_base#removeDirectory -
-
removeDirectory #
fs_base.removeDirectory(dir) ⇒ undefined-
dir(String) – directory to remove
Removes an empty directory. A symbolic link is itself removed, rather than the directory it resolves to being removed.
-
-
same #
fs_base.same(path1, path2) ⇒ Boolean- path1 (String): path to compare
- path2 (String): path to compare
Compare if the two paths are identical.
-
size #
fs_base.size(path) ⇒ Number-
path(String) – path
Return the size of the file in bytes. Due to the way that ECMAScript behaves, if the file is larger than 65,536 terabytes accuracy will be lost.
-
-
touch #
fs_base.touch(path[, mtime]) ⇒ undefined-
path(String) – File or directory to touch -
mtime(Date) – Date to change last modified date to.
‘touch’ the path, setting the last modified date to
mtimeor now. If there is no file or directory atpath, an empty file will be created. -
-
workingDirectory #
fs_base.workingDirectory() ⇒ StringGet the processes current working directory.