Class: Vertx::AsyncFile
- Inherits:
-
Object
- Object
- Vertx::AsyncFile
- Defined in:
- src/main/ruby_scripts/core/file_system.rb
Overview
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 Method Summary (collapse)
-
- (Object) close(&block)
Close the file, asynchronously.
-
- (Object) flush
Flush any writes made to this file to underlying persistent storage, asynchronously.
-
- (Object) read(buffer, offset, position, length, &block)
Reads some data from a file into a buffer, asynchronously.
-
- (ReadStream) read_stream
A read stream operating on the file.
-
- (Object) write(buffer, position, &block)
Write a Buffer to the file, asynchronously.
-
- (WriteStream) write_stream
A write stream operating on the file.
Instance Method Details
- (Object) close(&block)
Close the file, asynchronously.
108 109 110 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 108 def close(&block) @j_file.close(FSWrappedHandler.new(block)) end |
- (Object) flush
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.
146 147 148 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 146 def flush Future.new(@j_file.flush) end |
- (Object) read(buffer, offset, position, length, &block)
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.
129 130 131 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 129 def read(buffer, offset, position, length, &block) @j_file.read(buffer._to_java_buffer, offset, position, length, FSWrappedHandler.new(block) { |j_buff| Buffer.new(j_buff) }) end |
- (ReadStream) read_stream
A read stream operating on the file.
139 140 141 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 139 def read_stream AsyncFileReadStream.new(@j_file.getReadStream) end |
- (Object) write(buffer, position, &block)
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.
starts with zero at the beginning of the file.
118 119 120 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 118 def write(buffer, position, &block) @j_file.write(buffer._to_java_buffer, position, FSWrappedHandler.new(block)) end |
- (WriteStream) write_stream
A write stream operating on the file.
134 135 136 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 134 def write_stream AsyncFileWriteStream.new(@j_file.getWriteStream) end |