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 |
__construct()
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)
callable
drainHandler( $arg0) : $this
callable
$this
end( $arg0 = null, $arg1 = null) : void
end()
Same as @see \io\vertx\jphp\core\file\AsyncFile::end but writes some data to the stream before ending.
param $data [Buffer] the data to write end($data)
Close the file, see @see \io\vertx\jphp\core\file\AsyncFile::close.
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)
Buffer | callable
callable
endHandler( $arg0) : $this
callable
$this
exceptionHandler( $arg0) : $this
callable
$this
fetch( $arg0) : $this
integer
$this
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)
callable
$thisa reference to this, so the API can be used fluently
getWritePos() : integer
integerthe current write position the file is at
handler( $arg0) : $this
callable
$this
pause() : $this
$this
pipe() : \io\vertx\jphp\core\file\Pipe<Buffer>
The stream will be resumed when the pipe will be wired to a WriteStream.
\io\vertx\jphp\core\file\Pipea pipe
pipeTo( $arg0, $arg1 = null) : void
param $dst [WriteStream
Pipe this ReadStream to the WriteStream.
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.
param $dst [WriteStream
WriteStream
callable
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.
Buffer
integer
integer
integer
callable
$thisa reference to this, so the API can be used fluently
resume() : $this
$this
setReadBufferSize( $arg0) : $this
integer
$thisa reference to this, so the API can be used fluently
setReadPos( $arg0) : $this
integer
$thisa reference to this, so the API can be used fluently
setWritePos( $arg0) : $this
integer
$thisa reference to this, so the API can be used fluently
setWriteQueueMaxSize( $arg0) : $this
integer
$this
write( $arg0, $arg1 = null, $arg2 = null) : $this
Same as @see \io\vertx\jphp\core\file\AsyncFile::write but with an handler called when the operation completes
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)
Buffer
callable | integer
callable
$this
writeQueueFull() : boolean
booleantrue if write queue is full