CMS 3D CMS Logo

ZipMember.h

Go to the documentation of this file.
00001 #ifndef CLASSLIB_MEMBER_H
00002 # define CLASSLIB_MEMBER_H
00003 
00004 //<<<<<< INCLUDES                                                       >>>>>>
00005 
00006 # include "classlib/zip/ZConstants.h"
00007 # include "classlib/iobase/Filename.h"
00008 
00009 namespace lat {
00010 //<<<<<< PUBLIC DEFINES                                                 >>>>>>
00011 //<<<<<< PUBLIC CONSTANTS                                               >>>>>>
00012 //<<<<<< PUBLIC TYPES                                                   >>>>>>
00013 //<<<<<< PUBLIC VARIABLES                                               >>>>>>
00014 //<<<<<< PUBLIC FUNCTIONS                                               >>>>>>
00015 //<<<<<< CLASS DECLARATIONS                                             >>>>>>
00016 
00025 class ZipMember : public ZConstants
00026 {
00027 public:
00028     // FIXME: Check that name is <256 characters.
00029 
00030     // FIXME: Check that extra data and comment is <65536 bytes.
00031 
00032     // FIXME: File format restricts file data length to <32bits.
00033 
00034     // FIXME: CRC-32 and data length (compressed and real) are valid
00035     // only on reading, or once the member output stream is closed on
00036     // write.
00037 
00038     // FIXME: Comment, global extra field and file attributes are
00039     // valid only when read from ZipArchive, or if they were given on
00040     // member creation for write, or once ZipInputStream has reached
00041     // the end of the archive (at which point already seen ZipMembers
00042     // will be completed with the central directory info).
00043 
00044     // FIXME: Not all the information is available in one place -- it
00045     // must be merged from central and local headers.  ZipArchive must
00046     // read both on archive open, as well as fetch all the comment and
00047     // extra data fields even if they are never accessed; otherwise
00048     // will end up in horrible mess of needing to seek around the
00049     // archive.  To be able to share this one class implementation
00050     // with both streams and archives, read it all.
00051 
00052     enum ExtraField { LOCAL = 0, CENTRAL = 1 };
00053     enum Attribute { INTERNAL = 0, EXTERNAL = 1 };
00054     enum SizeType { COMPRESSED = 0, UNCOMPRESSED = 1 };
00055     enum UnsetMethod { NONE = ~0U };
00056 
00057     ZipMember (Filename name);
00058     ZipMember (const ZipMember &x);
00059     ZipMember &operator= (const ZipMember &x);
00060     ~ZipMember (void);
00061 
00062     // FIXME: level = ZLIB level?
00063     //   ZLIB level:   ZIP level:      (flag & 6):  (= ziplevel << 2)
00064     //     3-7          0 (normal)         0
00065     //     8-9          1 (best)           2
00066     //     2            2 (fast)           4
00067     //     1            3 (extra fast)     6
00068 
00069     Filename            name (void) const;
00070     IOOffset            position (void) const;
00071     IOOffset            size (SizeType which) const;
00072     unsigned            crc32 (void) const;
00073 
00074     std::string         comment (void) const; // unavailble in stream reading
00075     Time                time (void) const;
00076 
00077     unsigned            method (void) const;
00078     unsigned            level (void) const;
00079     bool                isDirectory (void) const;
00080     unsigned            flags (void) const;
00081 
00082     unsigned            attributes (Attribute which = EXTERNAL) const;
00083     void                extra (ExtraField which, void **buffer,
00084                                IOSize *size) const;
00085 
00086     // Interface for writers.  Size and CRC-32 are filled when the
00087     // member output stream is closed or flushed, and updated back to
00088     // this member.  @ZipArchive seeks back to overwrite the local
00089     // header; @ZipOutputStream buffers compressed output until the
00090     // values are known and then streams the whole lot out.
00091     void                position (IOOffset value);
00092     void                size (SizeType which, IOOffset value);
00093     void                crc32 (unsigned value);
00094 
00095     void                comment (const std::string &value);
00096     void                time (Time value);
00097 
00098     void                method (Method value);
00099     void                level (unsigned value);
00100     void                isDirectory (bool value);
00101 
00102     void                attributes (Attribute which, unsigned value);
00103     void                extra (ExtraField which, void *buffer, IOSize size);
00104 
00105 private:
00106     Filename            m_name;         //< Name of the archive member
00107     std::string         m_comment;      //< Comment field
00108     IOOffset            m_position;     //< Archive byte position
00109     void                *m_xlocal;      //< Extra file header data
00110     IOSize              m_xlocalLen;    //< Length of extra file header data
00111     void                *m_xglobal;     //< Extra directory data
00112     IOSize              m_xglobalLen;   //< Length of extra directory data
00113     Time                m_time;         //< Modification time
00114     IOOffset            m_csize;        //< Compressed size
00115     IOOffset            m_dsize;        //< Decompressed size
00116     unsigned            m_method;       //< Compression method
00117     unsigned            m_level;        //< Compression level
00118     unsigned            m_crc32;        //< CRC-32 for all decompressed data
00119     unsigned            m_attrInt;      //< Internal file attributes
00120     unsigned            m_attrExt;      //< External file attributes
00121     bool                m_directory;    //< Flag indicating this is a directory
00122 };
00123 
00124 //<<<<<< INLINE PUBLIC FUNCTIONS                                        >>>>>>
00125 //<<<<<< INLINE MEMBER FUNCTIONS                                        >>>>>>
00126 
00127 } // namespace lat
00128 #endif // CLASSLIB_MEMBER_H

Generated on Tue Jun 9 17:39:00 2009 for CMSSW by  doxygen 1.5.4