Class: VirtDisk::BlockFile
- Inherits:
-
Object
- Object
- VirtDisk::BlockFile
- Defined in:
- lib/virt_disk/block_file.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #block_size ⇒ Object
- #close ⇒ Object
-
#initialize(path) ⇒ BlockFile
constructor
A new instance of BlockFile.
- #raw_read(start, len) ⇒ Object
- #raw_write(buf, start, len) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(path) ⇒ BlockFile
Returns a new instance of BlockFile.
5 6 7 8 |
# File 'lib/virt_disk/block_file.rb', line 5 def initialize(path) @path = path @file = defined?(VirtFS) ? VirtFS::VFile.open(path) : File.open(path) end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
3 4 5 |
# File 'lib/virt_disk/block_file.rb', line 3 def path @path end |
Instance Method Details
#block_size ⇒ Object
10 11 12 |
# File 'lib/virt_disk/block_file.rb', line 10 def block_size 1 end |
#close ⇒ Object
18 19 20 |
# File 'lib/virt_disk/block_file.rb', line 18 def close @file.close end |
#raw_read(start, len) ⇒ Object
22 23 24 25 |
# File 'lib/virt_disk/block_file.rb', line 22 def raw_read(start, len) @file.seek start @file.read len end |
#raw_write(buf, start, len) ⇒ Object
27 28 29 30 |
# File 'lib/virt_disk/block_file.rb', line 27 def raw_write(buf, start, len) @file.seek start @file.write buf, len end |
#size ⇒ Object
14 15 16 |
# File 'lib/virt_disk/block_file.rb', line 14 def size @file.size end |