vertx / io.vertx.core.file / FileSystem

FileSystem

interface FileSystem

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.

Author
Tim Fox

Functions

chmod

abstract fun chmod(path: String, perms: String, handler: Handler<AsyncResult<Void>>): FileSystem

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

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

chmodBlocking

abstract fun chmodBlocking(path: String, perms: String): FileSystem

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

chmodRecursive

abstract fun chmodRecursive(path: String, perms: String, dirPerms: String, handler: Handler<AsyncResult<Void>>): FileSystem

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.

chmodRecursiveBlocking

abstract fun chmodRecursiveBlocking(path: String, perms: String, dirPerms: String): FileSystem

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

chown

abstract fun chown(path: String, user: String, group: String, handler: Handler<AsyncResult<Void>>): FileSystem

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

chownBlocking

abstract fun chownBlocking(path: String, user: String, group: String): FileSystem

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

copy

abstract fun copy(from: String, to: String, handler: Handler<AsyncResult<Void>>): FileSystem

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

The copy will fail if the destination already exists.

abstract fun copy(from: String, to: String, options: CopyOptions, handler: Handler<AsyncResult<Void>>): FileSystem

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

copyBlocking

abstract fun copyBlocking(from: String, to: String): FileSystem

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

copyRecursive

abstract fun copyRecursive(from: String, to: String, recursive: Boolean, handler: Handler<AsyncResult<Void>>): FileSystem

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.

copyRecursiveBlocking

abstract fun copyRecursiveBlocking(from: String, to: String, recursive: Boolean): FileSystem

Blocking version of #copyRecursive(String, String, boolean, Handler)

createFile

abstract fun createFile(path: String, handler: Handler<AsyncResult<Void>>): FileSystem

Creates an empty file with the specified path, asynchronously.

abstract fun createFile(path: String, perms: String, handler: Handler<AsyncResult<Void>>): FileSystem

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

createFileBlocking

abstract fun createFileBlocking(path: String): FileSystem

Blocking version of #createFile(String, Handler)

abstract fun createFileBlocking(path: String, perms: String): FileSystem

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

delete

abstract fun delete(path: String, handler: Handler<AsyncResult<Void>>): FileSystem

Deletes the file represented by the specified path, asynchronously.

deleteBlocking

abstract fun deleteBlocking(path: String): FileSystem

Blocking version of #delete(String, Handler)

deleteRecursive

abstract fun deleteRecursive(path: String, recursive: Boolean, handler: Handler<AsyncResult<Void>>): FileSystem

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.

deleteRecursiveBlocking

abstract fun deleteRecursiveBlocking(path: String, recursive: Boolean): FileSystem

Blocking version of #deleteRecursive(String, boolean, Handler)

exists

abstract fun exists(path: String, handler: Handler<AsyncResult<Boolean>>): FileSystem

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

existsBlocking

abstract fun existsBlocking(path: String): Boolean

Blocking version of #exists(String, Handler)

fsProps

abstract fun fsProps(path: String, handler: Handler<AsyncResult<FileSystemProps>>): FileSystem

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

fsPropsBlocking

abstract fun fsPropsBlocking(path: String): FileSystemProps

Blocking version of #fsProps(String, Handler)

link

abstract fun link(link: String, existing: String, handler: Handler<AsyncResult<Void>>): FileSystem

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

linkBlocking

abstract fun linkBlocking(link: String, existing: String): FileSystem

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

lprops

abstract fun lprops(path: String, handler: Handler<AsyncResult<FileProps>>): FileSystem

Obtain properties for the link represented by path, asynchronously.

The link will not be followed.

lpropsBlocking

abstract fun lpropsBlocking(path: String): FileProps

Blocking version of #lprops(String, Handler)

mkdir

abstract fun mkdir(path: String, handler: Handler<AsyncResult<Void>>): FileSystem

Create the directory represented by path, asynchronously.

The operation will fail if the directory already exists.

abstract fun mkdir(path: String, perms: String, handler: Handler<AsyncResult<Void>>): FileSystem

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.

mkdirBlocking

abstract fun mkdirBlocking(path: String): FileSystem

Blocking version of #mkdir(String, Handler)

abstract fun mkdirBlocking(path: String, perms: String): FileSystem

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

mkdirs

abstract fun mkdirs(path: String, handler: Handler<AsyncResult<Void>>): FileSystem

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

The operation will fail if the directory already exists.

abstract fun mkdirs(path: String, perms: String, handler: Handler<AsyncResult<Void>>): FileSystem

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.

mkdirsBlocking

abstract fun mkdirsBlocking(path: String): FileSystem

Blocking version of #mkdirs(String, Handler)

abstract fun mkdirsBlocking(path: String, perms: String): FileSystem

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

move

abstract fun move(from: String, to: String, handler: Handler<AsyncResult<Void>>): FileSystem

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

The move will fail if the destination already exists.

abstract fun move(from: String, to: String, options: CopyOptions, handler: Handler<AsyncResult<Void>>): FileSystem

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

moveBlocking

abstract fun moveBlocking(from: String, to: String): FileSystem

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

open

abstract fun open(path: String, options: OpenOptions, handler: Handler<AsyncResult<AsyncFile>>): FileSystem

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.

openBlocking

abstract fun openBlocking(path: String, options: OpenOptions): AsyncFile

Blocking version of #open(String, io.vertx.core.file.OpenOptions, Handler)

props

abstract fun props(path: String, handler: Handler<AsyncResult<FileProps>>): FileSystem

Obtain properties for the file represented by path, asynchronously.

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

propsBlocking

abstract fun propsBlocking(path: String): FileProps

Blocking version of #props(String, Handler)

readDir

abstract fun readDir(path: String, handler: Handler<AsyncResult<MutableList<String>>>): FileSystem

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.

abstract fun readDir(path: String, filter: String, handler: Handler<AsyncResult<MutableList<String>>>): FileSystem

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.

readDirBlocking

abstract fun readDirBlocking(path: String): MutableList<String>

Blocking version of #readDir(String, Handler)

abstract fun readDirBlocking(path: String, filter: String): MutableList<String>

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

readFile

abstract fun readFile(path: String, handler: Handler<AsyncResult<Buffer>>): FileSystem

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

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

readFileBlocking

abstract fun readFileBlocking(path: String): Buffer

Blocking version of #readFile(String, Handler)

readSymlink

abstract fun readSymlink(link: String, handler: Handler<AsyncResult<String>>): FileSystem

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

readSymlinkBlocking

abstract fun readSymlinkBlocking(link: String): String

Blocking version of #readSymlink(String, Handler)

symlink

abstract fun symlink(link: String, existing: String, handler: Handler<AsyncResult<Void>>): FileSystem

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

symlinkBlocking

abstract fun symlinkBlocking(link: String, existing: String): FileSystem

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

truncate

abstract fun truncate(path: String, len: Long, handler: Handler<AsyncResult<Void>>): FileSystem

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.

truncateBlocking

abstract fun truncateBlocking(path: String, len: Long): FileSystem

Blocking version of #truncate(String, long, Handler)

unlink

abstract fun unlink(link: String, handler: Handler<AsyncResult<Void>>): FileSystem

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

unlinkBlocking

abstract fun unlinkBlocking(link: String): FileSystem

Blocking version of #unlink(String, Handler)

writeFile

abstract fun writeFile(path: String, data: Buffer, handler: Handler<AsyncResult<Void>>): FileSystem

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

writeFileBlocking

abstract fun writeFileBlocking(path: String, data: Buffer): FileSystem

Blocking version of #writeFile(String, Buffer, Handler)