Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Private Member Functions
nsZipItem Class Reference

This file defines some of the basic structures used by libjar to read Zip files. More...

#include <nsZipArchive.h>

Collaboration diagram for nsZipItem:
Collaboration graph
[legend]

List of all members.

Public Member Functions

PRTime GetModTime ()
 GetModTime.
 nsZipItem ()
 ~nsZipItem ()

Public Attributes

char * name
PRUint32 headerOffset
PRUint32 dataOffset
PRUint32 size
PRUint32 realsize
PRUint32 crc32
nsZipItemnext
PRUint16 mode
PRUint16 time
PRUint16 date
PRUint8 compression
PRPackedBool hasDataOffset: 1
PRPackedBool isSymlink: 1

Private Member Functions

nsZipItemoperator= (const nsZipItem &rhs)
 nsZipItem (const nsZipItem &rhs)

Detailed Description

This file defines some of the basic structures used by libjar to read Zip files.

It makes use of zlib in order to do the decompression.

A few notes on the classes: nsZipArchive represents a single Zip file, and maintains an index of all the items in the file. nsZipItem represents a single item (file) in the Zip archive. nsZipReadState represents a read-in-progress, and maintains all zlib state nsZipFind represents the metadata involved in doing a search, and current state of the iteration of found objects.

There is a lot of #ifdef STANDALONE here, and that is so that these basic structures can be reused in a standalone static library. In order for the code to be reused, these structures should never use anything from XPCOM, including such obvious things as NS_ASSERTION(). Instead, use the basic NSPR equivalents.

There is one key difference in the way that this code behaves in STANDALONE mode. In STANDALONE mode, the nsZipArchive owns the single file descriptor and that is used to read the ZIP file. Since there is only one nsZipArchive per file, you can only read one file at a time from the Zip file.

In non-STANDALONE mode, nsZipReadState owns the file descriptor. Since there can be multiple nsZipReadStates in existence at the same time, there can be multiple reads from the same nsZipArchive happening at the same time. nsZipItem -- a helper class for nsZipArchive

each nsZipItem represents one file in the archive and all the information needed to manipulate it.

Definition at line 111 of file nsZipArchive.h.


Constructor & Destructor Documentation

Definition at line 1770 of file nsZipArchive.cpp.

                     : name(0), headerOffset(0), dataOffset(0), next(0), hasDataOffset(0), isSymlink(0)
{
}

Definition at line 1774 of file nsZipArchive.cpp.

{
#ifdef STANDALONE
  if (name != 0)
  {
    delete [] name;
    name = 0;
  }
#endif
}
nsZipItem::nsZipItem ( const nsZipItem rhs) [private]

Member Function Documentation

GetModTime.

Utility to get an NSPR-friendly formatted string representing the last modified time of this item.

Returns:
nsprstr The modification time in PRTime

Definition at line 1894 of file nsZipArchive.cpp.

{
  char buffer[17];

  PRUint16 aDate = this->date;
  PRUint16 aTime = this->time;

  PR_snprintf(buffer, sizeof(buffer), "%02d/%02d/%04d %02d:%02d",
        ((aDate >> 5) & 0x0F), (aDate & 0x1F), (aDate >> 9) + 1980,
        ((aTime >> 11) & 0x1F), ((aTime >> 5) & 0x3F));

  PRTime result;
  PR_ParseTimeString(buffer, PR_FALSE, &result);
  return result;
}

Here is the call graph for this function:

nsZipItem& nsZipItem::operator= ( const nsZipItem rhs) [private]

Member Data Documentation

Definition at line 134 of file nsZipArchive.h.

Definition at line 120 of file nsZipArchive.h.

Definition at line 117 of file nsZipArchive.h.

Definition at line 129 of file nsZipArchive.h.

Definition at line 135 of file nsZipArchive.h.

Definition at line 116 of file nsZipArchive.h.

Definition at line 136 of file nsZipArchive.h.

Definition at line 127 of file nsZipArchive.h.

Definition at line 114 of file nsZipArchive.h.

Definition at line 122 of file nsZipArchive.h.

Definition at line 119 of file nsZipArchive.h.

Definition at line 118 of file nsZipArchive.h.

Definition at line 128 of file nsZipArchive.h.


The documentation for this class was generated from the following files: