Method: BC3::Snapshot.new_filesystem
- Defined in:
- lib/bc3/snapshot.rb
.new_filesystem(dirname) ⇒ Object Also known as: newd
Create a snapshot from a directory.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/bc3/snapshot.rb', line 68 def self.new_filesystem( dirname ) $log.info("Build Snapshot from directory #{dirname}") #~ raise ArgumentError, "No hash given" unless data.is_a?(Hash) snapshot = new( ::File.("./#{dirname}") ) Dir.chdir(dirname){ Dir['*'].each{|f| if ::File.directory?(f) snapshot << Folder.new_by_dirname(f) elsif ::File.exist?(f) snapshot << File.new_by_filename(f) else raise ArgumentError, "#{f} not found in #{dirname}" end } } snapshot end |