Groovy Documentation

org.vertx.groovy.core.file
[Groovy] Class FileSystem

java.lang.Object
  org.vertx.groovy.core.file.FileSystem

class FileSystem

Contains a broad set of operations for manipulating files.

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

The asynchronous versions take an AsynchronousResultHandler 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

Authors:
Tim Fox


Property Summary
static java.io.FileSystem instance

 
Method Summary
void chmod(java.lang.String path, java.lang.String perms, java.lang.String dirPerms = null, groovy.lang.Closure handler)

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

void chmodSync(java.lang.String path, java.lang.String perms, java.lang.String dirPerms = null)

Synchronous version of chmod(String, String, String, Closure)

void copy(java.lang.String from, java.lang.String to, boolean recursive = false, groovy.lang.Closure handler)

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

void copySync(java.lang.String from, java.lang.String to, boolean recursive = false)

Synchronous version of copy(String, String, boolean, Closure)

void createFile(java.lang.String path, java.lang.String perms = null, groovy.lang.Closure handler)

Creates an empty file with the specified path, asynchronously.

void createFileSync(java.lang.String path, java.lang.String perms = null)

Synchronous version of createFile(String, String, Closure)

void delete(java.lang.String path, boolean recursive = false, groovy.lang.Closure handler)

Deletes the file represented by the specified path, asynchronously.

void deleteSync(java.lang.String path, boolean recursive)

Synchronous version of delete(String, boolean, Closure)

void exists(java.lang.String path, groovy.lang.Closure handler)

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

boolean existsSync(java.lang.String path)

Synchronous version of exists(String, Closure)

void fsProps(java.lang.String path, groovy.lang.Closure handler)

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

FileSystemProps fsPropsSync(java.lang.String path)

Synchronous version of fsProps(String, Closure)

void link(java.lang.String link, java.lang.String existing, groovy.lang.Closure handler)

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

void linkSync(java.lang.String link, java.lang.String existing)

Synchronous version of link(String, String, Closure)

void lprops(java.lang.String path, groovy.lang.Closure handler)

Obtain properties for the link represented by path, asynchronously.

FileProps lpropsSync(java.lang.String path)

Synchronous version of lprops(String, Closure)

void mkdir(java.lang.String path, java.lang.String perms = null, boolean createParents = false, groovy.lang.Closure handler)

Create the directory represented by path, asynchronously.

void mkdirSync(java.lang.String path, java.lang.String perms = null, boolean createParents = false)

Synchronous version of mkdir(String, String, boolean, Closure)

void move(java.lang.String from, java.lang.String to, groovy.lang.Closure handler)

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

void moveSync(java.lang.String from, java.lang.String to)

Synchronous version of move(String, String, Closure)

void open(java.lang.String path, java.lang.String perms = null, boolean read = true, boolean write = true, boolean createNew = true, boolean flush = false, groovy.lang.Closure handler)

Open the file represented by path, asynchronously.

AsyncFile openSync(java.lang.String path, java.lang.String perms = null, boolean read = true, boolean write = true, boolean createNew = true, boolean flush = false)

Synchronous version of open(String, String, boolean, boolean, boolean, boolean, Closure)

void props(java.lang.String path, groovy.lang.Closure handler)

Obtain properties for the file represented by path, asynchronously.

FileProps propsSync(java.lang.String path)

Synchronous version of props(String, Closure)

void readDir(java.lang.String path, java.lang.String filter = null, groovy.lang.Closure handler)

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

java.lang.String[] readDirSync(java.lang.String path, java.lang.String filter)

Synchronous version of readDir(String, String, Closure)

void readFile(java.lang.String path, groovy.lang.Closure handler)

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

Buffer readFileSync(java.lang.String path)

Synchronous version of readFile(String, Closure)

void readSymlink(java.lang.String link, groovy.lang.Closure handler)

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

java.lang.String readSymlinkSync(java.lang.String link)

Synchronous version of readSymlink(String, Closure)

void symlink(java.lang.String link, java.lang.String existing, groovy.lang.Closure handler)

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

void symlinkSync(java.lang.String link, java.lang.String existing)

Synchronous version of link(String, String, Closure)

void truncate(java.lang.String path, long len, groovy.lang.Closure handler)

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

void truncateSync(java.lang.String path, long len)

Synchronous version of truncate(String, long, Closure)

void unlink(java.lang.String link, groovy.lang.Closure handler)

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

void unlinkSync(java.lang.String link)

Synchronous version of unlink(String, Closure)

void writeFile(java.lang.String path, Buffer data, groovy.lang.Closure handler)

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

void writeFile(java.lang.String path, java.lang.String data, groovy.lang.Closure handler)

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

void writeFileSync(java.lang.String path, Buffer data)

Synchronous version of writeFile(String, Buffer, Closure)

void writeFileSync(java.lang.String path, java.lang.String data)

Synchronous version of writeFile(String, String, Closure)

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Property Detail

instance

static java.io.FileSystem instance


 
Method Detail

chmod

