51 lines
No EOL
883 B
C++
51 lines
No EOL
883 B
C++
|
|
#ifndef ARCHIVE_H
|
|
#define ARCHIVE_H
|
|
|
|
#include <Spectre/Core/Buffer.h>
|
|
#include <Spectre/System/File.h>
|
|
#include <string>
|
|
#include <vector>
|
|
#include <map>
|
|
#include <cstdint>
|
|
|
|
struct Header {
|
|
uint8_t sig[2];
|
|
uint8_t version;
|
|
|
|
// how many indexes we have.
|
|
// uint32_t num_index;
|
|
// uint32_t data_offset;
|
|
};
|
|
|
|
#define ARCHIVE_PATH_MAX_LEN 100
|
|
|
|
struct Index {
|
|
char path[ARCHIVE_PATH_MAX_LEN];
|
|
uint32_t size;
|
|
};
|
|
|
|
class Archive
|
|
{
|
|
public:
|
|
void add(const std::string& path, const std::vector<uint8_t>& data);
|
|
|
|
const std::map<std::string, std::vector<uint8_t>>& files() const;
|
|
|
|
void read(const std::string& filename);
|
|
|
|
void write(const std::string& filename);
|
|
|
|
protected:
|
|
|
|
void pack(sp::core::Buffer<uint8_t>& buffer);
|
|
|
|
protected:
|
|
|
|
std::map<std::string, std::vector<uint8_t>> m_files;
|
|
|
|
//std::vector<struct Index> m_idx;
|
|
//std::vector<uint8_t> m_data;
|
|
};
|
|
|
|
#endif /* ARCHIVE_H */ |