Class: Zip::ZipFileSystem::ZipFsFile

### Home Classes Methods

### In Files

- lib/zip/zipfilesystem.rb

### Parent

Object

### Namespace

- CLASS Zip::ZipFileSystem::ZipFsFile::ZipFsStat

### Methods

- ::new
- #atime
- #basename
- #blockdev?
- #chardev?
- #chmod
- #chown
- #ctime
- #delete
- #directory?
- #dirname
- #executable?
- #executable_real?
- #exist?
- #exists?
- #expand_path
- #file?
- #foreach
- #ftype
- #grpowned?
- #join
- #link
- #lstat
- #mtime
- #new
- #open
- #owned?
- #pipe
- #pipe?
- #popen
- #read
- #readable?
- #readable_real?
- #readlines
- #readlink
- #rename
- #setgid?
- #setuid?
- #size
- #size?
- #socket?
- #split
- #stat
- #sticky?
- #symlink
- #symlink?
- #truncate
- #umask
- #unlink
- #utime
- #writable?
- #writable_real?
- #zero?

### 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::ZipFsFile

Instances of this class are normally accessed via the accessor ZipFile::file. An instance of ZipFsFile behaves like ruby's builtin File (class) object, except it works on ZipFile entries.

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

### Attributes

dir[W]

### Public Class Methods

new(mappedZip) click to toggle source

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

### Public Instance Methods