void chmod(java.lang.String path, java.lang.String perms, java.lang.String dirPerms = null, groovy.lang.Closure 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.


chmodSync

void chmodSync(java.lang.String path, java.lang.String perms, java.lang.String dirPerms = null)
Synchronous version of chmod(String, String, String, Closure)


copy

void copy(java.lang.String from, java.lang.String to, boolean recursive = false, groovy.lang.Closure 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.


copySync

void copySync(java.lang.String from, java.lang.String to, boolean recursive = false)
Synchronous version of copy(String, String, boolean, Closure)


createFile

void createFile(java.lang.String path, java.lang.String perms = null, groovy.lang.Closure handler)
Creates an empty file with the specified path, asynchronously.


createFileSync

void createFileSync(java.lang.String path, java.lang.String perms = null)
Synchronous version of createFile(String, String, Closure)


delete

void delete(java.lang.String path, boolean recursive = false, groovy.lang.Closure 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.


deleteSync

void deleteSync(java.lang.String path, boolean recursive)
Synchronous version of delete(String, boolean, Closure)


exists

void exists(java.lang.String path, groovy.lang.Closure handler)
Determines whether the file as specified by the path path exists, asynchronously.


existsSync

boolean existsSync(java.lang.String path)
Synchronous version of exists(String, Closure)


fsProps

void fsProps(java.lang.String path, groovy.lang.Closure handler)
Returns properties of the file-system being used by the specified path, asynchronously.


fsPropsSync

FileSystemProps fsPropsSync(java.lang.String path)
Synchronous version of fsProps(String, Closure)


link

void link(java.lang.String link, java.lang.String existing, groovy.lang.Closure handler)
Create a hard link on the file system from link to existing, asynchronously.


linkSync

void linkSync(java.lang.String link, java.lang.String existing)
Synchronous version of link(String, String, Closure)


lprops

void lprops(java.lang.String path, groovy.lang.Closure handler)
Obtain properties for the link represented by path, asynchronously. The link will not be followed.


lpropsSync

FileProps lpropsSync(java.lang.String path)
Synchronous version of lprops(String, Closure)


mkdir

void mkdir(java.lang.String path, java.lang.String perms = null, boolean createParents = false, groovy.lang.Closure 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.

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.


mkdirSync

void mkdirSync(java.lang.String path, java.lang.String perms = null, boolean createParents = false)
Synchronous version of mkdir(String, String, boolean, Closure)


move

void move(java.lang.String from, java.lang.String to, groovy.lang.Closure handler)
Move a file from the path from to path to, asynchronously.

The move will fail if the destination already exists.


moveSync

void moveSync(java.lang.String from, java.lang.String to)
Synchronous version of move(String, String, Closure)


open

void open(java.lang.String path, java.lang.String perms = null, boolean read = true, boolean write = true, boolean createNew = true, boolean flush = false, groovy.lang.Closure handler)
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.


openSync

AsyncFile openSync(java.lang.String path, java.lang.String perms = null, boolean read = true, boolean write = true, boolean createNew = true, boolean flush = false)
Synchronous version of open(String, String, boolean, boolean, boolean, boolean, Closure)


props

void props(java.lang.String path, groovy.lang.Closure handler)
Obtain properties for the file represented by path, asynchronously. If the file is a link, the link will be followed.


propsSync

FileProps propsSync(java.lang.String path)
Synchronous version of props(String, Closure)


readDir

void readDir(java.lang.String path, java.lang.String filter = null, groovy.lang.Closure 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.


readDirSync

java.lang.String[] readDirSync(java.lang.String path, java.lang.String filter)
Synchronous version of readDir(String, String, Closure)


readFile

void readFile(java.lang.String path, groovy.lang.Closure handler)
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.


readFileSync

Buffer readFileSync(java.lang.String path)
Synchronous version of readFile(String, Closure)


readSymlink

void readSymlink(java.lang.String link, groovy.lang.Closure handler)
Returns the path representing the file that the symbolic link specified by link points to, asynchronously.


readSymlinkSync

java.lang.String readSymlinkSync(java.lang.String link)
Synchronous version of readSymlink(String, Closure)


symlink

void symlink(java.lang.String link, java.lang.String existing, groovy.lang.Closure handler)
Create a symbolic link on the file system from link to existing, asynchronously.


symlinkSync

void symlinkSync(java.lang.String link, java.lang.String existing)
Synchronous version of link(String, String, Closure)


truncate

void truncate(java.lang.String path, long len, groovy.lang.Closure 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.


truncateSync

void truncateSync(java.lang.String path, long len)
Synchronous version of truncate(String, long, Closure)


unlink

void unlink(java.lang.String link, groovy.lang.Closure handler)
Unlinks the link on the file system represented by the path link, asynchronously.


unlinkSync

void unlinkSync(java.lang.String link)
Synchronous version of unlink(String, Closure)


writeFile

void writeFile(java.lang.String path, Buffer data, groovy.lang.Closure handler)
Creates the file, and writes the specified Buffer data to the file represented by the path path, asynchronously.


writeFile

void writeFile(java.lang.String path, java.lang.String data, groovy.lang.Closure handler)
Creates the file, and writes the specified String data to the file represented by the path path, asynchronously.


writeFileSync

void writeFileSync(java.lang.String path, Buffer data)
Synchronous version of writeFile(String, Buffer, Closure)


writeFileSync

void writeFileSync(java.lang.String path, java.lang.String data)
Synchronous version of writeFile(String, String, Closure)


 

Groovy Documentation