1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-10 09:32:29 +01:00

Rename ZIP_ACCESS and its members

This commit is contained in:
Gymnasiast
2025-03-26 12:00:43 +01:00
parent b26a2953d7
commit 8d57f4d193
7 changed files with 26 additions and 26 deletions

View File

@@ -42,7 +42,7 @@ void AssetPack::SetEnabled(bool value)
void AssetPack::Fetch()
{
auto archive = Zip::Open(Path.u8string(), ZIP_ACCESS::READ);
auto archive = Zip::Open(Path.u8string(), ZipAccess::read);
if (!archive->Exists(ManifestFileName))
{
throw std::runtime_error("Manifest does not exist.");
@@ -160,7 +160,7 @@ public:
void AssetPack::Load()
{
auto path = Path.u8string();
auto archive = Zip::Open(path, ZIP_ACCESS::READ);
auto archive = Zip::Open(path, ZipAccess::read);
if (!archive->Exists(ManifestFileName))
{
throw std::runtime_error("Manifest does not exist.");

View File

@@ -70,14 +70,14 @@ class ZipArchive final : public IZipArchive
{
private:
zip_t* _zip;
ZIP_ACCESS _access;
ZipAccess _access;
std::vector<std::vector<uint8_t>> _writeBuffers;
public:
ZipArchive(std::string_view path, ZIP_ACCESS access)
ZipArchive(std::string_view path, ZipAccess access)
{
auto zipOpenMode = ZIP_RDONLY;
if (access == ZIP_ACCESS::WRITE)
if (access == ZipAccess::write)
{
zipOpenMode = ZIP_CREATE;
}
@@ -378,12 +378,12 @@ private:
namespace OpenRCT2::Zip
{
std::unique_ptr<IZipArchive> Open(std::string_view path, ZIP_ACCESS access)
std::unique_ptr<IZipArchive> Open(std::string_view path, ZipAccess access)
{
return std::make_unique<ZipArchive>(path, access);
}
std::unique_ptr<IZipArchive> TryOpen(std::string_view path, ZIP_ACCESS access)
std::unique_ptr<IZipArchive> TryOpen(std::string_view path, ZipAccess access)
{
std::unique_ptr<IZipArchive> result;
try

View File

@@ -49,14 +49,14 @@ struct IZipArchive
[[nodiscard]] bool Exists(std::string_view path) const;
};
enum class ZIP_ACCESS
enum class ZipAccess
{
READ,
WRITE,
read,
write,
};
namespace OpenRCT2::Zip
{
[[nodiscard]] std::unique_ptr<IZipArchive> Open(std::string_view path, ZIP_ACCESS zipAccess);
[[nodiscard]] std::unique_ptr<IZipArchive> TryOpen(std::string_view path, ZIP_ACCESS zipAccess);
[[nodiscard]] std::unique_ptr<IZipArchive> Open(std::string_view path, ZipAccess zipAccess);
[[nodiscard]] std::unique_ptr<IZipArchive> TryOpen(std::string_view path, ZipAccess zipAccess);
} // namespace OpenRCT2::Zip

View File

@@ -28,7 +28,7 @@ private:
jobject _zip;
public:
ZipArchive(std::string_view path, ZIP_ACCESS access)
ZipArchive(std::string_view path, ZipAccess access)
{
// retrieve the JNI environment.
JNIEnv* env = (JNIEnv*)SDL_AndroidGetJNIEnv();
@@ -139,12 +139,12 @@ public:
namespace OpenRCT2::Zip
{
std::unique_ptr<IZipArchive> Open(std::string_view path, ZIP_ACCESS access)
std::unique_ptr<IZipArchive> Open(std::string_view path, ZipAccess access)
{
return std::make_unique<ZipArchive>(path, access);
}
std::unique_ptr<IZipArchive> TryOpen(std::string_view path, ZIP_ACCESS access)
std::unique_ptr<IZipArchive> TryOpen(std::string_view path, ZipAccess access)
{
std::unique_ptr<IZipArchive> result;
try

View File

@@ -311,7 +311,7 @@ bool ObjectAsset::IsAvailable() const
return File::Exists(_path);
}
auto zipArchive = Zip::TryOpen(_zipPath, ZIP_ACCESS::READ);
auto zipArchive = Zip::TryOpen(_zipPath, ZipAccess::read);
return zipArchive != nullptr && zipArchive->Exists(_path);
}
@@ -322,7 +322,7 @@ uint64_t ObjectAsset::GetSize() const
return File::GetSize(_path);
}
auto zipArchive = Zip::TryOpen(_zipPath, ZIP_ACCESS::READ);
auto zipArchive = Zip::TryOpen(_zipPath, ZipAccess::read);
if (zipArchive != nullptr)
{
auto index = zipArchive->GetIndexFromPath(_path);
@@ -342,7 +342,7 @@ std::vector<uint8_t> ObjectAsset::GetData() const
return File::ReadAllBytes(_path);
}
auto zipArchive = Zip::TryOpen(_zipPath, ZIP_ACCESS::READ);
auto zipArchive = Zip::TryOpen(_zipPath, ZipAccess::read);
if (zipArchive != nullptr)
{
return zipArchive->GetFileData(_path);
@@ -359,7 +359,7 @@ std::unique_ptr<IStream> ObjectAsset::GetStream() const
return std::make_unique<FileStream>(_path, FileMode::open);
}
auto zipArchive = Zip::TryOpen(_zipPath, ZIP_ACCESS::READ);
auto zipArchive = Zip::TryOpen(_zipPath, ZipAccess::read);
if (zipArchive != nullptr)
{
auto stream = zipArchive->GetFileStream(_path);

View File

@@ -433,7 +433,7 @@ namespace OpenRCT2::ObjectFactory
{
try
{
auto archive = Zip::Open(path, ZIP_ACCESS::READ);
auto archive = Zip::Open(path, ZipAccess::read);
auto jsonBytes = archive->GetFileData("object.json");
if (jsonBytes.empty())
{

View File

@@ -59,7 +59,7 @@ namespace OpenRCT2::Title
auto ext = Path::GetExtension(path);
if (String::equals(ext, TITLE_SEQUENCE_EXTENSION))
{
auto zip = Zip::TryOpen(path, ZIP_ACCESS::READ);
auto zip = Zip::TryOpen(path, ZipAccess::read);
if (zip == nullptr)
{
Console::Error::WriteLine("Unable to open '%s'", path.c_str());
@@ -109,7 +109,7 @@ namespace OpenRCT2::Title
const auto& filename = seq.Saves[index];
if (seq.IsZip)
{
auto zip = Zip::TryOpen(seq.Path, ZIP_ACCESS::READ);
auto zip = Zip::TryOpen(seq.Path, ZipAccess::read);
if (zip != nullptr)
{
auto data = zip->GetFileData(filename);
@@ -159,7 +159,7 @@ namespace OpenRCT2::Title
if (seq.IsZip)
{
auto fdata = std::vector<uint8_t>(script.begin(), script.end());
auto zip = Zip::Open(seq.Path, ZIP_ACCESS::WRITE);
auto zip = Zip::Open(seq.Path, ZipAccess::write);
zip->SetFileData("script.txt", std::move(fdata));
}
else
@@ -189,7 +189,7 @@ namespace OpenRCT2::Title
try
{
auto fdata = File::ReadAllBytes(path);
auto zip = Zip::TryOpen(seq.Path, ZIP_ACCESS::WRITE);
auto zip = Zip::TryOpen(seq.Path, ZipAccess::write);
if (zip == nullptr)
{
Console::Error::WriteLine("Unable to open '%s'", seq.Path.c_str());
@@ -222,7 +222,7 @@ namespace OpenRCT2::Title
auto& oldRelativePath = seq.Saves[index];
if (seq.IsZip)
{
auto zip = Zip::TryOpen(seq.Path, ZIP_ACCESS::WRITE);
auto zip = Zip::TryOpen(seq.Path, ZipAccess::write);
if (zip == nullptr)
{
Console::Error::WriteLine("Unable to open '%s'", seq.Path.c_str());
@@ -252,7 +252,7 @@ namespace OpenRCT2::Title
auto& relativePath = seq.Saves[index];
if (seq.IsZip)
{
auto zip = Zip::TryOpen(seq.Path, ZIP_ACCESS::WRITE);
auto zip = Zip::TryOpen(seq.Path, ZipAccess::write);
if (zip == nullptr)
{
Console::Error::WriteLine("Unable to open '%s'", seq.Path.c_str());