fileHeader.h

Engine/source/core/util/zip/fileHeader.h

More...

Classes:

Namespaces:

namespace

Namespace for the zip code.

Detailed Description

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#include "core/util/zip/extraField.h"
 25#include "core/util/tVector.h"
 26
 27#ifndef _FILEHEADER_H_
 28#define _FILEHEADER_H_
 29
 30// Forward Refs
 31class Stream;
 32
 33namespace Zip
 34{
 35
 36/// @addtogroup zipint_group
 37/// @ingroup zip_group
 38// @{
 39
 40enum FileFlags
 41{
 42   Encrypted = BIT(0),
 43
 44   // For implode compression
 45   Implode8KDictionary = BIT(1),
 46   Implode3ShannonFanoTrees = BIT(2),
 47
 48   // For deflate compression
 49   DeflateTypeMask = BIT(1) | BIT(2),
 50
 51   FileInfoInDirectory = BIT(3),
 52
 53   // Note that much of the following flag bits are unsupported for various reasons
 54   ReservedEnhDeflate = BIT(4),
 55   PatchData = BIT(5),
 56   StrongEncryption = BIT(6),
 57
 58   UnusedReserved1 = BIT(7),
 59   UnusedReserved2 = BIT(8),
 60   UnusedReserved3 = BIT(9),
 61   UnusedReserved4 = BIT(10),
 62   UnusedReserved5 = BIT(11),
 63
 64   ReservedPKWARE1 = BIT(12),
 65
 66   EncryptedDirectory = BIT(13),
 67
 68   ReservedPKWARE2 = BIT(14),
 69   ReservedPKWARE3 = BIT(15),
 70};
 71
 72class FileHeader
 73{
 74   static const U32 mFileHeaderSignature = 0x04034b50;
 75
 76protected:
 77   bool readExtraFields(Stream *stream, U16 efLen);
 78
 79public:
 80   U32 mHeaderSig;
 81
 82   U16 mExtractVer;
 83   U16 mFlags;
 84   U16 mCompressMethod;
 85
 86   U16 mModTime;
 87   U16 mModDate;
 88
 89   U32 mCRC32;
 90
 91   U32 mCompressedSize;
 92   U32 mUncompressedSize;
 93
 94   String mFilename;
 95
 96   Vector<ExtraField*> mExtraFields;
 97
 98   FileHeader();
 99   virtual ~FileHeader();
100
101   virtual bool read(Stream *stream);
102   virtual bool write(Stream *stream);
103
104   ExtraField *findExtraField(U16 id);
105
106   void setFilename(String filename);
107};
108
109// @}
110
111} // end namespace Zip
112
113#endif
114