Contains a broad set of operations for manipulating files.

An asynchronous and a synchronous version of each operation is provided.

The asynchronous versions take a handler which is called when the operation completes or an error occurs.

The synchronous versions return the results, or throw exceptions directly.

It is highly recommended the asynchronous versions are used unless you are sure the operation will not block for a significant period of time.

Instances of FileSystem are thread-safe.

no subtypes hierarchy

Initializer
FileSystem(FileSystem delegate)
Inherited Attributes
Attributes inherited from: Object
hash, string
Methods
chmodshared Promise<Anything> chmod(String path, String perms, String? dirPerms = null)

Change the permissions on the file represented by path to perms, 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 to perms.

Parameters:
  • dirPerms = null
chmodSyncshared FileSystem chmodSync(String path, String perms, String? dirPerms = null)

Synchronous version of chmod()

Parameters:
  • dirPerms = null
chownshared Promise<Anything> chown(String path, String user, String group)

Change the ownership on the file represented by path to user and group, asynchronously.

chownSyncshared FileSystem chownSync(String path, String user, String group)

Synchronous version of chown()

copyshared Promise<Anything> copy(String from, String to, Boolean? recursive = null)

Copy a file from the path from to path to, asynchronously.

If recursive is true and from represents a directory, then the directory and its contents will be copied recursively to the destination to.

The copy will fail if the destination if the destination already exists.

Parameters:
  • recursive = null
copySyncshared FileSystem copySync(String from, String to, Boolean? recursive = null)

Synchronous version of copy()

Parameters:
  • recursive = null
createFileshared Promise<Anything> createFile(String path, String? perms = null)

Creates an empty file with the specified path and permissions perms, asynchronously.

Parameters:
  • perms = null
createFileSyncshared FileSystem createFileSync(String path)

Synchronous version of createFile()

deleteshared Promise<Anything> delete(String path, Boolean? recursive = null)

Deletes the file represented by the specified path, asynchronously.

If the path represents a directory and recursive then the directory and its contents will be deleted recursively.

Parameters:
  • recursive = null
deleteSyncshared FileSystem deleteSync(String path, Boolean? recursive = null)

Synchronous version of delete()

Parameters:
  • recursive = null
existsshared Promise<Boolean> exists(String path)

Determines whether the file as specified by the path path exists, asynchronously.

existsSyncshared Boolean existsSync(String path)

Synchronous version of exists()

fsPropsshared Promise<FileSystemProps> fsProps(String path)

Returns properties of the file-system being used by the specified path, asynchronously.

fsPropsSyncshared FileSystemProps fsPropsSync(String path)

Synchronous version of fsProps()

shared Promise<Anything> link(String link, String existing)

Create a hard link on the file system from link to existing, asynchronously.

linkSyncshared FileSystem linkSync(String link, String existing)

Synchronous version of link()

lpropsshared Promise<FileProps> lprops(String path)

Obtain properties for the link represented by path, asynchronously. The link will not be followed.

lpropsSyncshared FileProps lpropsSync(String path)

Synchronous version of lprops()

mkdirshared Promise<Anything> mkdir(String path, String? perms = null, Boolean? createParents = null)

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.

If createParents is set to true then any non-existent parent directories of the directory will also be created.

The operation will fail if the directory already exists.

Parameters:
  • perms = null
  • createParents = null
mkdirSyncshared FileSystem mkdirSync(String path, String? perms = null, Boolean? createParents = null)

Synchronous version of mkdir()

Parameters:
  • perms = null
  • createParents = null
moveshared Promise<Anything> move(String from, String to)

Move a file from the path from to path to, asynchronously.

The move will fail if the destination already exists.

moveSyncshared FileSystem moveSync(String from, String to)

Synchronous version of move()

openshared Promise<AsyncFile> open(String path, String? perms = null, Boolean? read = null, Boolean? createNew = null, Boolean? write = null, Boolean? flush = null)

Open the file represented by path, asynchronously.

If read is true the file will be opened for reading. If write is true the file will be opened for writing.

If the file does not already exist and createNew is true it will be created with the permissions as specified by perms, otherwise the operation will fail.

If flush} is true then all writes will be automatically flushed through OS buffers to the underlying storage on each write.

Parameters:
  • perms = null
  • read = null
  • createNew = null
  • write = null
  • flush = null
openSyncshared AsyncFile openSync(String path, String? perms = null, Boolean? read = null, Boolean? createNew = null, Boolean? write = null, Boolean? flush = null)

Synchronous version of open()

Parameters:
  • perms = null
  • read = null
  • createNew = null
  • write = null
  • flush = null
propsshared Promise<FileProps> props(String path)

Obtain properties for the file represented by path, asynchronously. If the file is a link, the link will be followed.

propsSyncshared FileProps propsSync(String path)

Synchronous version of props()

readDirshared Promise<{String*}> readDir(String path, String? filter = null)

Read the contents of the directory specified by path, asynchronously.

The parameter filter is a regular expression. If filter 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:
  • filter = null
readDirSyncshared {String*} readDirSync(String path, String? filter = null)

Synchronous version of readDir()

Parameters:
  • filter = null
readFileshared Promise<Buffer> readFile(String path)

Reads the entire file as represented by the path path as a Buffer, asynchronously.

Do not user this method to read very large files or you risk running out of available RAM.

readFileSyncshared Buffer readFileSync(String path)

Synchronous version of readFile()

shared Promise<String> readSymlink(String link)

Returns the path representing the file that the symbolic link specified by link points to, asynchronously.

readSymlinkSyncshared String readSymlinkSync(String link)

Synchronous version of readSymlink()

shared Promise<Anything> symlink(String link, String existing)

Create a symbolic link on the file system from link to existing, asynchronously.

symlinkSyncshared FileSystem symlinkSync(String link, String existing)

Synchronous version of symlink()

truncateshared Promise<Anything> truncate(String path, Integer len)

Truncate the file represented by path to length len in bytes, asynchronously.

The operation will fail if the file does not exist or len is less than 0.

truncateSyncshared FileSystem truncateSync(String path, Integer len)

Synchronous version of truncate()

shared Promise<Anything> unlink(String link)

Unlinks the link on the file system represented by the path link, asynchronously.

unlinkSyncshared FileSystem unlinkSync(String link)

Synchronous version of unlink()

writeFileshared Promise<Anything> writeFile(String path, Buffer data)

Creates the file, and writes the specified data to the file represented by the path path, asynchronously.

writeFileSyncshared FileSystem writeFileSync(String path, Buffer data)

Synchronous version of writeFile()

Inherited Methods
Methods inherited from: Object
equals