core.file_system | index

`# Copyright 2011 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.`

Modules

``

core | datetime |  |

Classes

``

__builtin__.object
  AsyncFile
  FSProps
  FileProps
  FileSystem
core.streams.ReadStream(__builtin__.object)
  AsyncFileReadStream
core.streams.WriteStream(__builtin__.object)
  AsyncFileWriteStream
org.vertx.java.core.AsyncResultHandler(org.vertx.java.core.Handler, java.lang.Object)
  org.python.proxies.core.file_system$FSWrappedHandler$10(org.vertx.java.core.AsyncResultHandler, java.lang.Object)
    FSWrappedHandler

class AsyncFile(__builtin__.object)
`` | `Represents a file on the file-system which can be read from, or written to asynchronously. Methods also exist to get a read stream or a write stream on the file. This allows the data to be pumped to and from other streams, e.g. an HttpClientRequest instance, using the Pump class`

Methods defined here:

__init__(self, java_obj)

close(self, handler)
  `Close the file, asynchronously.`

flush(self)
  `Flush any writes made to this file to underlying persistent storage, asynchronously.
  If the file was opened with flush set to true then calling this method will have no effect.
  Keyword arguments:
  @param handler: the handler which is called on completion.`

read(self, buffer, offset, position, length, handler)
  `Reads some data from a file into a buffer, asynchronously.
  When multiple reads are invoked on the same file
  there are no guarantees as to order in which those reads actually occur.
  Keyword arguments
  @param buffer: the buffer into which the data which is read is written.
  @param offset: the position in the buffer where to start writing the data.
  @param position: the position in the file where to read the data.
  @param length: the number of bytes to read.`

write(self, buffer, position, handler)
  `Write a Buffer to the file, asynchronously.
  When multiple writes are invoked on the same file
  there are no guarantees as to order in which those writes actually occur.
  Keyword arguments:
  @param buffer: the buffer to write
  @param position: the position in the file where to write the buffer. Position is measured in bytes and
  starts with zero at the beginning of the file.`

Data descriptors defined here:

__dict__
  `dictionary for instance variables (if defined)`

__weakref__
  `list of weak references to the object (if defined)`

read_stream
  `returns [ReadStream] A read stream operating on the file.`

write_stream
  `returns a write stream operating on the file.`

class AsyncFileReadStream(core.streams.ReadStream)

``

Method resolution order:
  AsyncFileReadStream
  core.streams.ReadStream
  __builtin__.object

Methods defined here:

__init__(self, java_obj)

Methods inherited from core.streams.ReadStream:

data_handler(self, handler)
  `Set a data handler. As data is read, the handler will be called with the data.
  Keyword arguments:
  @param handler: The data handler`

end_handler(self, handler)
  `Set an end handler on the stream. Once the stream has ended, and there is no more data to be read, this handler will be called.
  Keyword arguments:
  @param handler: The exception handler`

exception_handler(self, handler)
  `Set an execption handler on the stream.
  param [Block] hndlr. The exception handler`

pause(self)
  `Pause the ReadStream. After calling this, the ReadStream will aim to send no more data to the`

resume(self)
  `Resume reading. If the ReadStream has been paused, reading will recommence on it.`

Data descriptors inherited from core.streams.ReadStream:

__dict__
  `dictionary for instance variables (if defined)`

__weakref__
  `list of weak references to the object (if defined)`

class AsyncFileWriteStream(core.streams.WriteStream)

``

Method resolution order:
  AsyncFileWriteStream
  core.streams.WriteStream
  __builtin__.object

Methods defined here:

__init__(self, java_obj)

Methods inherited from core.streams.WriteStream:

drain_handler(self, handler)
  `Set a drain handler on the stream. If the write queue is full, then the handler will be called when the write
  queue has been reduced to maxSize / 2. See for an example of this being used.
  Keyword arguments:
  @param handler: The drain handler`

exception_handler(self, handler)
  `Set an execption handler on the stream.
  Keyword arguments:
  @param handler: The exception handler`

set_write_queue_max_size(self, size)
  `Set the maximum size of the write queue. You will still be able to write to the stream even
  if there is more data than this in the write queue. This is used as an indicator by classes such as
  to provide flow control.
  Keyword arguments:
  @param size: The maximum size, in bytes.`

write_buffer(self, buff)
  `Write some data to the stream. The data is put on an internal write queue, and the write actually happens
  asynchronously. To avoid running out of memory by putting too much on the write queue,
  check the method before writing. This is done automatically if using a .
  param [Buffer]. The buffer to write.`

Data descriptors inherited from core.streams.WriteStream:

__dict__
  `dictionary for instance variables (if defined)`

__weakref__
  `list of weak references to the object (if defined)`

