Sha256: 5ba2f783891606b2666bd42aa537e53e0ca83ffa8aacc3e3b42072f43de03347

Contents?: true

Size: 898 Bytes

Versions: 1

Compression:

Stored size: 898 Bytes

Contents


module VFS
  class Dir
    attr_reader :path
    attr_reader :pos
    alias_method :tell, :pos

    def initialize(path)
      @path         = path
      begin
        @virtual_file = org.jboss.vfs.VFS.child( path )
      rescue Java::JavaLang::NullPointerException
        raise Errno::ENOENT.new
      end
      @pos          = 0
      @closed       = false
    end

    def close
      @closed = true
    end

    def each
      @virtual_file.children.each do |child|
        yield child.name
      end
    end

    def rewind
      @pos = 0
    end

    def read
      children = @virtual_file.children
      return nil unless ( @pos < children.size )
      child = children[@pos]
      @pos += 1
      child.name
    end

    def seek(i)
      @pos = i
      self
    end

    def pos=(i)
      @pos = i
    end

    def entries
      @virtual_file.children.map(&:name)
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
org.torquebox.vfs-1.0.0.Beta23 lib/vfs/dir.rb