Class: Pathname
- Inherits:
-
Object
- Object
- Pathname
- Defined in:
- lib/xccache/core/system.rb
Instance Method Summary collapse
Instance Method Details
#checksum ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/xccache/core/system.rb', line 53 def checksum hasher = Digest::SHA256.new glob("**/*").reject { |p| p.directory? || p.symlink? }.sort.each do |p| p.open("rb") do |f| while (chunk = f.read(65_536)) # Read 64KB chunks hasher.update(chunk) end end end hasher.hexdigest[...8] end |
#copy(to: nil, to_dir: nil) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/xccache/core/system.rb', line 45 def copy(to: nil, to_dir: nil) dst = to || (Pathname(to_dir) / basename) dst.rmtree if dst.exist? || dst.symlink? dst.parent.mkpath FileUtils.copy_entry(self, dst) dst end |