Contains a broad set of operations for manipulating files on the file system.

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.

The blocking versions are named xxxBlocking and return the results, or throw exceptions directly. In many cases, depending on the operating system and file system some of the potentially blocking operations can return quickly, which is why we provide them, but it's highly recommended that you test how long they take to return in your particular application before using them on an event loop.

Please consult the documentation for more information on file system support.

no subtypes hierarchy

Initializer
FileSystem(FileSystem unknown)
Inherited Attributes
Attributes inherited from: Object
hash, string
Methods
chmodshared default FileSystem chmod(String path, String perms, Anything(Throwable?) handler)

Change the permissions on the file represented by path to perms, asynchronously.

The permission String takes the form rwxr-x— as specified here.

Parameters:
  • path

    the path to the file

  • perms

    the permissions string

  • handler

    the handler that will be called on completion

chmodBlockingshared default FileSystem chmodBlocking(String path, String perms)

Blocking version of #chmod(String, String, Handler)

chmodRecursiveshared default FileSystem chmodRecursive(String path, String perms, String dirPerms, Anything(Throwable?) handler)

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:
  • path

    the path to the file

  • perms

    the permissions string

  • dirPerms

    the directory permissions

  • handler

    the handler that will be called on completion

chmodRecursiveBlockingshared default FileSystem chmodRecursiveBlocking(String path, String perms, String dirPerms)

Blocking version of chmodRecursive

chownshared default FileSystem chown(String path, String? user, String? group, Anything(Throwable?) handler)

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

Parameters:
  • path

    the path to the file

  • user

    the user name, null will not change the user name

  • group

    the user group, null will not change the user group name

  • handler

    the handler that will be called on completion

chownBlockingshared default FileSystem chownBlocking(String path, String? user, String? group)

Blocking version of

copyshared default FileSystem copy(String from, String to, Anything(Throwable?) handler)

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

The copy will fail if the destination already exists.

Parameters:
  • from

    the path to copy from

  • to

    the path to copy to

  • handler

    the handler that will be called on completion

copyshared default FileSystem copy(String from, String to, CopyOptions options, Anything(Throwable?) handler)

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

Parameters:
  • from

    the path to copy from

  • to

    the path to copy to

  • options

    options describing how the file should be copied

  • handler

    the handler that will be called on completion

copyBlockingshared default FileSystem copyBlocking(String from, String to)

Blocking version of copy

copyRecursiveshared default FileSystem copyRecursive(String from, String to, Boolean recursive, Anything(Throwable?) handler)

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:
  • from

    the path to copy from

  • to

    the path to copy to

  • handler

    the handler that will be called on completion

copyRecursiveBlockingshared default FileSystem copyRecursiveBlocking(String from, String to, Boolean recursive)

Blocking version of copyRecursive

createFileshared default FileSystem createFile(String path, Anything(Throwable?) handler)

Creates an empty file with the specified path, asynchronously.

Parameters:
  • path

    path to the file

  • handler

    the handler that will be called on completion

createFileshared default FileSystem createFile(String path, String perms, Anything(Throwable?) handler)

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

Parameters:
  • path

    path to the file

  • perms

    the permissions string

  • handler

    the handler that will be called on completion

createFileBlockingshared default FileSystem createFileBlocking(String path)

Blocking version of createFile

createFileBlockingshared default FileSystem createFileBlocking(String path, String perms)

Blocking version of createFile

deleteshared default FileSystem delete(String path, Anything(Throwable?) handler)

Deletes the file represented by the specified path, asynchronously.

Parameters:
  • path

    path to the file

  • handler

    the handler that will be called on completion

deleteBlockingshared default FileSystem deleteBlocking(String path)

Blocking version of delete

deleteRecursiveshared default FileSystem deleteRecursive(String path, Boolean recursive, Anything(Throwable?) handler)

Deletes the file represented by the specified path, asynchronously.

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

Parameters:
  • path

    path to the file

  • recursive

    delete recursively?

  • handler

    the handler that will be called on completion

deleteRecursiveBlockingshared default FileSystem deleteRecursiveBlocking(String path, Boolean recursive)

Blocking version of deleteRecursive

existsshared default FileSystem exists(String path, Anything(Throwable|Boolean) handler)

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

Parameters:
  • path

    path to the file

  • handler

    the handler that will be called on completion

existsBlockingshared default Boolean existsBlocking(String path)

Blocking version of exists

fsPropsshared default FileSystem fsProps(String path, Anything(Throwable|FileSystemProps) handler)

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

Parameters:
  • path

    path to anywhere on the filesystem

  • handler

    the handler that will be called on completion

fsPropsBlockingshared default FileSystemProps fsPropsBlocking(String path)

Blocking version of fsProps

shared default FileSystem link(String link, String existing, Anything(Throwable?) handler)

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

Parameters:
  • link

    the link

  • existing

    the link destination

  • handler

    the handler that will be called on completion

linkBlockingshared default FileSystem linkBlocking(String link, String existing)

Blocking version of link

lpropsshared default FileSystem lprops(String path, Anything(Throwable|FileProps) handler)

Obtain properties for the link represented by path, asynchronously.

The link will not be followed.

