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 = null) : void

close()

Close the file. The actual close happens asynchronously. The handler will be called when the close is complete, or an error occurs.

param $handler [callable] the handler close($handler)

Arguments

$arg0

callable

drainHandler

drainHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

Close the file, see @see \io\vertx\jphp\core\file\AsyncFile::close.

end( $arg0 = null) : void

end()

Same as @see \io\vertx\jphp\core\file\AsyncFile::end but writes some data to the stream before ending.

param $t [Buffer] end($t)

Arguments

$arg0

Buffer

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

Flush any writes made to this file to underlying persistent storage.

flush( $arg0 = null) : $this

If the file was opened with flush set to true then calling this method will have no effect.

The actual flush will happen asynchronously. flush() 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 param $handler [callable] flush($handler)

Arguments

$arg0

callable

Response

$this

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

handler

handler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

pause

pause() : $this

Response

$this

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 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

param $data [Buffer] <b> write($data) </b>

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

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

integer

$arg2

callable

Response

$this

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