Module: FileUtils

Defined in:
lib/gonzui/util.rb

Class Method Summary collapse

Class Method Details

.chmod_r(mode, *paths) ⇒ Object



91
92
93
94
95
# File 'lib/gonzui/util.rb', line 91

def chmod_r(mode, *paths)
  Find.find(*paths) {|path|
    File.chmod(mode, path) if !File.symlink?(path)
  }
end

.fix_permission(directory) ⇒ Object



97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/gonzui/util.rb', line 97

def fix_permission(directory)
  Find.find(directory) {|file_name|
    stat = File.lstat(file_name)
    if stat.directory?
      if stat.mode & 0777 != (stat.mode | 0700) & 0755
        File.chmod((stat.mode | 0700) & 0755, file_name)
      end
    elsif stat.file?
      if stat.mode & 0666 != (stat.mode | 0600) & 0644
        File.chmod((stat.mode | 0600) & 0644, file_name)
      end
    end
  }
end

.rm_rff(path) ⇒ Object



112
113
114
115
# File 'lib/gonzui/util.rb', line 112

def rm_rff(path)
  fix_permission(path)
  rm_rf(path)
end