modules/libjar/zipwriter/src/nsZipHeader.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 4 */
michael@0 5
michael@0 6 #ifndef _nsZipHeader_h_
michael@0 7 #define _nsZipHeader_h_
michael@0 8
michael@0 9 #include "nsString.h"
michael@0 10 #include "nsIOutputStream.h"
michael@0 11 #include "nsIInputStream.h"
michael@0 12 #include "nsIZipReader.h"
michael@0 13 #include "nsAutoPtr.h"
michael@0 14 #include "mozilla/Attributes.h"
michael@0 15
michael@0 16 // High word is S_IFREG, low word is DOS file attribute
michael@0 17 #define ZIP_ATTRS_FILE 0x80000000
michael@0 18 // High word is S_IFDIR, low word is DOS dir attribute
michael@0 19 #define ZIP_ATTRS_DIRECTORY 0x40000010
michael@0 20 #define PERMISSIONS_FILE 0644
michael@0 21 #define PERMISSIONS_DIR 0755
michael@0 22
michael@0 23 // Combine file type attributes with unix style permissions
michael@0 24 #define ZIP_ATTRS(p, a) ((p & 0xfff) << 16) | a
michael@0 25
michael@0 26 class nsZipHeader MOZ_FINAL : public nsIZipEntry
michael@0 27 {
michael@0 28 public:
michael@0 29 NS_DECL_ISUPPORTS
michael@0 30 NS_DECL_NSIZIPENTRY
michael@0 31
michael@0 32 nsZipHeader() :
michael@0 33 mCRC(0),
michael@0 34 mCSize(0),
michael@0 35 mUSize(0),
michael@0 36 mEAttr(0),
michael@0 37 mOffset(0),
michael@0 38 mFieldLength(0),
michael@0 39 mLocalFieldLength(0),
michael@0 40 mVersionMade(0x0300 + 23), // Generated on Unix by v2.3 (matches infozip)
michael@0 41 mVersionNeeded(20), // Requires v2.0 to extract
michael@0 42 mFlags(0),
michael@0 43 mMethod(0),
michael@0 44 mTime(0),
michael@0 45 mDate(0),
michael@0 46 mDisk(0),
michael@0 47 mIAttr(0),
michael@0 48 mInited(false),
michael@0 49 mWriteOnClose(false),
michael@0 50 mExtraField(nullptr),
michael@0 51 mLocalExtraField(nullptr)
michael@0 52 {
michael@0 53 }
michael@0 54
michael@0 55 ~nsZipHeader()
michael@0 56 {
michael@0 57 mExtraField = nullptr;
michael@0 58 mLocalExtraField = nullptr;
michael@0 59 }
michael@0 60
michael@0 61 uint32_t mCRC;
michael@0 62 uint32_t mCSize;
michael@0 63 uint32_t mUSize;
michael@0 64 uint32_t mEAttr;
michael@0 65 uint32_t mOffset;
michael@0 66 uint32_t mFieldLength;
michael@0 67 uint32_t mLocalFieldLength;
michael@0 68 uint16_t mVersionMade;
michael@0 69 uint16_t mVersionNeeded;
michael@0 70 uint16_t mFlags;
michael@0 71 uint16_t mMethod;
michael@0 72 uint16_t mTime;
michael@0 73 uint16_t mDate;
michael@0 74 uint16_t mDisk;
michael@0 75 uint16_t mIAttr;
michael@0 76 bool mInited;
michael@0 77 bool mWriteOnClose;
michael@0 78 nsCString mName;
michael@0 79 nsCString mComment;
michael@0 80 nsAutoArrayPtr<uint8_t> mExtraField;
michael@0 81 nsAutoArrayPtr<uint8_t> mLocalExtraField;
michael@0 82
michael@0 83 void Init(const nsACString & aPath, PRTime aDate, uint32_t aAttr,
michael@0 84 uint32_t aOffset);
michael@0 85 uint32_t GetFileHeaderLength();
michael@0 86 nsresult WriteFileHeader(nsIOutputStream *aStream);
michael@0 87 uint32_t GetCDSHeaderLength();
michael@0 88 nsresult WriteCDSHeader(nsIOutputStream *aStream);
michael@0 89 nsresult ReadCDSHeader(nsIInputStream *aStream);
michael@0 90 const uint8_t * GetExtraField(uint16_t aTag, bool aLocal, uint16_t *aBlockSize);
michael@0 91 nsresult PadExtraField(uint32_t aOffset, uint16_t aAlignSize);
michael@0 92 };
michael@0 93
michael@0 94 #endif

mercurial