This commit is contained in:
2025-10-19 22:01:31 +02:00
parent 16306f2325
commit 2b4523d644
101 changed files with 2058 additions and 1564 deletions

View File

@@ -1,10 +1,11 @@
#ifndef RESOURCE_PACK_H
#define RESOURCE_PACK_H
#include <cstdint>
#include <string>
#include <unordered_map>
#include <vector>
#include <cstddef> // Para size_t
#include <cstdint> // Para uint8_t, uint32_t, uint64_t
#include <string> // Para string, basic_string, hash
#include <unordered_map> // Para unordered_map
#include <vector> // Para vector
struct ResourceEntry {
std::string filename;
@@ -15,30 +16,30 @@ struct ResourceEntry {
class ResourcePack {
private:
std::unordered_map<std::string, ResourceEntry> resources;
std::vector<uint8_t> data;
bool loaded;
std::unordered_map<std::string, ResourceEntry> resources_;
std::vector<uint8_t> data_;
bool loaded_;
uint32_t calculateChecksum(const std::vector<uint8_t>& data);
void encryptData(std::vector<uint8_t>& data, const std::string& key);
static auto calculateChecksum(const std::vector<uint8_t>& data) -> uint32_t;
static void encryptData(std::vector<uint8_t>& data, const std::string& key);
void decryptData(std::vector<uint8_t>& data, const std::string& key);
public:
ResourcePack();
~ResourcePack();
bool loadPack(const std::string& packFile);
bool savePack(const std::string& packFile);
auto loadPack(const std::string& pack_file) -> bool;
auto savePack(const std::string& pack_file) -> bool;
bool addFile(const std::string& filename, const std::string& filepath);
bool addDirectory(const std::string& directory);
auto addFile(const std::string& filename, const std::string& filepath) -> bool;
auto addDirectory(const std::string& directory) -> bool;
std::vector<uint8_t> getResource(const std::string& filename);
bool hasResource(const std::string& filename) const;
auto getResource(const std::string& filename) -> std::vector<uint8_t>;
auto hasResource(const std::string& filename) const -> bool;
void clear();
size_t getResourceCount() const;
std::vector<std::string> getResourceList() const;
auto getResourceCount() const -> size_t;
auto getResourceList() const -> std::vector<std::string>;
static const std::string DEFAULT_ENCRYPT_KEY;
};