Class Zip::ZipFileSystem::ZipFsDir
In: lib/zip/zipfilesystem.rb
Parent: Object

Instances of this class are normally accessed via the accessor ZipFile::dir. An instance of ZipFsDir behaves like ruby‘s builtin Dir (class) object, except it works on ZipFile entries.

The individual methods are not documented due to their similarity with the methods in Dir

Methods

chdir   chroot   delete   entries   foreach   getwd   mkdir   new   new   open   pwd   rmdir   unlink  

Attributes

file  [W] 

Public Class methods

[Source]

# File lib/zip/zipfilesystem.rb, line 424
      def initialize(mappedZip)
        @mappedZip = mappedZip
      end

Public Instance methods

[Source]

# File lib/zip/zipfilesystem.rb, line 450
      def chdir(aDirectoryName)
        unless @file.stat(aDirectoryName).directory?
          raise Errno::EINVAL, "Invalid argument - #{aDirectoryName}"
        end
        @mappedZip.pwd = @file.expand_path(aDirectoryName)
      end

[Source]

# File lib/zip/zipfilesystem.rb, line 490
      def chroot(*args)
        raise NotImplementedError, "The chroot() function is not implemented"
      end

[Source]

# File lib/zip/zipfilesystem.rb, line 477
      def delete(entryName)
        unless @file.stat(entryName).directory?
          raise Errno::EINVAL, "Invalid argument - #{entryName}"
        end
        @mappedZip.remove(entryName)
      end

[Source]

# File lib/zip/zipfilesystem.rb, line 457
      def entries(aDirectoryName)
        entries = []
        foreach(aDirectoryName) { |e| entries << e }
        entries
      end

[Source]

# File lib/zip/zipfilesystem.rb, line 463
      def foreach(aDirectoryName)
        unless @file.stat(aDirectoryName).directory?
          raise Errno::ENOTDIR, aDirectoryName
        end
        path = @file.expand_path(aDirectoryName).ensure_end("/")

        subDirEntriesRegex = Regexp.new("^#{path}([^/]+)$")
        @mappedZip.each { 
          |fileName|
          match = subDirEntriesRegex.match(fileName)
          yield(match[1]) unless match == nil
        }
      end
getwd()

Alias for pwd

[Source]

# File lib/zip/zipfilesystem.rb, line 486
      def mkdir(entryName, permissionInt = 0755)
        @mappedZip.mkdir(entryName, permissionInt)
      end

[Source]

# File lib/zip/zipfilesystem.rb, line 430
      def new(aDirectoryName)
        ZipFsDirIterator.new(entries(aDirectoryName))
      end

[Source]

# File lib/zip/zipfilesystem.rb, line 434
      def open(aDirectoryName)
        dirIt = new(aDirectoryName)
        if block_given?
          begin
            yield(dirIt)
            return nil
          ensure
            dirIt.close
          end
        end
        dirIt
      end

[Source]

# File lib/zip/zipfilesystem.rb, line 447
      def pwd; @mappedZip.pwd; end
rmdir(entryName)

Alias for delete

unlink(entryName)

Alias for delete

[Validate]