4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/optimacms/fileutils/fileutils.rb', line 4
def self.create_dir_if_not_exists(filename)
if filename =~ /\/$/
path = filename
else
path = File.dirname(filename)
end
return if File.directory? (path)
begin
a_dirs = path.split(/\//)
d = ''
a_dirs.each do |v|
d += v + '/'
if d.empty?
continue
end
if ! File.directory? (d)
Dir.mkdir(d, 0775)
end
end
if ! File.directory? (path)
Dir.mkdir(path, 0775)
end
rescue Exception => ex
end
end
|