Class: Aruba::Platforms::ArubaFixedSizeFileCreator
- Inherits:
-
Object
- Object
- Aruba::Platforms::ArubaFixedSizeFileCreator
- Defined in:
- lib/aruba/platforms/aruba_fixed_size_file_creator.rb
Overview
Create files with fixed size
This class is not meant to be used directly by users.
It uses a single null byte as content and really creates so called sparse files.
Instance Method Summary collapse
-
#call(path, size, check_presence) ⇒ Object
Write File.
Instance Method Details
#call(path, size, check_presence) ⇒ Object
Write File
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/aruba/platforms/aruba_fixed_size_file_creator.rb', line 24 def call(path, size, check_presence) if check_presence && !Aruba.platform.file?(path) raise "Expected #{path} to be present" end Aruba.platform.mkdir(File.dirname(path)) File.open(path, "wb") do |f| f.seek(size - 1) f.write("\0") end self end |