First
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
#pragma once
|
||||
#include "ZipBase.h"
|
||||
#include "tl/memory_buffer.h"
|
||||
#include "tl/result.h"
|
||||
#include "tl/vector.h"
|
||||
|
||||
namespace fs
|
||||
{
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class ISource;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class ZipReader : public ZipBase
|
||||
{
|
||||
public:
|
||||
enum class ErrorCode : uint8_t
|
||||
{
|
||||
InvalidStream,
|
||||
BadSignature,
|
||||
BadOffset,
|
||||
CorruptedFile,
|
||||
};
|
||||
typedef tl::error<ErrorCode> Error;
|
||||
|
||||
typedef tl::result<ZipReader, Error> CreateResult;
|
||||
|
||||
static CreateResult create(ISource& source);
|
||||
|
||||
struct Entry
|
||||
{
|
||||
tl::string name;
|
||||
CompressionMethod compressionMethod = CompressionMethod::Store;
|
||||
GeneralBitFlags generalBitFlags;
|
||||
uint64_t uncompressedSize = 0;
|
||||
uint64_t compressedSize = 0;
|
||||
uint32_t crc32 = 0;
|
||||
uint64_t localHeaderOffset = 0;
|
||||
uint64_t dataOffset = 0;
|
||||
time_t lastModTimePoint = 0;
|
||||
tl::memory_buffer comment;
|
||||
};
|
||||
|
||||
size_t getEntryCount() const;
|
||||
const Entry& getEntry(size_t index) const;
|
||||
|
||||
typedef tl::result<void, Error> SeekResult;
|
||||
SeekResult seekSourceToEntryData(const Entry& entry, ISource& o_source) const;
|
||||
|
||||
private:
|
||||
explicit ZipReader(tl::vector<Entry> entries);
|
||||
|
||||
typedef tl::result<tl::pair<uint64_t, uint64_t>, Error> CentralDirectoryResult;
|
||||
static CentralDirectoryResult findCentralDirectoryBounds(ISource& source);
|
||||
|
||||
tl::vector<Entry> m_entries;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user