From 7a81b2b396cbc57914bf6b820b7d4cc6f5b74b8a Mon Sep 17 00:00:00 2001 From: Diomendius <42310725+Diomendius@users.noreply.github.com> Date: Tue, 11 Jun 2024 02:08:39 +1200 Subject: [PATCH] Add gpr2gpa to CMake, port to *nix --- CMakeLists.txt | 18 +++++++++++++ gpr2gpa/gpr2gpa.cpp | 63 ++++++++++++++++++++++++--------------------- 2 files changed, 51 insertions(+), 30 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ba031a..ef25998 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -335,5 +335,23 @@ target_include_directories(hqx2gp PRIVATE ) target_link_libraries(hqx2gp PortabilityLayer) +add_executable(gpr2gpa + gpr2gpa/gpr2gpa.cpp + gpr2gpa/macedec.cpp + AerofoilPortable/GpAllocator_C.cpp + WindowsUnicodeToolShim/UnixUnicodeToolShim.cpp + ) +target_include_directories(gpr2gpa PRIVATE + Common + GpCommon + PortabilityLayer + AerofoilPortable + MacRomanConversion + WindowsUnicodeToolShim + rapidjson/include + zlib + ) +target_link_libraries(gpr2gpa PortabilityLayer MacRomanConversion zlib) + install (TARGETS ${EXECNAME}) diff --git a/gpr2gpa/gpr2gpa.cpp b/gpr2gpa/gpr2gpa.cpp index 2f9c4e1..27c93b0 100644 --- a/gpr2gpa/gpr2gpa.cpp +++ b/gpr2gpa/gpr2gpa.cpp @@ -31,9 +31,9 @@ #include #include #include +#include #include #include -#include "GpWindows.h" enum AudioCompressionCodecID { @@ -2432,14 +2432,11 @@ int ConvertSingleFile(const char *resPath, const PortabilityLayer::CombinedTimes const size_t numRefs = typeList.m_numRefs; { - char subName[256]; - sprintf_s(subName, "%s", resTag.m_id); - PlannedEntry entry; - entry.m_name = subName; + entry.m_name = resTag.m_id; entry.m_isDirectory = true; - contents.push_back(entry); + contents.push_back(std::move(entry)); } for (size_t rlIndex = 0; rlIndex < numRefs; rlIndex++) @@ -2458,14 +2455,15 @@ int ConvertSingleFile(const char *resPath, const PortabilityLayer::CombinedTimes if (typeList.m_resType == pictTypeID || typeList.m_resType == dateTypeID) { - char resName[256]; - sprintf_s(resName, "%s/%i.bmp", resTag.m_id, static_cast(res.m_resID)); + std::string resName = ( + std::ostringstream() << resTag.m_id << '/' << res.m_resID << ".bmp" + ).str(); - if (ContainsName(reservedNames, resName)) + if (ContainsName(reservedNames, resName.c_str())) continue; PlannedEntry entry; - entry.m_name = resName; + entry.m_name = std::move(resName); entry.m_comment = resComment; if (ImportPICT(entry.m_uncompressedContents, resData, resSize, dumpqtDir, res.m_resID)) @@ -2475,14 +2473,15 @@ int ConvertSingleFile(const char *resPath, const PortabilityLayer::CombinedTimes } else if (typeList.m_resType == sndTypeID) { - char resName[256]; - sprintf_s(resName, "%s/%i.wav", resTag.m_id, static_cast(res.m_resID)); + std::string resName = ( + std::ostringstream() << resTag.m_id << '/' << res.m_resID << ".wav" + ).str(); - if (ContainsName(reservedNames, resName)) + if (ContainsName(reservedNames, resName.c_str())) continue; PlannedEntry entry; - entry.m_name = resName; + entry.m_name = std::move(resName); entry.m_comment = resComment; if (ImportSound(entry.m_uncompressedContents, resData, resSize, res.m_resID)) @@ -2492,14 +2491,15 @@ int ConvertSingleFile(const char *resPath, const PortabilityLayer::CombinedTimes } else if (typeList.m_resType == indexStringTypeID) { - char resName[256]; - sprintf_s(resName, "%s/%i.txt", resTag.m_id, static_cast(res.m_resID)); + std::string resName = ( + std::ostringstream() << resTag.m_id << '/' << res.m_resID << ".txt" + ).str(); - if (ContainsName(reservedNames, resName)) + if (ContainsName(reservedNames, resName.c_str())) continue; PlannedEntry entry; - entry.m_name = resName; + entry.m_name = std::move(resName); entry.m_comment = resComment; if (ImportIndexedString(entry.m_uncompressedContents, resData, resSize)) @@ -2507,14 +2507,15 @@ int ConvertSingleFile(const char *resPath, const PortabilityLayer::CombinedTimes } else if (typeList.m_resType == ditlTypeID) { - char resName[256]; - sprintf_s(resName, "%s/%i.json", resTag.m_id, static_cast(res.m_resID)); + std::string resName = ( + std::ostringstream() << resTag.m_id << '/' << res.m_resID << ".json" + ).str(); - if (ContainsName(reservedNames, resName)) + if (ContainsName(reservedNames, resName.c_str())) continue; PlannedEntry entry; - entry.m_name = resName; + entry.m_name = std::move(resName); entry.m_comment = resComment; if (ImportDialogItemTemplate(entry.m_uncompressedContents, resData, resSize)) @@ -2529,15 +2530,16 @@ int ConvertSingleFile(const char *resPath, const PortabilityLayer::CombinedTimes const IconTypeSpec &iconSpec = iconTypeSpecs[i]; if (typeList.m_resType == iconSpec.m_resTypeID) { - char resName[256]; - sprintf_s(resName, "%s/%i.bmp", resTag.m_id, static_cast(res.m_resID)); + std::string resName = ( + std::ostringstream() << resTag.m_id << '/' << res.m_resID << ".bmp" + ).str(); - if (!ContainsName(reservedNames, resName)) + if (!ContainsName(reservedNames, resName.c_str())) { isIcon = true; PlannedEntry entry; - entry.m_name = resName; + entry.m_name = std::move(resName); entry.m_comment = resComment; if (ImportIcon(entry.m_uncompressedContents, resData, resSize, iconSpec.m_width, iconSpec.m_height, iconSpec.m_bpp)) @@ -2550,15 +2552,16 @@ int ConvertSingleFile(const char *resPath, const PortabilityLayer::CombinedTimes if (!isIcon) { - char resName[256]; - sprintf_s(resName, "%s/%i.bin", resTag.m_id, static_cast(res.m_resID)); + std::string resName = ( + std::ostringstream() << resTag.m_id << '/' << res.m_resID << ".bin" + ).str(); - if (ContainsName(reservedNames, resName)) + if (ContainsName(reservedNames, resName.c_str())) continue; PlannedEntry entry; - entry.m_name = resName; + entry.m_name = std::move(resName); entry.m_comment = resComment; entry.m_uncompressedContents.resize(res.GetSize());