12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/file_crawler/finder/command/search.rb', line 12
def search_directories(path, options={})
result = []
cmd = "find #{path} -type d"
if options[:maxdepth] && options[:maxdepth] > 0
cmd = "find #{path} -maxdepth #{options[:maxdepth]} -type d"
end
exec(cmd).each_line {|item|
item.chomp!
valid = true
if options[:exclude_invisible_file]
filename = File.basename(item)
valid = !filename.start_with?('.')
end
result << item if valid
}
result
end
|