|
/*
http://www.developdotnet.com
File Created by: Alberto Ferrazzoli
Date: 06/06/2004
File Description:
Zip file format structure headers. See PKWare appnote.txt
Notes:
Revision Log - Please mark significant changes in source code in the following format:
Date - Time - Reviewer - Comments
08/07/2004 Alberto Ferrazzoli Added Write methods
26/10/2004 Alberto Ferrazzoli Now Read functions, can skip signature constant
*/
#pragma once
using namespace System;
using namespace System::Collections;
using namespace System::IO;
using namespace System::Text;
using namespace System::Runtime::InteropServices;
namespace DevelopDotNet
{
namespace Compression
{
public __gc class ZipEntry;
//////////////////////////////////////////////////////////////////////////
// LocalFileHeader
//
private __gc class LocalFileHeader
{
private public:
static const UInt32 LOCALHEADERMAGIC = 0x04034b50;
private public:
UInt32 Signature;
UInt16 VersionNeeded;
UInt16 Flags;
UInt16 CompressionMethod;
UInt16 LastModFileTime;
UInt16 LastModFileDate;
UInt32 CRC32;
UInt32 CompressedSize;
UInt32 UncompressedSize;
String* FileName;
System::Byte ExtraField __gc[];
__property int get_LocalHeaderSize();
private public:
LocalFileHeader();
static bool HasValidSignature(Stream* stream);
void Read(Stream* stream);
void Read(Stream* stream, bool signature);
void Read(BinaryReader* stream, bool signature);
void Write(Stream* stream);
};
private __gc class DataDescriptor
{
private public:
UInt32 CRC32;
UInt32 CompressedSize;
UInt32 UncompressedSize;
__property int get_DataDescriptorSize();
void Read(Stream* stream);
void Write(Stream* stream);
};
//////////////////////////////////////////////////////////////////////////
// CentralFileHeader
//
private __gc class CentralFileHeader : public IComparable
{
private public:
static const UInt32 CENTRALHEADERMAGIC = 0x02014b50;
private public:
UInt32 Signature;
UInt16 VersionMadeby;
UInt16 VersionNeeded;
UInt16 Flags;
UInt16 CompressionMethod;
UInt16 LastModFileTime;
UInt16 LastModFileDate;
UInt32 CRC32;
UInt32 CompressedSize;
UInt32 UncompressedSize;
UInt16 DiskNumberStart;
UInt16 InternalFileAttributes;
UInt32 ExternalFileAttributes;
UInt32 OffsetLocalHeader;
String* FileName;
System::Byte ExtraField __gc[];
String* FileComment;
String* FullPath;
__property int get_CentralHeaderSize();
__property ZipEntry* get_Entry() { return _entry; }
__property void set_Entry(ZipEntry* value) { _entry = value; }
public:
CentralFileHeader();
CentralFileHeader(ZipEntry* entry);
Int32 CompareTo(Object* obj);
void Read(Stream* stream);
void Read(Stream* stream, bool signature);
void Read(BinaryReader* reader, bool signature);
void Write(Stream* stream);
private:
ZipEntry* _entry;
};
//////////////////////////////////////////////////////////////////////////
// EndOfCentralDirectory
//
private __gc class EndOfCentralDirectory
{
private public:
static const UInt32 ENDHEADERMAGIC = 0x06054b50;
private public:
UInt32 Signature;
UInt16 DiskNumber;
UInt16 DiskNumberStartCD;
UInt16 ThisDiskEntriesCD;
UInt16 TotalEntriesCD;
// size of central directory
UInt32 SizeCD;
// offset of start of central directory with respect to the starting disk number
UInt32 OffsetCD;
// zip file comment
String* ArchiveComment;
private public:
EndOfCentralDirectory();
void Read(Stream* stream);
void Read(Stream* stream, bool signature);
void Read(BinaryReader* reader, bool signature);
void Write(Stream* stream);
};
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.