Class: File
- Inherits:
-
Object
- Object
- File
- Defined in:
- lib/fallocate/18.rb,
lib/fallocate/19.rb
Instance Method Summary collapse
-
#allocate(offset = 0, length) ⇒ Object
Ensures there is enough disk space for writing to a file.
Instance Method Details
#allocate(offset = 0, length) ⇒ Object
Ensures there is enough disk space for writing to a file.
This method asks the filesystem to allocate disk blocks for a file region, so that writes to that region will not fail due to out-of-space errors.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/fallocate/18.rb', line 9 def allocate(offset, length = nil) unless length length = offset offset = 0 end errno = Fallocate.posix_fallocate fileno, offset, length return if errno == 0 raise SystemCallError.new(errno) end |