class Backup::FileItem::Base

Public Instance Methods

file_hash(file) click to toggle source
# File lib/backup/file_item/base.rb, line 32
def file_hash(file)
  Digest::MD5.hexdigest file
end
semantic_path(path) click to toggle source
# File lib/backup/file_item/base.rb, line 4
def semantic_path(path)
  if Dir.exists? path
    path += '/'
  else
    path
  end
end
stat(file, timestamp = nil) click to toggle source
# File lib/backup/file_item/base.rb, line 12
def stat(file, timestamp = nil)
  files = {}

  stat = File.new(file).stat
  files[file] = {
    :uid => stat.uid,
    :gid => stat.gid,
    :mode => stat.mode
  }
  files[file][:timestamp] = timestamp if timestamp

  unless Dir.exists?(file)
    files[file][:checksum] = Digest::MD5.hexdigest(File.open(file).read)
  end

  files
rescue Exception => e
  STDERR.puts e
end