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

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

Methods

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   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?  

Classes and Modules

Class Zip::ZipFileSystem::ZipFsFile::ZipFsStat

Attributes

dir  [W] 

Public Class methods

[Source]

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

Public Instance methods

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

# File lib/zip/zipfilesystem.rb, line 253
      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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

Alias for executable?

exist?(fileName)

Alias for exists?

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

Alias for exists?

[Source]

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

[Source]

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

Alias for stat

[Source]

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

[Source]

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

[Source]

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

Alias for exists?

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

Alias for readable?

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

Returns nil for not found and nil for directories

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

Alias for delete

[Source]

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

[Source]

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

Alias for writable?

[Source]

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

[Validate]