Groovy Documentation

org.linkedin.groovy.util.io.fs
[Groovy] Interface FileSystem


interface FileSystem

Abstraction to the filesystem

Authors:
ypujante@linkedin.com


Method Summary
java.lang.Object chmod(java.lang.Object file, java.lang.Object perm)

Resource cp(java.lang.Object from, java.lang.Object to)

Copy from to to...

Resource createTempDir()

Create a temporary directory

Resource createTempDir(java.lang.Object args)

Create a temporary directory

java.lang.Object deserializeFromFile(java.lang.Object file)

Resource eachChildRecurse(java.lang.Object dir, java.lang.Object closure)

java.lang.Object findAll(java.lang.Object dir, java.lang.Object closure)

Resource getRoot()

the root of the file system.

Resource getTmpRoot()

the tmp root of the file system.

java.lang.Object ls(java.lang.Object dir, groovy.lang.Closure closure)

@param dir starting point for listing

java.lang.Object ls(java.lang.Object dir)

list all the files under the provided directory (or root if not provided) (not recursive)

java.lang.Object ls()

list all the files under root only (not recursive)

java.lang.Object ls(groovy.lang.Closure closure)

Same as the other ls, but starts at root

Resource mkdirs(java.lang.Object dir)

Resource mv(java.lang.Object from, java.lang.Object to)

Move from to to...

FileSystem newFileSystem(java.lang.Object file)

Returns a new file system where the root is set to the provided file (effectively making it a sub file system of this one...)

FileSystem newFileSystem(java.lang.Object newRoot, java.lang.Object newTmpRoot)

Returns a new file system where the root is set to the provided file (effectively making it a sub file system of this one...)

java.lang.String readContent(java.lang.Object file)

reads the content from the file and return it as a String

void rm(java.lang.Object file)

void rmEmptyDirs(java.lang.Object dir)

Remove all empty directories (that are children (recurisvely) of the provided directory).

void rmdirs(java.lang.Object dir)

Resource saveContent(java.lang.Object file, java.lang.String content)

creates a file and populate its content with the provided (String) content

Resource serializeToFile(java.lang.Object file, java.lang.Object serializable)

Resource tempFile(java.lang.Object args)

Creates a temp file:

Resource tempFile()

Creates a temp file with all default values

Resource toResource(java.lang.Object file)

Returns a resource relative to this filesystem

java.lang.Object withInputStream(java.lang.Object file, java.lang.Object closure)

java.lang.Object withObjectInputStream(java.lang.Object file, java.lang.Object closure)

java.lang.Object withObjectOutputStream(java.lang.Object file, java.lang.Object closure)

java.lang.Object withOutputStream(java.lang.Object file, java.lang.Object closure)

 

Method Detail

chmod

java.lang.Object chmod(java.lang.Object file, java.lang.Object perm)


cp

Resource cp(java.lang.Object from, java.lang.Object to)
Copy from to to...
Returns:
to as a resource


createTempDir

Resource createTempDir()
Create a temporary directory


createTempDir

Resource createTempDir(java.lang.Object args)
Create a temporary directory
See Also:
for details on the options


deserializeFromFile

java.lang.Object deserializeFromFile(java.lang.Object file)


eachChildRecurse

Resource eachChildRecurse(java.lang.Object dir, java.lang.Object closure)


findAll

java.lang.Object findAll(java.lang.Object dir, java.lang.Object closure)


getRoot

Resource getRoot()
the root of the file system. All files created or returned by any methods on this class will be under this root (except for temp files)


getTmpRoot

Resource getTmpRoot()
the tmp root of the file system. All temp files created will be under this root


ls

java.lang.Object ls(java.lang.Object dir, groovy.lang.Closure closure)
Parameters:
dir - starting point for listing
closure - the closure (dsl) containing include(name: '') and exclude(name: '') values


ls

java.lang.Object ls(java.lang.Object dir)
list all the files under the provided directory (or root if not provided) (not recursive)


ls

java.lang.Object ls()
list all the files under root only (not recursive)


ls

java.lang.Object ls(groovy.lang.Closure closure)
Same as the other ls, but starts at root


mkdirs

Resource mkdirs(java.lang.Object dir)


mv

Resource mv(java.lang.Object from, java.lang.Object to)
Move from to to... (rename if file)
Returns:
to as a resource


newFileSystem

FileSystem newFileSystem(java.lang.Object file)
Returns a new file system where the root is set to the provided file (effectively making it a sub file system of this one...)


newFileSystem

FileSystem newFileSystem(java.lang.Object newRoot, java.lang.Object newTmpRoot)
Returns a new file system where the root is set to the provided file (effectively making it a sub file system of this one...)


readContent

java.lang.String readContent(java.lang.Object file)
reads the content from the file and return it as a String


rm

void rm(java.lang.Object file)


rmEmptyDirs

void rmEmptyDirs(java.lang.Object dir)
Remove all empty directories (that are children (recurisvely) of the provided directory).


rmdirs

void rmdirs(java.lang.Object dir)


saveContent

Resource saveContent(java.lang.Object file, java.lang.String content)
creates a file and populate its content with the provided (String) content


serializeToFile

Resource serializeToFile(java.lang.Object file, java.lang.Object serializable)


tempFile

Resource tempFile(java.lang.Object args)
Creates a temp file:
Parameters:
args.destdir - where the file should be created (optional)
args.prefix - a prefix for the file (optional)
args.suffix - a suffix for the file (optional)
args.deleteonexit - if the temp file should be deleted on exit (default to
args.createParents - if the parent directories should be created (default to true)
Returns:
a file (note that it is just a file object and that the actual file has *not* been created and the parents may have been depending on the args.createParents value)


tempFile

Resource tempFile()
Creates a temp file with all default values


toResource

Resource toResource(java.lang.Object file)
Returns a resource relative to this filesystem


withInputStream

java.lang.Object withInputStream(java.lang.Object file, java.lang.Object closure)


withObjectInputStream

java.lang.Object withObjectInputStream(java.lang.Object file, java.lang.Object closure)


withObjectOutputStream

java.lang.Object withObjectOutputStream(java.lang.Object file, java.lang.Object closure)


withOutputStream

java.lang.Object withOutputStream(java.lang.Object file, java.lang.Object closure)


 

Groovy Documentation