Module: QdumpfsFind

Defined in:
lib/qdumpfs/util.rb

Class Method Summary collapse

Class Method Details

.find(logger, *paths) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/qdumpfs/util.rb', line 70

def find(logger, *paths)
  block_given? or return enum_for(__method__, *paths)
  paths.each do |d|
    raise Errno::ENOENT unless File.exist?(d)
  end
  while file = paths.shift
    catch(:prune) do
      yield file.dup

      begin
        s = File.lstat(file)
      rescue => e
        logger.print("File.lstat path=#{file} error=#{e.message}")
        next
      end

      if s.directory?
        begin
          fs = Dir.entries(file, :encoding=>'UTF-8')
        rescue => e
          logger.print("Dir.entries path=#{file} error=#{e.message}")
          next
        end
        fs.sort!
        fs.reverse_each do |f|
          next if f == "." or f == ".."
          f = File.join(file, f)
          paths.unshift f
        end
      end
    end
  end
end

.pruneObject



104
105
106
# File 'lib/qdumpfs/util.rb', line 104

def prune
  throw :prune
end