AsyncFile

Represents a file on the file-system which can be read from, or written to asynchronously.

This class also implements @see \io\vertx\jphp\core\streams\ReadStream and

see

This allows the data to be pumped to and from other streams, e.g. an @see \io\vertx\jphp\core\http\HttpClientRequest instance, using the @see \io\vertx\jphp\core\streams\Pump class

package

Default

Methods

__construct

__construct() 

Close the file. The actual close happens asynchronously.

close( $arg0) : void

The handler will be called when the close is complete, or an error occurs.

Arguments

$arg0

callable

drainHandler

drainHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

Same as @see \io\vertx\jphp\core\streams\WriteStream::end but with an <code>handler</code> called when the operation completes

end( $arg0,  $arg1 = null) : void

param $handler [callable] end($handler)

Same as but with an handler called when the operation completes

param $data [Buffer] param $handler [callable] end($data, $handler)

Arguments

$arg0

Buffer | callable

$arg1

callable

endHandler

endHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

exceptionHandler

exceptionHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

fetch

fetch( $arg0) : $this

Arguments

$arg0

integer

Response

$this

Same as @see \io\vertx\jphp\core\file\AsyncFile::flush but the handler will be called when the flush is complete or if an error occurs

flush( $arg0) : $this

Arguments

$arg0

callable

Response

$this

getWritePos

getWritePos() : integer

Response

integer

the current write position the file is at

handler

handler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

pause

pause() : $this

Response

$this

Pause this stream and return a to transfer the elements of this stream to a destination .

pipe() : \io\vertx\jphp\core\file\Pipe<Buffer>

The stream will be resumed when the pipe will be wired to a WriteStream.

Response

\io\vertx\jphp\core\file\Pipe

a pipe

Pipe this <code>ReadStream</code> to the <code>WriteStream</code>.

pipeTo( $arg0,  $arg1) : void

Elements emitted by this stream will be written to the write stream until this stream ends or fails.

Once this stream has ended or failed, the write stream will be ended and the handler will be called with the result.

Arguments

$arg0

WriteStream

$arg1

callable

Reads <code>length</code> bytes of data from the file at position <code>position</code> in the file, asynchronously.

read( $arg0,  $arg1,  $arg2,  $arg3,  $arg4) : $this

The read data will be written into the specified Buffer buffer at position offset.

If data is read past the end of the file then zero bytes will be read.

When multiple reads are invoked on the same file there are no guarantees as to order in which those reads actually occur.

The handler will be called when the close is complete, or if an error occurs.

Arguments

$arg0

Buffer

$arg1

integer

$arg2

integer

$arg3

integer

$arg4

callable

Response

$this

a reference to this, so the API can be used fluently

resume

resume() : $this

Response

$this

Sets the buffer size that will be used to read the data from the file. Changing this value will impact how much the data will be read at a time from the file system.

setReadBufferSize( $arg0) : $this

Arguments

$arg0

integer

Response

$this

a reference to this, so the API can be used fluently

Sets the number of bytes that will be read when using the file as a @see \io\vertx\jphp\core\streams\ReadStream.

setReadLength( $arg0) : $this

Arguments

$arg0

integer

Response

$this

a reference to this, so the API can be used fluently

Sets the position from which data will be read from when using the file as a @see \io\vertx\jphp\core\streams\ReadStream.

setReadPos( $arg0) : $this

Arguments

$arg0

integer

Response

$this

a reference to this, so the API can be used fluently

Sets the position from which data will be written when using the file as a @see \io\vertx\jphp\core\streams\WriteStream.

setWritePos( $arg0) : $this

Arguments

$arg0

integer

Response

$this

a reference to this, so the API can be used fluently

setWriteQueueMaxSize

setWriteQueueMaxSize( $arg0) : $this

Arguments

$arg0

integer

Response

$this

Same as but with an <code>handler</code> called when the operation completes

write( $arg0,  $arg1,  $arg2 = null) : void

param $data [Buffer] param $handler [callable] write($data, $handler)

Write a @see \io\vertx\jphp\core\buffer\Buffer to the file at position position in the file, asynchronously.

If position lies outside of the current size of the file, the file will be enlarged to encompass it.

When multiple writes are invoked on the same file there are no guarantees as to order in which those writes actually occur

The handler will be called when the write is complete, or if an error occurs. param $buffer [Buffer] the buffer to write param $position [integer] the position in the file to write it at param $handler [callable] the handler to call when the write is complete write($buffer, $position, $handler)

Arguments

$arg0

Buffer

$arg1

callable | integer

$arg2

callable

This will return <code>true</code> if there are more bytes in the write queue than the value set using @see \io\vertx\jphp\core\file\AsyncFile::setWriteQueueMaxSize

writeQueueFull() : boolean

Response

boolean

true if write queue is full