Class: Backup::FileItem::Base
- Inherits:
-
Object
- Object
- Backup::FileItem::Base
- Defined in:
- lib/backup/file_item/base.rb
Instance Method Summary collapse
Instance Method Details
#file_hash(file) ⇒ Object
32 33 34 |
# File 'lib/backup/file_item/base.rb', line 32 def file_hash(file) Digest::MD5.hexdigest file end |
#semantic_path(path) ⇒ Object
4 5 6 7 8 9 10 |
# 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) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/backup/file_item/base.rb', line 12 def stat(file, = nil) files = {} stat = File.new(file).stat files[file] = { :uid => stat.uid, :gid => stat.gid, :mode => stat.mode } files[file][:timestamp] = if unless Dir.exists?(file) files[file][:checksum] = Digest::MD5.hexdigest(File.open(file).read) end files rescue Exception => e STDERR.puts e end |