Parameters:
  • path

    the path to the file

  • handler

    the handler that will be called on completion

lpropsBlockingshared default FileProps lpropsBlocking(String path)

Blocking version of lprops

mkdirshared default FileSystem mkdir(String path, Anything(Throwable?) handler)

Create the directory represented by path, asynchronously.

The operation will fail if the directory already exists.

Parameters:
  • path

    path to the file

  • handler

    the handler that will be called on completion

mkdirshared default FileSystem mkdir(String path, String perms, Anything(Throwable?) handler)

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:
  • path

    path to the file

  • perms

    the permissions string

  • handler

    the handler that will be called on completion

mkdirBlockingshared default FileSystem mkdirBlocking(String path)

Blocking version of mkdir

mkdirBlockingshared default FileSystem mkdirBlocking(String path, String perms)

Blocking version of mkdir

mkdirsshared default FileSystem mkdirs(String path, Anything(Throwable?) handler)

Create the directory represented by path and any non existent parents, asynchronously.

The operation will fail if the directory already exists.

Parameters:
  • path

    path to the file

  • handler

    the handler that will be called on completion

mkdirsshared default FileSystem mkdirs(String path, String perms, Anything(Throwable?) handler)

Create the directory represented by path and 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:
  • path

    path to the file

  • perms

    the permissions string

  • handler

    the handler that will be called on completion

mkdirsBlockingshared default FileSystem mkdirsBlocking(String path)

Blocking version of mkdirs

mkdirsBlockingshared default FileSystem mkdirsBlocking(String path, String perms)

Blocking version of mkdirs

moveshared default FileSystem move(String from, String to, Anything(Throwable?) handler)

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

The move will fail if the destination already exists.

Parameters:
  • from

    the path to copy from

  • to

    the path to copy to

  • handler

    the handler that will be called on completion

moveshared default FileSystem move(String from, String to, CopyOptions options, Anything(Throwable?) handler)

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

Parameters:
  • from

    the path to copy from

  • to

    the path to copy to

  • options

    options describing how the file should be copied

  • handler

    the handler that will be called on completion

moveBlockingshared default FileSystem moveBlocking(String from, String to)

Blocking version of move

openshared default FileSystem open(String path, OpenOptions options, Anything(Throwable|AsyncFile) handler)

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:
  • path

    path to the file

  • options

    options describing how the file should be opened

openBlockingshared default AsyncFile openBlocking(String path, OpenOptions options)

Blocking version of open

propsshared default FileSystem props(String path, Anything(Throwable|FileProps) handler)

Obtain properties for the file represented by path, asynchronously.

If the file is a link, the link will be followed.

Parameters:
  • path

    the path to the file

  • handler

    the handler that will be called on completion

propsBlockingshared default FileProps propsBlocking(String path)

Blocking version of props

readDirshared default FileSystem readDir(String path, Anything(Throwable|List<String>) handler)

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

The result is an array of String representing the paths of the files inside the directory.

Parameters:
  • path

    path to the file

  • handler

    the handler that will be called on completion

readDirshared default FileSystem readDir(String path, String filter, Anything(Throwable|List<String>) handler)

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:
  • path

    path to the directory

  • filter

    the filter expression

  • handler

    the handler that will be called on completion

readDirBlockingshared default List<String> readDirBlocking(String path)

Blocking version of readDir

readDirBlockingshared default List<String> readDirBlocking(String path, String filter)

Blocking version of readDir

readFileshared default FileSystem readFile(String path, Anything(Throwable|Buffer) handler)

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

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

Parameters:
  • path

    path to the file

  • handler

    the handler that will be called on completion

readFileBlockingshared default Buffer readFileBlocking(String path)

Blocking version of readFile

shared default FileSystem readSymlink(String link, Anything(Throwable|String) handler)

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

Parameters:
  • link

    the link

  • handler

    the handler that will be called on completion

readSymlinkBlockingshared default String readSymlinkBlocking(String link)

Blocking version of readSymlink

shared default FileSystem symlink(String link, String existing, Anything(Throwable?) handler)

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

Parameters:
  • link

    the link

  • existing

    the link destination

  • handler

    the handler that will be called on completion

symlinkBlockingshared default FileSystem symlinkBlocking(String link, String existing)

Blocking version of link

truncateshared default FileSystem truncate(String path, Integer len, Anything(Throwable?) handler)

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 zero.

Parameters:
  • path

    the path to the file

  • len

    the length to truncate it to

  • handler

    the handler that will be called on completion

truncateBlockingshared default FileSystem truncateBlocking(String path, Integer len)

Blocking version of truncate

shared default FileSystem unlink(String link, Anything(Throwable?) handler)

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

Parameters:
  • link

    the link

  • handler

    the handler that will be called on completion

unlinkBlockingshared default FileSystem unlinkBlocking(String link)

Blocking version of unlink

writeFileshared default FileSystem writeFile(String path, Buffer data, Anything(Throwable?) handler)

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

Parameters:
  • path

    path to the file

  • handler

    the handler that will be called on completion

writeFileBlockingshared default FileSystem writeFileBlocking(String path, Buffer data)

Blocking version of writeFile

Inherited Methods
Methods inherited from: Object
equals