module QdumpfsFind

Public Class Methods

find(logger, *paths) { |dup.taint| ... } click to toggle source
# File lib/qdumpfs/util.rb, line 65
def find(logger, *paths)
  block_given? or return enum_for(__method__, *paths)
  paths.collect!{|d|
    raise Errno::ENOENT unless File.exist?(d);
    d.dup
  }
  while file = paths.shift
    catch(:prune) do
      yield file.dup.taint
      begin
        s = File.lstat(file)
      rescue => e
        logger.print("File.lstat path=#{file} error=#{e.message}")
        next
      end
      if s.directory? then
        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 {|f|
          next if f == "." or f == ".."
          f = File.join(file, f)
          paths.unshift f.untaint
        }
      end
    end
  end
end
prune() click to toggle source
# File lib/qdumpfs/util.rb, line 98
def prune
  throw :prune
end

Private Instance Methods

find(logger, *paths) { |dup.taint| ... } click to toggle source
# File lib/qdumpfs/util.rb, line 65
def find(logger, *paths)
  block_given? or return enum_for(__method__, *paths)
  paths.collect!{|d|
    raise Errno::ENOENT unless File.exist?(d);
    d.dup
  }
  while file = paths.shift
    catch(:prune) do
      yield file.dup.taint
      begin
        s = File.lstat(file)
      rescue => e
        logger.print("File.lstat path=#{file} error=#{e.message}")
        next
      end
      if s.directory? then
        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 {|f|
          next if f == "." or f == ".."
          f = File.join(file, f)
          paths.unshift f.untaint
        }
      end
    end
  end
end
prune() click to toggle source
# File lib/qdumpfs/util.rb, line 98
def prune
  throw :prune
end