Package core :: Module file_system :: Class FileSystem

[hide private]
[frames] | no frames]

# Class FileSystem

source code

    object --+
             |
            FileSystem

Represents the file-system and 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 as a final argument which is called when the operation completes or an error occurs. The handler is called with two arguments; the first an exception, this will be nil if the operation has succeeded. The second is the result - this will be nil if the operation failed or there was no result to return. The synchronous versions return the results, or throw exceptions directly.

Static Methods | [hide private]

java_file_system() | source code

copy(frm, to, handler) Copy a file, asynchronously. | source code

copy_sync(frm, to) Synchronous version of FileSystem.copy | source code

copy_recursive(frm, to, handler) Copy a file recursively, asynchronously. | source code

copy_recursive_sync(frm, to) Synchronous version of FileSystem.copy_recursive | source code

move(frm, to, handler) Move a file, asynchronously. | source code

move_sync(frm, to) Synchronous version of FileSystem.move | source code

truncate(path, len, handler) Truncate a file, asynchronously. | source code

truncate_sync(path, len) Synchronous version of FileSystem.truncate | source code

chmod(path, perms, dir_perms=None, handler=None) Change the permissions on a file, asynchronously. | source code

chmod_sync(path, perms, dir_perms=None) Synchronous version of FileSystem.chmod | source code

props(path, handler) Get file properties for a file, asynchronously. | source code

props_sync(path) Synchronous version of FileSystem.props | source code

link(link, existing, handler) Create a hard link, asynchronously.. | source code

link_sync(link, existing) Synchronous version of FileSystem.link | source code

sym_link(link, existing, handler) Create a symbolic link, asynchronously. | source code

sym_link_sync(link, existing) Synchronous version of FileSystem.sym_link | source code

unlink(link, handler) Unlink a hard link. | source code

unlinkSync(link) Synchronous version of FileSystem.unlink | source code

read_sym_link(link, handler) Read a symbolic link, asynchronously. | source code

read_sym_link_sync(link) Synchronous version of FileSystem.read_sym_link | source code

delete(path, handler) Delete a file on the file system, asynchronously. | source code

delete_sync(path) Synchronous version of FileSystem.delete | source code

delete_recursive(path, handler) Delete a file on the file system recursively, asynchronously. | source code

delete_recursive_sync(path) Synchronous version of FileSystem.delete_recursive | source code

mkdir(path, perms=None, handler=None) Create a directory, asynchronously. | source code

mkdir_sync(path, perms=None) Synchronous version of FileSystem.mkdir | source code

mkdir_with_parents(path, perms=None, handler=None) Create a directory, and create all it's parent directories if they do not already exist, asynchronously. | source code

mkdir_with_parents_sync(path, perms=None) Synchronous version of FileSystem.mkdir_with_parents | source code

read_dir(path, filter=None, handler=None) Read a directory, i.e. | source code

read_dir_sync(path, filter=None) Synchronous version of FileSystem.read_dir | source code

read_file_as_buffer(path, handler) Read the contents of an entire file as a Buffer, asynchronously. | source code

read_file_as_buffer_sync(path) Synchronous version of FileSystem.read_file_as_buffer | source code

write_buffer_to_file(path, buffer, handler) Write a as the entire contents of a file, asynchronously. | source code

write_buffer_to_file_sync(path, buffer) Synchronous version of FileSystem.write_buffer_to_file | source code

open(path, perms=None, read=True, write=True, create_new=True, flush=False, handler=None) Open a file on the file system, asynchronously. | source code

open_sync(path, perms=None, read=True, write=True, create_new=True, flush=False) Synchronous version of FileSystem.open | source code

create_file(path, perms=None, handler=None) Create a new empty file, asynchronously. | source code

create_file_sync(path, perms=None) Synchronous version of FileSystem.create_file | source code

exists(path, handler) Check if a file exists, asynchronously. | source code

exists_sync(path) Synchronous version of FileSystem.exists | source code

fs_props(path, handler) Get properties for the file system, asynchronously. | source code

fs_props_sync(path) Synchronous version of FileSystem.fs_props | source code

Method Details | [hide private]

### copy(frm, to, handler)
Static Method

source code

Copy a file, asynchronously. The copy will fail if from does not exist, or if to already exists.

Keyword arguments:

Parameters:
  - `frm` - path of file to copy
  - `to` - path of file to copy to
  - `handler` - the handler which is called on completion.

### copy_recursive(frm, to, handler)
Static Method

source code

Copy a file recursively, asynchronously. The copy will fail if from does not exist, or if to already exists and is not empty. If the source is a directory all contents of the directory will be copied recursively, i.e. the entire directory tree is copied.

Keyword arguments:

Parameters:
  - `frm` - path of file to copy
  - `to` - path of file to copy to
  - `handler` - the function to call when complete

### move(frm, to, handler)
Static Method

source code

Move a file, asynchronously. The move will fail if from does not exist, or if to already exists.

Keyword arguments:

Parameters:
  - `frm` - Path of file to move
  - `to` - Path of file to move to
  - `handler` - the function to call when complete

### truncate(path, len, handler)
Static Method

source code

Truncate a file, asynchronously. The move will fail if path does not exist.

Keyword arguments:

Parameters:
  - `path` - Path of file to truncate
  - `len` - Length to truncate file to. Will fail if len < 0. If len > file size then will do nothing.
  - `handler` - the function to call when complete

### chmod(path, perms, dir_perms=None, handler=None)
Static Method

source code

Change the permissions on a file, asynchronously. If the file is directory then all contents will also have their permissions changed recursively.

Keyword arguments:

Parameters:
  - `path` - path of file to change permissions
  - `perms` - a permission string of the form rwxr-x--- as specified in http://download.oracle.com/javase/7/docs/api/java/nio/file/attribute/PosixFilePermissions.html. This is used to set the permissions for any regular files (not directories).
  - `dir_perms` - a permission string of the form rwxr-x---. Used to set permissions for regular files.
  - `handler` - the function to call when complete

### props(path, handler)
Static Method

source code

Get file properties for a file, asynchronously.

Keyword arguments:

Parameters:
  - `path` - path to file
  - `handler` - the function to call when complete

### link(link, existing, handler)
Static Method

source code

Create a hard link, asynchronously..

Keyword arguments:

Parameters:
  - `link` - path of the link to create.
  - `existing` - path of where the link points to.
  - `handler` - the function to call when complete

### sym_link(link, existing, handler)
Static Method

source code

Create a symbolic link, asynchronously.

Keyword arguments:

Parameters:
  - `link` - Path of the link to create.
  - `existing` - Path of where the link points to.
  - `handler` - the function to call when complete

### unlink(link, handler)
Static Method

source code

Unlink a hard link.

Keyword arguments:

Parameters:
  - `link` - path of the link to unlink.

### read_sym_link(link, handler)
Static Method

source code

Read a symbolic link, asynchronously. I.e. tells you where the symbolic link points.

Keyword arguments:

Parameters:
  - `link` - path of the link to read.
  - `handler` - the function to call when complete

### delete(path, handler)
Static Method

source code

Delete a file on the file system, asynchronously. The delete will fail if the file does not exist, or is a directory and is not empty.

Keyword arguments:

Parameters:
  - `path` - path of the file to delete.
  - `handler` - the function to call when complete

### delete_recursive(path, handler)
Static Method

source code

Delete a file on the file system recursively, asynchronously. The delete will fail if the file does not exist. If the file is a directory the entire directory contents will be deleted recursively.

Keyword arguments:

Parameters:
  - `path` - path of the file to delete.
  - `handler` - the function to call when complete

### mkdir(path, perms=None, handler=None)
Static Method

source code

Create a directory, asynchronously. The create will fail if the directory already exists, or if it contains parent directories which do not already exist.

Keyword arguments:

Parameters:
  - `path` - path of the directory to create.
  - `perms` - a permission string of the form rwxr-x--- to give directory.
  - `handler` - the function to call when complete

### mkdir_with_parents(path, perms=None, handler=None)
Static Method

source code

Create a directory, and create all it's parent directories if they do not already exist, asynchronously. The create will fail if the directory already exists.

Keyword arguments:

Parameters:
  - `path` - path of the directory to create.
  - `perms` - a permission string of the form rwxr-x--- to give the created directory(ies).

### read_dir(path, filter=None, handler=None)
Static Method

source code

Read a directory, i.e. list it's contents, asynchronously. The read will fail if the directory does not exist.

Keyword arguments:

Parameters:
  - `path` - path of the directory to read.
  - `filter` - a regular expression to filter out the contents of the directory. If the filter is not nil then only files which match the filter will be returned.
  - `handler` - the function to call when complete

### read_file_as_buffer(path, handler)
Static Method

source code

Read the contents of an entire file as a Buffer, asynchronously.

Keyword arguments:

Parameters:
  - `path` - path of the file to read.
  - `handler` - the function to call when complete

### write_buffer_to_file(path, buffer, handler)
Static Method

source code

Write a as the entire contents of a file, asynchronously.

Keyword arguments:

Parameters:
  - `path` - path of the file to write.
  - `buffer` - the Buffer to write
  - `handler` - the function to call when complete

### open(path, perms=None, read=True, write=True, create_new=True, flush=False, handler=None)
Static Method

source code

Open a file on the file system, asynchronously.

Keyword arguments:

Parameters:
  - `path` - path of the file to open.
  - `perms` - if the file does not exist and create_new is true, then the file will be created with these permissions.
  - `read` - open the file for reading?
  - `write` - open the file for writing?
  - `create_new` - Create the file if it doesn't already exist?
  - `flush` - whenever any data is written to the file, flush all changes to permanent storage immediately?
  - `handler` - the function to call when complete

### create_file(path, perms=None, handler=None)
Static Method

source code

Create a new empty file, asynchronously.

Keyword arguments:

Parameters:
  - `path` - path of the file to create.
  - `perms` - the file will be created with these permissions.
  - `handler` - the function to call when complete

### exists(path, handler)
Static Method

source code

Check if a file exists, asynchronously.

Keyword arguments:

Parameters:
  - `path` - Path of the file to check.
  - `handler` - the function to call when complete

### fs_props(path, handler)
Static Method

source code

Get properties for the file system, asynchronously.

Keyword arguments:

Parameters:
  - `path` - Path in the file system.
  - `handler` - the function to call when complete