write_queue_full
  `Is the write queue full?
  return True if there are more bytes in the write queue than the max write queue size.`

write_queue_max_size

class FSProps(__builtin__.object)
`` | `Represents the properties of a file system`

Methods defined here:

__init__(self, java_obj)

Data descriptors defined here:

__dict__
  `dictionary for instance variables (if defined)`

__weakref__
  `list of weak references to the object (if defined)`

total_space
  `returns the total space on the file system, in bytes.`

unallocated_space
  `returns unallocated space on the file system, in bytes.`

usable_space
  `returns usable space on the file system, in bytes.`

class FSWrappedHandler(org.python.proxies.core.file_system$FSWrappedHandler$10)

``

Method resolution order:
  FSWrappedHandler
  org.python.proxies.core.file_system$FSWrappedHandler$10
  org.vertx.java.core.AsyncResultHandler
  org.vertx.java.core.Handler
  java.lang.Object
  __builtin__.object

Methods defined here:

__init__(self, handler, result_converter=None)

handle(self, async_result)

Data descriptors defined here:

__dict__
  `dictionary for instance variables (if defined)`

__weakref__
  `list of weak references to the object (if defined)`

Data and other attributes defined here:

__initProxy__ = <java function __initProxy__ 0xf>

__supernames__ = array('java.lang.String', [u'clone', u'finalize'])

classDictInit = <java function classDictInit 0x10>

clone = <java function clone 0x11>

finalize = <java function finalize 0x12>

Methods inherited from java.lang.Object:

__copy__(...)

__deepcopy__(...)

__eq__(...)

__hash__(...)

__ne__(...)

__repr__(...)

__unicode__(...)

Data and other attributes inherited from java.lang.Object:

equals = <java function equals 0x13>

getClass = <java function getClass 0x14>

hashCode = <java function hashCode 0x15>

notify = <java function notify 0x16>

notifyAll = <java function notifyAll 0x17>

toString = <java function toString 0x18>

wait = <java function wait 0x19>

class FileProps(__builtin__.object)
`` | `Represents the properties of a file on the file system`

Methods defined here:

__init__(self, java_obj)

Data descriptors defined here:

__dict__
  `dictionary for instance variables (if defined)`

__weakref__
  `list of weak references to the object (if defined)`

creation_time
  `return [Time] The creation time of the file.`

directory
  `return is the file a directory`

last_access_time
  `return [Time] The last access time of the file.`

last_modified_time
  `return The last modified time of the file.`

other
  `return Is the file some other file type?`

regular_file
  `returns Is it a regular file?`

size
  `returnsthe size of the file, in bytes.`

symbolic_link
  `returns is it a symbolic link?`

class FileSystem(__builtin__.object)

``

`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 defined here:

chmod(path, perms, dir_perms=None, handler=None)
  `Change the permissions on a file, asynchronously. If the file is directory then all contents will also have their permissions changed recursively.
  Keyword arguments:
  @param path: path of file to change permissions
  @param 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).
  @param dir_perms: a permission string of the form rwxr-x---. Used to set permissions for regular files.
  @param handler: the function to call when complete`

chmod_sync(path, perms, dir_perms=None)
  `Synchronous version of FileSystem.chmod`

copy(frm, to, handler)
  `Copy a file, asynchronously. The copy will fail if from does not exist, or if to already exists.
  Keyword arguments:
  @param frm: path of file to copy
  @param to: path of file to copy to
  @param handler: the handler which is called on completion.`

copy_recursive(frm, to, handler)
  `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:
  @param frm: path of file to copy
  @param to: path of file to copy to
  @param handler: the function to call when complete`

copy_recursive_sync(frm, to)
  `Synchronous version of FileSystem.copy_recursive`

copy_sync(frm, to)
  `Synchronous version of FileSystem.copy`

create_file(path, perms=None, handler=None)
  `Create a new empty file, asynchronously.
  Keyword arguments:
  @param path: path of the file to create.
  @param perms: the file will be created with these permissions.
  @param handler: the function to call when complete`

create_file_sync(path, perms=None)
  `Synchronous version of FileSystem.create_file`

delete(path, handler)
  `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:
  @param path: path of the file to delete.
  @param handler: the function to call when complete`

delete_recursive(path, handler)
  `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:
  @param path: path of the file to delete.
  @param handler: the function to call when complete`

delete_recursive_sync(path)
  `Synchronous version of FileSystem.delete_recursive`

delete_sync(path)
  `Synchronous version of FileSystem.delete`

exists(path, handler)
  `Check if a file exists, asynchronously.
  Keyword arguments:
  @param path: Path of the file to check.
  @param handler: the function to call when complete`

exists_sync(path)
  `Synchronous version of FileSystem.exists`

fs_props(path, handler)
  `Get properties for the file system, asynchronously.
  Keyword arguments:
  @param path: Path in the file system.
  @param handler: the function to call when complete`

fs_props_sync(path)
  `Synchronous version of FileSystem.fs_props`

java_file_system()

link(link, existing, handler)
  `Create a hard link, asynchronously..
  Keyword arguments:
  @param link: path of the link to create.
  @param existing: path of where the link points to.
  @param handler: the function to call when complete`

link_sync(link, existing)
  `Synchronous version of FileSystem.link`

mkdir(path, perms=None, handler=None)
  `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:
  @param path: path of the directory to create.
  @param perms: a permission string of the form rwxr-x--- to give directory.
  @param handler: the function to call when complete`

mkdir_sync(path, perms=None)
  `Synchronous version of FileSystem.mkdir`

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.
  The create will fail if the directory already exists.
  Keyword arguments:
  @param path: path of the directory to create.
  @param perms: a permission string of the form rwxr-x--- to give the created directory(ies).`

