Sha256: 2eecb88eea893de93dc2c7b2dd73e3d0b08d0782270250ce2fceba2a6a1f208e
Contents?: true
Size: 935 Bytes
Versions: 37
Compression:
Stored size: 935 Bytes
Contents
require "fileutils" module Imap::Backup module Utils def self.check_permissions(filename, limit) actual = mode(filename) return nil if actual.nil? mask = ~limit & 0o777 return if (actual & mask).zero? message = format( "Permissions on '%<filename>s' " \ "should be 0%<limit>o, not 0%<actual>o", filename: filename, limit: limit, actual: actual ) raise message end def self.mode(filename) return nil if !File.exist?(filename) stat = File.stat(filename) stat.mode & 0o777 end def self.make_folder(base_path, path, permissions) 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 permissions, path end end end end
Version data entries
37 entries across 37 versions & 1 rubygems