atime(fileName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 319
    def atime(fileName)
      e = get_entry(fileName)
      if e.extra.member? "UniversalTime"
        e.extra["UniversalTime"].atime
      else
        nil
      end
    end

basename(fileName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 297
    def basename(fileName)
      ::File.basename(fileName)
    end

blockdev?(filename) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 341
    def blockdev?(filename)
      false
    end

chardev?(filename) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 345
    def chardev?(filename)
      false
    end

chmod(modeInt, *filenames) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 270
    def chmod (modeInt, *filenames)
      filenames.each { |fileName|
        e = get_entry(fileName)
        e.fstype = 3 # force convertion filesystem type to unix
        e.unix_perms = modeInt
        e.externalFileAttributes = modeInt << 16
        e.dirty = true
      }
      filenames.size
    end

chown(ownerInt, groupInt, *filenames) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 258
    def chown(ownerInt, groupInt, *filenames)
      filenames.each { |fileName|
        e = get_entry(fileName)
        unless e.extra.member?("IUnix")
          e.extra.create("IUnix")
        end
        e.extra["IUnix"].uid = ownerInt
        e.extra["IUnix"].gid = groupInt
      }
      filenames.size
    end

ctime(fileName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 328
    def ctime(fileName)
      e = get_entry(fileName)
      if e.extra.member? "UniversalTime"
        e.extra["UniversalTime"].ctime
      else
        nil
      end
    end

delete(*args) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 402
    def delete(*args)
      args.each {
        |fileName|
        if directory?(fileName)
          raise Errno::EISDIR, "Is a directory - \"#{fileName}\""
        end
        @mappedZip.remove(fileName)
      }
    end

Also aliased as: unlink
directory?(fileName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 227
    def directory?(fileName)
      entry = @mappedZip.find_entry(fileName)
      expand_path(fileName) == "/" || (entry != nil && entry.directory?)
    end

dirname(fileName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 293
    def dirname(fileName)
      ::File.dirname(fileName)
    end

executable?(fileName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 202
    def executable?(fileName)
      unix_mode_cmp(fileName, 0111)
    end

Also aliased as: executable_real?
executable_real?(fileName) click to toggle source
Alias for: executable?
exist?(fileName) click to toggle source
Alias for: exists?
exists?(fileName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 183
    def exists?(fileName)
      expand_path(fileName) == "/" || @mappedZip.find_entry(fileName) != nil
    end

Also aliased as: exist?, owned?, grpowned?
expand_path(aPath) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 418
    def expand_path(aPath)
      @mappedZip.expand_path(aPath)
    end

file?(fileName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 288
    def file?(fileName)
      entry = @mappedZip.find_entry(fileName)
      entry != nil && entry.file?
    end

foreach(fileName, aSep = $/, &aProc) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 398
    def foreach(fileName, aSep = $/, &aProc)
      open(fileName) { |is| is.each_line(aSep, &aProc) }
    end

ftype(fileName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 357
    def ftype(fileName)
      @mappedZip.get_entry(fileName).directory? ? "directory" : "file"
    end

grpowned?(fileName) click to toggle source
Alias for: exists?
join(*fragments) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 305
    def join(*fragments)
      ::File.join(*fragments)
    end

link(fileName, symlinkName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 369
    def link(fileName, symlinkName)
      raise NotImplementedError, "The link() function is not implemented"
    end

lstat(fileName) click to toggle source
Alias for: stat
mtime(fileName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 315
    def mtime(fileName)
      @mappedZip.get_entry(fileName).mtime
    end

new(fileName, openMode = "r") click to toggle source

    # File lib/zip/zipfilesystem.rb, line 244
    def new(fileName, openMode = "r")
      open(fileName, openMode)
    end

open(fileName, openMode = "r", permissionInt = 0644, &block) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 232
    def open(fileName, openMode = "r", permissionInt = 0644, &block)
      openMode.gsub!("b", "") # ignore b option
      case openMode
        when "r"
          @mappedZip.get_input_stream(fileName, &block)
        when "w"
          @mappedZip.get_output_stream(fileName, permissionInt, &block)
        else
          raise StandardError, "openmode '#{openMode} not supported" unless openMode == "r"
      end
    end

owned?(fileName) click to toggle source

Permissions not implemented, so if the file exists it is accessible

Alias for: exists?
pipe() click to toggle source

    # File lib/zip/zipfilesystem.rb, line 373
    def pipe
      raise NotImplementedError, "The pipe() function is not implemented"
    end

pipe?(filename) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 337
    def pipe?(filename)
      false
    end

popen(*args, &aProc) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 394
    def popen(*args, &aProc)
      File.popen(*args, &aProc)
    end

read(fileName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 390
    def read(fileName)
      @mappedZip.read(fileName)
    end

readable?(fileName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 192
    def readable?(fileName)
      unix_mode_cmp(fileName, 0444)
    end

Also aliased as: readable_real?
readable_real?(fileName) click to toggle source
Alias for: readable?
readlines(fileName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 386
    def readlines(fileName)
      open(fileName) { |is| is.readlines }
    end

readlink(fileName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 361
    def readlink(fileName)
      raise NotImplementedError, "The readlink() function is not implemented"
    end

rename(fileToRename, newName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 412
    def rename(fileToRename, newName)
      @mappedZip.rename(fileToRename, newName) { true }
    end

setgid?(fileName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 211
    def setgid?(fileName)
      unix_mode_cmp(fileName, 02000)
    end

setuid?(fileName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 207
    def setuid?(fileName)
      unix_mode_cmp(fileName, 04000)
    end

size(fileName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 248
    def size(fileName)
      @mappedZip.get_entry(fileName).size
    end

size?(fileName) click to toggle source

Returns nil for not found and nil for directories

    # File lib/zip/zipfilesystem.rb, line 253
    def size?(fileName)
      entry = @mappedZip.find_entry(fileName)
      return (entry == nil || entry.directory?) ? nil : entry.size
    end

socket?(fileName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 353
    def socket?(fileName)
      false
    end

split(fileName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 301
    def split(fileName)
      ::File.split(fileName)
    end

stat(fileName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 377
    def stat(fileName)
      if ! exists?(fileName)
        raise Errno::ENOENT, fileName
      end
      ZipFsStat.new(self, fileName)
    end

Also aliased as: lstat
sticky?(fileName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 215
    def sticky?(fileName)
      unix_mode_cmp(fileName, 01000)
    end

symlink(fileName, symlinkName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 365
    def symlink(fileName, symlinkName)
      raise NotImplementedError, "The symlink() function is not implemented"
    end

symlink?(fileName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 349
    def symlink?(fileName)
      false
    end

truncate(fileName, len) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 223
    def truncate(fileName, len)
      raise StandardError, "truncate not supported"
    end

umask(*args) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 219
    def umask(*args)
      ::File.umask(*args)
    end

unlink(*args) click to toggle source
Alias for: delete
utime(modifiedTime, *fileNames) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 309
    def utime(modifiedTime, *fileNames)
      fileNames.each { |fileName|
        get_entry(fileName).time = modifiedTime
      }
    end

writable?(fileName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 197
    def writable?(fileName)
      unix_mode_cmp(fileName, 0222)
    end

Also aliased as: writable_real?
writable_real?(fileName) click to toggle source
Alias for: writable?
zero?(fileName) click to toggle source

    # File lib/zip/zipfilesystem.rb, line 281
    def zero?(fileName)
      sz = size(fileName)
      sz == nil || sz == 0
    rescue Errno::ENOENT
      false
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.