mkdir_with_parents_sync(path, perms=None)
  `Synchronous version of FileSystem.mkdir_with_parents`

move(frm, to, handler)
  `Move a file, asynchronously. The move will fail if from does not exist, or if to already exists.
  Keyword arguments:
  @param frm: Path of file to move
  @param to: Path of file to move to
  @param handler: the function to call when complete`

move_sync(frm, to)
  `Synchronous version of FileSystem.move`

open(path, perms=None, read=True, write=True, create_new=True, flush=False, handler=None)
  `Open a file on the file system, asynchronously.
  Keyword arguments:
  @param path: path of the file to open.
  @param perms: if the file does not exist and create_new is true, then the file will be created with these permissions.
  @param read: open the file for reading?
  @param write: open the file for writing?
  @param create_new: Create the file if it doesn't already exist?
  @param flush: whenever any data is written to the file, flush all changes to permanent storage immediately?
  @param handler: the function to call when complete`

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

props(path, handler)
  `Get file properties for a file, asynchronously.
  Keyword arguments:
  @param path: path to file
  @param handler: the function to call when complete`

props_sync(path)
  `Synchronous version of FileSystem.props`

read_dir(path, filter=None, handler=None)
  `Read a directory, i.e. list it's contents, asynchronously.
  The read will fail if the directory does not exist.
  Keyword arguments:
  @param path: path of the directory to read.
  @param 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.
  @param handler: the function to call when complete`

read_dir_sync(path, filter=None)
  `Synchronous version of FileSystem.read_dir`

read_file_as_buffer(path, handler)
  `Read the contents of an entire file as a Buffer, asynchronously.
  Keyword arguments:
  @param path: path of the file to read.
  @param handler: the function to call when complete`

read_file_as_buffer_sync(path)
  `Synchronous version of FileSystem.read_file_as_buffer`

read_sym_link(link, handler)
  `Read a symbolic link, asynchronously. I.e. tells you where the symbolic link points.
  Keyword arguments:
  @param link: path of the link to read.
  @param handler: the function to call when complete`

read_sym_link_sync(link)
  `Synchronous version of FileSystem.read_sym_link`

sym_link(link, existing, handler)
  `Create a symbolic link, asynchronously.
  Keyword arguments:
  @param link: Path of the link to create.
  @param existing: Path of where the link points to.
  @param handler: the function to call when complete`

sym_link_sync(link, existing)
  `Synchronous version of FileSystem.sym_link`

truncate(path, len, handler)
  `Truncate a file, asynchronously. The move will fail if path does not exist.
  Keyword arguments:
  @param path: Path of file to truncate
  @param len: Length to truncate file to. Will fail if len < 0. If len > file size then will do nothing.
  @param handler: the function to call when complete`

truncate_sync(path, len)
  `Synchronous version of FileSystem.truncate`

unlink(link, handler)
  `Unlink a hard link.
  Keyword arguments:
  @param link: path of the link to unlink.`

unlinkSync(link)
  `Synchronous version of FileSystem.unlink`

write_buffer_to_file(path, buffer, handler)
  `Write a as the entire contents of a file, asynchronously.
  Keyword arguments:
  @param path: path of the file to write.
  @param buffer: the Buffer to write
  @param handler: the function to call when complete`

write_buffer_to_file_sync(path, buffer)
  `Synchronous version of FileSystem.write_buffer_to_file`

Data descriptors defined here:

__dict__
  `dictionary for instance variables (if defined)`

__weakref__
  `list of weak references to the object (if defined)`

Data
`` |  | __author__ = 'Scott Horn' __credits__ = 'Based entirely on work by Tim Fox http://tfox.org' __email__ = 'scott@hornmicro.com' org = <java package org 0x2>

Author
`` |  | Scott Horn

Credits
`` |  | Based entirely on work by Tim Fox http://tfox.org