Sha256: 4170ed9508a0222f9aed0d2bb3b33301a894b53d3954948bb8e2c60d17135a52

Contents?: true

Size: 875 Bytes

Versions: 26

Compression:

Stored size: 875 Bytes

Contents

# Aruba
module Aruba
  # Platforms
  module Platforms
    # 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.
    #
    # @private
    class ArubaFixedSizeFileCreator
      # Write File
      #
      # @param [String] path
      #   The path to write content to
      #
      # @param [Numeric] size
      #   The size of the file
      #
      # @param [TrueClass, FalseClass] check_presence (false)
      #   Check if file exist
      def call(path, size, check_presence)
        fail "Expected #{path} to be present" if check_presence && !Aruba.platform.file?(path)

        Aruba.platform.mkdir(File.dirname(path))

        File.open(path, "wb"){ |f| f.seek(size - 1); f.write("\0") }

        self
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 3 rubygems

Version Path
aruba-0.14.14 lib/aruba/platforms/aruba_fixed_size_file_creator.rb
aruba-0.14.13 lib/aruba/platforms/aruba_fixed_size_file_creator.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/aruba-0.14.12/lib/aruba/platforms/aruba_fixed_size_file_creator.rb
aruba-0.14.12 lib/aruba/platforms/aruba_fixed_size_file_creator.rb
aruba-0.14.11 lib/aruba/platforms/aruba_fixed_size_file_creator.rb
aruba-0.14.10 lib/aruba/platforms/aruba_fixed_size_file_creator.rb
aruba-0.14.9 lib/aruba/platforms/aruba_fixed_size_file_creator.rb
aruba-0.14.8 lib/aruba/platforms/aruba_fixed_size_file_creator.rb
aruba-0.14.7 lib/aruba/platforms/aruba_fixed_size_file_creator.rb
aruba-0.14.6 lib/aruba/platforms/aruba_fixed_size_file_creator.rb
aruba-0.14.5 lib/aruba/platforms/aruba_fixed_size_file_creator.rb
aruba-0.14.4 lib/aruba/platforms/aruba_fixed_size_file_creator.rb
aruba-0.14.3 lib/aruba/platforms/aruba_fixed_size_file_creator.rb
aruba-1.0.0.pre.alpha.2 lib/aruba/platforms/aruba_fixed_size_file_creator.rb
aruba-1.0.0.pre.alpha.1 lib/aruba/platforms/aruba_fixed_size_file_creator.rb
aruba-win-fix-0.14.2 lib/aruba/platforms/aruba_fixed_size_file_creator.rb
aruba-0.14.2 lib/aruba/platforms/aruba_fixed_size_file_creator.rb
aruba-0.14.1 lib/aruba/platforms/aruba_fixed_size_file_creator.rb
aruba-0.14.0 lib/aruba/platforms/aruba_fixed_size_file_creator.rb
aruba-0.13.0 lib/aruba/platforms/aruba_fixed_size_file_creator.rb