Sha256: 4348a8b023acf71aecec50d98f98c3931825158050e68eaf3f1e6962ea457700

Contents?: true

Size: 1.13 KB

Versions: 50

Compression:

Stored size: 1.13 KB

Contents

class Puppet::FileSystem::File19 < Puppet::FileSystem::FileImpl
  def binread(path)
    path.binread
  end

  # Provide an encoding agnostic version of compare_stream
  #
  # The FileUtils implementation in Ruby 2.0+ was modified in a manner where
  # it cannot properly compare File and StringIO instances. To sidestep that
  # issue this method reimplements the faster 2.0 version that will correctly
  # compare binary File and StringIO streams.
  def compare_stream(path, stream)
    open(path, 0, 'rb') do |this|
      bsize = stream_blksize(this, stream)
      sa = "".force_encoding('ASCII-8BIT')
      sb = "".force_encoding('ASCII-8BIT')
      begin
        this.read(bsize, sa)
        stream.read(bsize, sb)
        return true if sa.empty? && sb.empty?
      end while sa == sb
      false
    end
  end

  private
  def stream_blksize(*streams)
    streams.each do |s|
      next unless s.respond_to?(:stat)
      size = blksize(s.stat)
      return size if size
    end
    default_blksize()
  end

  def blksize(st)
    s = st.blksize
    return nil unless s
    return nil if s == 0
    s
  end

  def default_blksize
    1024
  end
end

Version data entries

50 entries across 50 versions & 2 rubygems

Version Path
puppet-retrospec-0.12.2 vendor/gems/puppet-3.7.3/lib/puppet/file_system/file19.rb
puppet-3.8.7 lib/puppet/file_system/file19.rb
puppet-3.8.7-x86-mingw32 lib/puppet/file_system/file19.rb
puppet-3.8.7-x64-mingw32 lib/puppet/file_system/file19.rb
puppet-3.8.6 lib/puppet/file_system/file19.rb
puppet-3.8.6-x86-mingw32 lib/puppet/file_system/file19.rb
puppet-retrospec-0.12.1 vendor/gems/puppet-3.7.3/lib/puppet/file_system/file19.rb
puppet-3.8.6-x64-mingw32 lib/puppet/file_system/file19.rb
puppet-retrospec-0.12.0 vendor/gems/puppet-3.7.3/lib/puppet/file_system/file19.rb
puppet-3.8.5 lib/puppet/file_system/file19.rb
puppet-3.8.5-x86-mingw32 lib/puppet/file_system/file19.rb
puppet-3.8.5-x64-mingw32 lib/puppet/file_system/file19.rb
puppet-3.8.4 lib/puppet/file_system/file19.rb
puppet-3.8.4-x86-mingw32 lib/puppet/file_system/file19.rb
puppet-3.8.4-x64-mingw32 lib/puppet/file_system/file19.rb
puppet-retrospec-0.11.0 vendor/gems/puppet-3.7.3/lib/puppet/file_system/file19.rb
puppet-retrospec-0.10.0 vendor/gems/puppet-3.7.3/lib/puppet/file_system/file19.rb
puppet-retrospec-0.9.1 vendor/gems/puppet-3.7.3/lib/puppet/file_system/file19.rb
puppet-retrospec-0.9.0 vendor/gems/puppet-3.7.3/lib/puppet/file_system/file19.rb
puppet-retrospec-0.8.1 vendor/gems/puppet-3.7.3/lib/puppet/file_system/file19.rb