Class: AsyncFile

vertx-js/async_file~ AsyncFile

new AsyncFile()

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

Source:

Methods

close(handler)

Close the file. The actual close happens asynchronously. The handler will be called when the close is complete, or an error occurs.
Parameters:
Name Type Description
handler function the handler
Source:

drainHandler(handler) → {AsyncFile}

Parameters:
Name Type Description
handler function
Source:
Returns:
Type
AsyncFile

end(t)

Same as AsyncFile#end but writes some data to the stream before ending.
Parameters:
Name Type Description
t Buffer
Source:

endHandler(endHandler) → {AsyncFile}

Parameters:
Name Type Description
endHandler function
Source:
Returns:
Type
AsyncFile

exceptionHandler(handler) → {AsyncFile}

Parameters:
Name Type Description
handler function
Source:
Returns:
Type
AsyncFile

flush(handler) → {AsyncFile}

Same as AsyncFile#flush but the handler will be called when the flush is complete or if an error occurs
Parameters:
Name Type Description
handler function
Source:
Returns:
Type
AsyncFile

handler(handler) → {AsyncFile}

Parameters:
Name Type Description
handler function
Source:
Returns:
Type
AsyncFile

pause() → {AsyncFile}

Source:
Returns:
Type
AsyncFile

read(buffer, offset, position, length, handler) → {AsyncFile}

Reads length bytes of data from the file at position position in the file, asynchronously.

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.

Parameters:
Name Type Description
buffer Buffer the buffer to read into
offset number the offset into the buffer where the data will be read
position number the position in the file where to start reading
length number the number of bytes to read
handler function the handler to call when the write is complete
Source:
Returns:
a reference to this, so the API can be used fluently
Type
AsyncFile

resume() → {AsyncFile}

Source:
Returns:
Type
AsyncFile

setReadBufferSize(readBufferSize) → {AsyncFile}

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.
Parameters:
Name Type Description
readBufferSize number the buffer size
Source:
Returns:
a reference to this, so the API can be used fluently
Type
AsyncFile

setReadPos(readPos) → {AsyncFile}

Sets the position from which data will be read from when using the file as a ReadStream.
Parameters:
Name Type Description
readPos number the position in the file
Source:
Returns:
a reference to this, so the API can be used fluently
Type
AsyncFile

setWritePos(writePos) → {AsyncFile}

Sets the position from which data will be written when using the file as a WriteStream.
Parameters:
Name Type Description
writePos number the position in the file
Source:
Returns:
a reference to this, so the API can be used fluently
Type
AsyncFile

setWriteQueueMaxSize(maxSize) → {AsyncFile}

Parameters:
Name Type Description
maxSize number
Source:
Returns:
Type
AsyncFile

write(buffer, position, handler) → {AsyncFile}

Write a 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.

Parameters:
Name Type Description
buffer Buffer the buffer to write
position number the position in the file to write it at
handler function the handler to call when the write is complete
Source:
Returns:
a reference to this, so the API can be used fluently
Type
AsyncFile

writeQueueFull() → {boolean}

This will return true if there are more bytes in the write queue than the value set using AsyncFile#setWriteQueueMaxSize
Source:
Returns:
true if write queue is full
Type
boolean