Module: Imap::Backup::Utils
- Defined in:
- lib/imap/backup/utils.rb
Class Method Summary collapse
- .check_permissions(filename, limit) ⇒ Object
- .make_folder(base_path, path, permissions) ⇒ Object
- .mode(filename) ⇒ Object
Class Method Details
.check_permissions(filename, limit) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/imap/backup/utils.rb', line 5 def self.(filename, limit) actual = mode(filename) return nil if actual.nil? mask = ~limit & 0o777 return if (actual & mask).zero? = format( "Permissions on '%<filename>s' " \ "should be 0%<limit>o, not 0%<actual>o", filename: filename, limit: limit, actual: actual ) raise end |
.make_folder(base_path, path, permissions) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/imap/backup/utils.rb', line 27 def self.make_folder(base_path, path, ) parts = path.split("/") return if parts.empty? full_path = File.join(base_path, path) FileUtils.mkdir_p full_path path = base_path parts.each do |part| path = File.join(path, part) FileUtils.chmod , path end end |
.mode(filename) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/imap/backup/utils.rb', line 20 def self.mode(filename) return nil if !File.exist?(filename) stat = File.stat(filename) stat.mode & 0o777 end |