libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
Loading...
Searching...
No Matches
O2rArchive.h
Go to the documentation of this file.
1#pragma once
2
3#undef _DLL
4
5#include <string>
6#include <stdint.h>
7#include <string>
8#include <mutex>
9#include <vector>
10
11#include "zip.h"
12
13#include "ship/resource/File.h"
16
17namespace Ship {
18struct File;
19
30class O2rArchive final : virtual public Archive {
31 public:
36 O2rArchive(const std::string& archivePath, std::shared_ptr<ResourceManager> resourceManager = nullptr,
37 std::shared_ptr<Keystore> keystore = nullptr);
39
44 bool Open();
45
50 bool Close();
51
58 bool WriteFile(const std::string& filename, const std::vector<uint8_t>& data);
59
65 std::shared_ptr<File> LoadFile(const std::string& filePath);
66
72 std::shared_ptr<File> LoadFile(uint64_t hash);
73
74 private:
76 zip_t* GetZipHandle();
78 void ReleaseZipHandle(zip_t* handle);
79 zip_t* mZipArchive;
80 std::mutex mPoolMutex;
81 std::vector<zip_t*> mZipArchivePool;
82};
83} // namespace Ship
Abstract base class representing a mounted archive (OTR, O2R, or folder).
Definition Archive.h:61
Archive implementation backed by a ZIP file (.o2r format).
Definition O2rArchive.h:30
O2rArchive(const std::string &archivePath, std::shared_ptr< ResourceManager > resourceManager=nullptr, std::shared_ptr< Keystore > keystore=nullptr)
Constructs an O2rArchive for the given ZIP file path.
std::shared_ptr< File > LoadFile(const std::string &filePath)
Loads a file from the archive by its virtual path.
bool Open()
Opens the ZIP file via libzip, creating the internal handle pool.
bool WriteFile(const std::string &filename, const std::vector< uint8_t > &data)
Writes raw data to a file entry inside the ZIP archive.
std::shared_ptr< File > LoadFile(uint64_t hash)
Loads a file from the archive by its 64-bit hash.
bool Close()
Closes all pooled handles and releases libzip resources.
Core namespace for the libultraship engine framework.
Definition gfx_direct3d_common.h:14