Module: Find

Defined in:
lib/lnbackup/util.rb

Class Method Summary collapse

Class Method Details

.find3(*path) ⇒ Object

reimplementace funkce “find” s osetrenim vyjimky Errno::EOVERFLOW, ktera minimalne na ruby1.6 nastava pri zachazeni (napr. stat) se souborem o velikosti >2GB

pruchod je udelan pomoci zasobniku s hloubkou, aby bylo mozne usetrit pamet



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/lnbackup/util.rb', line 93

def Find.find3(*path)
  path.collect!{|d| [d.dup,0]}
  while temp = path.shift
    catch(:prune) do
      (file, depth) = temp
      yield [file, depth]
      begin
        if File.lstat(file).directory? then
          d = Dir.open(file)
          begin
            for f in d
              next if f == "." or f == ".."
              if File::ALT_SEPARATOR and file =~ /^(?:[\/\\]|[A-Za-z]:[\/\\]?)$/ then
                f = file + f
              elsif file == "/" then
                f = "/" + f
              else
                f = File.join(file, f)
              end
              path.unshift [f, depth+1]
            end
          ensure
            d.close
          end
        end
      rescue Errno::ENOENT, Errno::EACCES, Errno::EOVERFLOW
      end
    end
  end
end