Skip to content

Commit

Permalink
remove LoadFileRaw from ArchiveManager, move to protected in `Arc…
Browse files Browse the repository at this point in the history
…hive` (#459)
  • Loading branch information
briaguya-ai committed Mar 6, 2024
1 parent d70fd7d commit f79b19a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/resource/archive/Archive.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ class Archive {

virtual bool Open() = 0;
virtual bool Close() = 0;
virtual std::shared_ptr<File> LoadFileRaw(const std::string& filePath) = 0;
virtual std::shared_ptr<File> LoadFileRaw(uint64_t hash) = 0;

protected:
void SetLoaded(bool isLoaded);
void SetGameVersion(uint32_t gameVersion);
void IndexFile(const std::string& filePath);
virtual std::shared_ptr<File> LoadFileRaw(const std::string& filePath) = 0;
virtual std::shared_ptr<File> LoadFileRaw(uint64_t hash) = 0;

private:
static std::shared_ptr<ResourceInitData> CreateDefaultResourceInitData();
Expand Down
19 changes: 0 additions & 19 deletions src/resource/archive/ArchiveManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,6 @@ std::shared_ptr<File> ArchiveManager::LoadFile(uint64_t hash, std::shared_ptr<Re
return file;
}

std::shared_ptr<File> ArchiveManager::LoadFileRaw(const std::string& filePath) {
if (filePath == "") {
return nullptr;
}

return LoadFileRaw(CRC64(filePath.c_str()));
}

std::shared_ptr<File> ArchiveManager::LoadFileRaw(uint64_t hash) {
const auto archive = mFileToArchive[hash];
if (archive == nullptr) {
return nullptr;
}

auto file = archive->LoadFileRaw(hash);
file->Parent = archive;
return file;
}

bool ArchiveManager::HasFile(const std::string& filePath) {
return HasFile(CRC64(filePath.c_str()));
}
Expand Down
2 changes: 0 additions & 2 deletions src/resource/archive/ArchiveManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ class ArchiveManager {
bool IsArchiveLoaded();
std::shared_ptr<File> LoadFile(const std::string& filePath, std::shared_ptr<ResourceInitData> initData = nullptr);
std::shared_ptr<File> LoadFile(uint64_t hash, std::shared_ptr<ResourceInitData> initData = nullptr);
std::shared_ptr<File> LoadFileRaw(const std::string& filePath);
std::shared_ptr<File> LoadFileRaw(uint64_t hash);
bool HasFile(const std::string& filePath);
bool HasFile(uint64_t hash);
std::shared_ptr<std::vector<std::string>> ListFiles(const std::string& filter);
Expand Down
3 changes: 2 additions & 1 deletion src/resource/archive/O2rArchive.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ class O2rArchive : virtual public Archive {

bool Open();
bool Close();

protected:
std::shared_ptr<File> LoadFileRaw(const std::string& filePath);
std::shared_ptr<File> LoadFileRaw(uint64_t hash);

protected:
private:
zip_t* mZipArchive;
};
Expand Down
3 changes: 2 additions & 1 deletion src/resource/archive/OtrArchive.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ class OtrArchive : virtual public Archive {

bool Open();
bool Close();

protected:
std::shared_ptr<File> LoadFileRaw(const std::string& filePath);
std::shared_ptr<File> LoadFileRaw(uint64_t hash);

protected:
private:
HANDLE mHandle;
};
Expand Down

0 comments on commit f79b19a

Please sign in to comment.