Package core :: Module file_system :: Class AsyncFile |
[hide private]
[frames] | no frames]

# Class AsyncFile

source code

    object --+
             |
            AsyncFile

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

Instance Methods | [hide private]
__init__(self, java_obj) | source code
close(self, handler) Close the file, asynchronously. | source code
write(self, buffer, position, handler) Write a Buffer to the file, asynchronously. | source code
read(self, buffer, offset, position, length, handler) Reads some data from a file into a buffer, asynchronously. | source code
write_stream(self) returns a write stream operating on the file. | source code
read_stream(self) returns [ReadStream] A read stream operating on the file. | source code
flush(self) Flush any writes made to this file to underlying persistent storage, asynchronously. | source code

Method Details | [hide private]

### __init__(self, java_obj) (Constructor) | source code
Overrides: object.__init__ (inherited documentation)

### write(self, buffer, position, handler) | source code
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: Parameters: `buffer` - the buffer to write `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.

### read(self, buffer, offset, position, length, handler) | source code
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 Parameters: `buffer` - the buffer into which the data which is read is written. `offset` - the position in the buffer where to start writing the data. `position` - the position in the file where to read the data. `length` - the number of bytes to read.

### write_stream(self) | source code
returns a write stream operating on the file. Decorators: `@property`

### read_stream(self) | source code
returns [ReadStream] A read stream operating on the file. Decorators: `@property`

### flush(self) | source code
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: Parameters: `handler` - the handler which is called on completion.