Module: Zip::ZipFileSystem

### Home Classes Methods

### In Files

- lib/zip/zipfilesystem.rb

### Namespace

- CLASS Zip::ZipFileSystem::ZipFsDir
- CLASS Zip::ZipFileSystem::ZipFsFile

### Methods

- #dir
- #file

### Class/Module Index

Quicksearch

- Zip
- Zip::ZipCentralDirectory
- Zip::ZipCompressionMethodError
- Zip::ZipDestinationFileExistsError
- Zip::ZipEntry
- Zip::ZipEntryExistsError
- Zip::ZipEntryNameError
- Zip::ZipError
- Zip::ZipExtraField
- Zip::ZipExtraField::Generic
- Zip::ZipExtraField::IUnix
- Zip::ZipExtraField::UniversalTime
- Zip::ZipFile
- Zip::ZipFileSystem
- Zip::ZipFileSystem::ZipFsDir
- Zip::ZipFileSystem::ZipFsFile
- Zip::ZipFileSystem::ZipFsFile::ZipFsStat
- Zip::ZipInputStream
- Zip::ZipInternalError
- Zip::ZipOutputStream
- Zip::ZipStreamableDirectory
- Zip::ZipStreamableStream
- IOExtras
- IOExtras::AbstractInputStream
- IOExtras::AbstractOutputStream
- IOExtras::FakeIO
- BugFix
- Object

No matching classes.

# Zip::ZipFileSystem

The ZipFileSystem API provides an API for accessing entries in a zip archive that is similar to ruby's builtin File and Dir classes.

Requiring 'zip/zipfilesystem' includes this module in ZipFile making the methods in this module available on ZipFile objects.

Using this API the following example creates a new zip file `my.zip` containing a normal entry with the name `first.txt`, a directory entry named `mydir` and finally another normal entry named `second.txt`

    require 'zip/zipfilesystem'

    Zip::ZipFile.open("my.zip", Zip::ZipFile::CREATE) {
      |zipfile|
      zipfile.file.open("first.txt", "w") { |f| f.puts "Hello world" }
      zipfile.dir.mkdir("mydir")
      zipfile.file.open("mydir/second.txt", "w") { |f| f.puts "Hello again" }
    }

Reading is as easy as writing, as the following example shows. The example writes the contents of `first.txt` from zip archive `my.zip` to standard out.

    require 'zip/zipfilesystem'

    Zip::ZipFile.open("my.zip") {
      |zipfile|
      puts zipfile.file.read("first.txt")
    }

### Public Instance Methods

dir() click to toggle source

Returns a ZipFsDir which is much like ruby's builtin Dir (class) object, except it works on the ZipFile on which this method is invoked

    # File lib/zip/zipfilesystem.rb, line 50
    def dir
      @zipFsDir
    end

file() click to toggle source

Returns a ZipFsFile which is much like ruby's builtin File (class) object, except it works on the ZipFile on which this method is invoked

    # File lib/zip/zipfilesystem.rb, line 57
    def file
      @zipFsFile
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.