mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 12:01:50 +00:00
add ZipFileDevice (WIP)
This commit is contained in:
parent
decb820cf9
commit
7f4b074d70
2 changed files with 223 additions and 0 deletions
48
src/io/devices/ZipFileDevice.hpp
Normal file
48
src/io/devices/ZipFileDevice.hpp
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
#pragma once
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "Device.hpp"
|
||||
|
||||
namespace io {
|
||||
class ZipFileDevice : public Device {
|
||||
struct Entry {
|
||||
uint16_t versionMadeBy;
|
||||
uint16_t versionNeeded;
|
||||
uint16_t flags;
|
||||
uint16_t compressionMethod;
|
||||
uint16_t modTime;
|
||||
uint16_t modDate;
|
||||
uint32_t crc32;
|
||||
uint32_t compressedSize;
|
||||
uint32_t uncompressedSize;
|
||||
uint16_t diskNumberStart;
|
||||
uint16_t internalAttributes;
|
||||
uint32_t externalAttributes;
|
||||
uint32_t localHeaderOffset;
|
||||
std::string fileName;
|
||||
size_t blobOffset = 0;
|
||||
};
|
||||
public:
|
||||
ZipFileDevice(std::unique_ptr<std::istream> file);
|
||||
|
||||
std::filesystem::path resolve(std::string_view path) override;
|
||||
std::unique_ptr<std::ostream> write(std::string_view path) override;
|
||||
std::unique_ptr<std::istream> read(std::string_view path) override;
|
||||
size_t size(std::string_view path) override;
|
||||
bool exists(std::string_view path) override;
|
||||
bool isdir(std::string_view path) override;
|
||||
bool isfile(std::string_view path) override;
|
||||
bool mkdir(std::string_view path) override;
|
||||
bool mkdirs(std::string_view path) override;
|
||||
bool remove(std::string_view path) override;
|
||||
uint64_t removeAll(std::string_view path) override;
|
||||
std::unique_ptr<PathsGenerator> list(std::string_view path) override;
|
||||
private:
|
||||
std::unique_ptr<std::istream> file;
|
||||
std::unordered_map<std::string, Entry> entries;
|
||||
|
||||
Entry readEntry();
|
||||
void findBlob(Entry& entry);
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue