mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-22 22:45:39 +00:00
Compare commits
33 Commits
cc4a1bbd67
...
ed4eb8e1f7
Author | SHA1 | Date | |
---|---|---|---|
|
ed4eb8e1f7 | ||
|
c8e3e8683b | ||
|
ee60ef57a1 | ||
|
2681ffc5c6 | ||
|
6a13e44dae | ||
|
68db3cd83e | ||
|
13f0874757 | ||
|
660d79980a | ||
|
f65d550300 | ||
|
d9049f3c8a | ||
|
8a5b50d98d | ||
|
91e2f3b25f | ||
|
0ebdabc12f | ||
|
8b916867d5 | ||
|
a7f5b653fa | ||
|
5c74c96771 | ||
|
e78d93437a | ||
|
c2753ec679 | ||
|
f27860776b | ||
|
77fcc35726 | ||
|
e2bb19709d | ||
|
8b2db1b142 | ||
|
77009b08ca | ||
|
7a81b2b396 | ||
|
e2da9bb7c5 | ||
|
796b2880cf | ||
|
c372fcb92d | ||
|
1e4ee9335e | ||
|
e2fcd7851d | ||
|
9aa82066f1 | ||
|
de3fdeb7b1 | ||
|
0e1af575ca | ||
|
7a7cc8b0dc |
162
CMakeLists.txt
162
CMakeLists.txt
@@ -343,13 +343,17 @@ target_include_directories(hqx2bin PRIVATE
|
||||
)
|
||||
target_link_libraries(hqx2bin PortabilityLayer)
|
||||
|
||||
add_executable(hqx2gp EXCLUDE_FROM_ALL hqx2gp/hqx2gp.cpp AerofoilPortable/GpAllocator_C.cpp)
|
||||
add_executable(hqx2gp EXCLUDE_FROM_ALL
|
||||
hqx2gp/hqx2gp.cpp
|
||||
AerofoilPortable/GpAllocator_C.cpp
|
||||
WindowsUnicodeToolShim/UnixUnicodeToolShim.cpp
|
||||
)
|
||||
target_include_directories(hqx2gp PRIVATE
|
||||
Common
|
||||
GpCommon
|
||||
PortabilityLayer
|
||||
AerofoilPortable
|
||||
UnixCompat
|
||||
WindowsUnicodeToolShim
|
||||
)
|
||||
target_link_libraries(hqx2gp PortabilityLayer)
|
||||
|
||||
@@ -357,7 +361,7 @@ add_executable(gpr2gpa EXCLUDE_FROM_ALL
|
||||
gpr2gpa/gpr2gpa.cpp
|
||||
gpr2gpa/macedec.cpp
|
||||
AerofoilPortable/GpAllocator_C.cpp
|
||||
UnixCompat/UnixCompat.cpp
|
||||
WindowsUnicodeToolShim/UnixUnicodeToolShim.cpp
|
||||
)
|
||||
target_include_directories(gpr2gpa PRIVATE
|
||||
Common
|
||||
@@ -365,52 +369,62 @@ target_include_directories(gpr2gpa PRIVATE
|
||||
PortabilityLayer
|
||||
AerofoilPortable
|
||||
MacRomanConversion
|
||||
UnixCompat
|
||||
WindowsUnicodeToolShim
|
||||
rapidjson/include
|
||||
zlib
|
||||
)
|
||||
target_link_libraries(gpr2gpa PortabilityLayer MacRomanConversion zlib)
|
||||
|
||||
add_executable(MakeTimestamp EXCLUDE_FROM_ALL MakeTimestamp/MakeTimestamp.cpp)
|
||||
target_include_directories(MakeTimestamp PRIVATE PortabilityLayer UnixCompat)
|
||||
target_include_directories(MakeTimestamp PRIVATE PortabilityLayer)
|
||||
target_link_libraries(MakeTimestamp PortabilityLayer)
|
||||
|
||||
add_executable(FTagData EXCLUDE_FROM_ALL FTagData/FTagData.cpp)
|
||||
add_executable(FTagData EXCLUDE_FROM_ALL
|
||||
FTagData/FTagData.cpp
|
||||
WindowsUnicodeToolShim/UnixUnicodeToolShim.cpp
|
||||
)
|
||||
target_include_directories(FTagData PRIVATE
|
||||
Common
|
||||
GpCommon
|
||||
PortabilityLayer
|
||||
AerofoilPortable
|
||||
UnixCompat
|
||||
WindowsUnicodeToolShim
|
||||
)
|
||||
target_link_libraries(FTagData PortabilityLayer)
|
||||
|
||||
add_executable(MergeGPF EXCLUDE_FROM_ALL MergeGPF/MergeGPF.cpp AerofoilPortable/GpAllocator_C.cpp)
|
||||
add_executable(MergeGPF EXCLUDE_FROM_ALL
|
||||
MergeGPF/MergeGPF.cpp
|
||||
AerofoilPortable/GpAllocator_C.cpp
|
||||
WindowsUnicodeToolShim/UnixUnicodeToolShim.cpp
|
||||
)
|
||||
target_include_directories(MergeGPF PRIVATE
|
||||
Common
|
||||
GpCommon
|
||||
PortabilityLayer
|
||||
AerofoilPortable
|
||||
UnixCompat
|
||||
WindowsUnicodeToolShim
|
||||
)
|
||||
target_link_libraries(MergeGPF PortabilityLayer)
|
||||
|
||||
add_executable(MiniRez EXCLUDE_FROM_ALL MiniRez/MiniRez.cpp)
|
||||
add_executable(MiniRez EXCLUDE_FROM_ALL MiniRez/MiniRez.cpp WindowsUnicodeToolShim/UnixUnicodeToolShim.cpp)
|
||||
target_include_directories(MiniRez PRIVATE
|
||||
Common
|
||||
GpCommon
|
||||
PortabilityLayer
|
||||
UnixCompat
|
||||
WindowsUnicodeToolShim
|
||||
)
|
||||
target_link_libraries(MiniRez PortabilityLayer)
|
||||
|
||||
add_executable(HouseTool EXCLUDE_FROM_ALL HouseTool/HouseTool.cpp)
|
||||
add_executable(HouseTool EXCLUDE_FROM_ALL
|
||||
HouseTool/HouseTool.cpp
|
||||
WindowsUnicodeToolShim/UnixUnicodeToolShim.cpp
|
||||
)
|
||||
target_include_directories(HouseTool PRIVATE
|
||||
Common
|
||||
GpCommon
|
||||
PortabilityLayer
|
||||
MacRomanConversion
|
||||
UnixCompat
|
||||
WindowsUnicodeToolShim
|
||||
)
|
||||
target_link_libraries(HouseTool PortabilityLayer MacRomanConversion)
|
||||
|
||||
@@ -438,13 +452,14 @@ add_executable(unpacktool EXCLUDE_FROM_ALL
|
||||
unpacktool/StuffItHuffmanDecompressor.cpp
|
||||
unpacktool/StuffItParser.cpp
|
||||
unpacktool/unpacktool.cpp
|
||||
WindowsUnicodeToolShim/UnixUnicodeToolShim.cpp
|
||||
)
|
||||
target_include_directories(unpacktool PRIVATE
|
||||
Common
|
||||
GpCommon
|
||||
PortabilityLayer
|
||||
MacRomanConversion
|
||||
UnixCompat
|
||||
WindowsUnicodeToolShim
|
||||
)
|
||||
target_link_libraries(unpacktool PortabilityLayer MacRomanConversion)
|
||||
|
||||
@@ -464,13 +479,17 @@ if(FREETYPE_FOUND)
|
||||
target_link_libraries(GpFontHandler_FreeType2 PRIVATE Freetype::Freetype)
|
||||
|
||||
|
||||
add_executable(GenerateFonts EXCLUDE_FROM_ALL GenerateFonts/GenerateFonts.cpp AerofoilPortable/GpAllocator_C.cpp)
|
||||
add_executable(GenerateFonts EXCLUDE_FROM_ALL
|
||||
GenerateFonts/GenerateFonts.cpp
|
||||
AerofoilPortable/GpAllocator_C.cpp
|
||||
WindowsUnicodeToolShim/UnixUnicodeToolShim.cpp
|
||||
)
|
||||
target_include_directories(GenerateFonts PRIVATE
|
||||
Common
|
||||
GpCommon
|
||||
PortabilityLayer
|
||||
AerofoilPortable
|
||||
UnixCompat
|
||||
WindowsUnicodeToolShim
|
||||
)
|
||||
target_link_libraries(GenerateFonts PortabilityLayer GpFontHandler_FreeType2)
|
||||
endif()
|
||||
@@ -479,6 +498,7 @@ add_executable(ConvertColorCursors EXCLUDE_FROM_ALL
|
||||
ConvertColorCursors/ConvertColorCursors.cpp
|
||||
AerofoilPortable/GpAllocator_C.cpp
|
||||
stb/stb_image_write.c
|
||||
WindowsUnicodeToolShim/UnixUnicodeToolShim.cpp
|
||||
)
|
||||
target_include_directories(ConvertColorCursors PRIVATE
|
||||
Common
|
||||
@@ -486,12 +506,16 @@ target_include_directories(ConvertColorCursors PRIVATE
|
||||
PortabilityLayer
|
||||
AerofoilPortable
|
||||
stb
|
||||
UnixCompat
|
||||
WindowsUnicodeToolShim
|
||||
)
|
||||
target_link_libraries(ConvertColorCursors PortabilityLayer)
|
||||
|
||||
|
||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Packaged/Houses")
|
||||
add_custom_target(BuildDirs
|
||||
BYPRODUCTS Packaged tmp
|
||||
COMMAND "${CMAKE_COMMAND}" -E make_directory Packaged/Houses tmp
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
set(DATA_FILES)
|
||||
|
||||
@@ -499,87 +523,61 @@ function(add_data_file NAME)
|
||||
list(APPEND DATA_FILES "Packaged/${NAME}")
|
||||
set(DATA_FILES "${DATA_FILES}" PARENT_SCOPE)
|
||||
|
||||
cmake_parse_arguments(PARSE_ARGV 1 ARG
|
||||
""
|
||||
""
|
||||
"BYPRODUCTS;COMMANDS"
|
||||
cmake_parse_arguments(PARSE_ARGV 1 ARG "" "" "")
|
||||
set(TMPDIR "${CMAKE_CURRENT_BINARY_DIR}/tmp/${NAME}")
|
||||
list(TRANSFORM ARG_UNPARSED_ARGUMENTS
|
||||
REPLACE {TMPDIR} "${TMPDIR}"
|
||||
)
|
||||
|
||||
if(ARG_BYPRODUCTS)
|
||||
set(RM_BYPRODUCTS_COMMAND COMMAND "${CMAKE_COMMAND}" -E rm)
|
||||
set(RM_BYPRODUCTS_PATHS "${ARG_BYPRODUCTS}")
|
||||
list(TRANSFORM RM_BYPRODUCTS_PATHS PREPEND "${CMAKE_CURRENT_BINARY_DIR}/")
|
||||
endif()
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT "Packaged/${NAME}"
|
||||
BYPRODUCTS ${ARG_BYPRODUCTS}
|
||||
${ARG_COMMANDS}
|
||||
${RM_BYPRODUCTS_COMMAND} ${RM_BYPRODUCTS_PATHS}
|
||||
DEPENDS BuildDirs
|
||||
COMMAND "${CMAKE_COMMAND}" -E make_directory "${TMPDIR}"
|
||||
${ARG_UNPARSED_ARGUMENTS}
|
||||
COMMAND "${CMAKE_COMMAND}" -E rename
|
||||
"${TMPDIR}/${NAME}"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/Packaged/${NAME}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E rm -r -- "${TMPDIR}"
|
||||
VERBATIM
|
||||
)
|
||||
endfunction()
|
||||
|
||||
add_data_file(ApplicationResources.gpf
|
||||
BYPRODUCTS
|
||||
Packaged/ApplicationResources.gpr
|
||||
Packaged/ApplicationResources.gpa
|
||||
COMMANDS
|
||||
DEPENDS MiniRez gpr2gpa FTagData MergeGPF
|
||||
DEPENDS
|
||||
MiniRez gpr2gpa FTagData MergeGPF "GliderProData/Glider PRO.r"
|
||||
ApplicationResourcePatches/manifest.json DefaultTimestamp.timestamp
|
||||
COMMAND MiniRez
|
||||
"GliderProData/Glider PRO.r"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/Packaged/ApplicationResources.gpr"
|
||||
"{TMPDIR}/ApplicationResources.gpr"
|
||||
COMMAND gpr2gpa
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/Packaged/ApplicationResources.gpr"
|
||||
"{TMPDIR}/ApplicationResources.gpr"
|
||||
DefaultTimestamp.timestamp
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/Packaged/ApplicationResources.gpa"
|
||||
"{TMPDIR}/ApplicationResources.gpa"
|
||||
-patch ApplicationResourcePatches/manifest.json
|
||||
COMMAND FTagData
|
||||
DefaultTimestamp.timestamp
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/Packaged/ApplicationResources.gpf"
|
||||
"{TMPDIR}/ApplicationResources.gpf"
|
||||
data ozm5 0 0 locked
|
||||
COMMAND MergeGPF
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/Packaged/ApplicationResources.gpf"
|
||||
"{TMPDIR}/ApplicationResources.gpf"
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE FONT_DEPS RELATIVE "${CMAKE_SOURCE_DIR}" CONFIGURE_DEPENDS Resources/Fonts/*)
|
||||
add_data_file(Fonts.gpf
|
||||
BYPRODUCTS
|
||||
Packaged/Fonts.gpr
|
||||
Packaged/Fonts.gpa
|
||||
Packaged/FontCacheCatalog.bin
|
||||
Packaged/FontCacheManifest.json
|
||||
Packaged/CachedFont0.bin
|
||||
Packaged/CachedFont1.bin
|
||||
Packaged/CachedFont2.bin
|
||||
Packaged/CachedFont3.bin
|
||||
Packaged/CachedFont4.bin
|
||||
Packaged/CachedFont5.bin
|
||||
Packaged/CachedFont6.bin
|
||||
Packaged/CachedFont7.bin
|
||||
Packaged/CachedFont8.bin
|
||||
Packaged/CachedFont9.bin
|
||||
Packaged/CachedFont10.bin
|
||||
Packaged/CachedFont11.bin
|
||||
Packaged/CachedFont12.bin
|
||||
Packaged/CachedFont13.bin
|
||||
Packaged/CachedFont14.bin
|
||||
COMMANDS
|
||||
DEPENDS GenerateFonts MiniRez gpr2gpa FTagData MergeGPF
|
||||
COMMAND GenerateFonts
|
||||
"${CMAKE_SOURCE_DIR}/Resources"
|
||||
Packaged
|
||||
COMMAND MiniRez "${CMAKE_SOURCE_DIR}/Empty.r" Packaged/Fonts.gpr
|
||||
DEPENDS GenerateFonts MiniRez gpr2gpa FTagData MergeGPF ${FONT_DEPS}
|
||||
COMMAND GenerateFonts "${CMAKE_SOURCE_DIR}/Resources" {TMPDIR}
|
||||
COMMAND MiniRez "${CMAKE_SOURCE_DIR}/Empty.r" {TMPDIR}/Fonts.gpr
|
||||
COMMAND gpr2gpa
|
||||
Packaged/Fonts.gpr
|
||||
{TMPDIR}/Fonts.gpr
|
||||
"${CMAKE_SOURCE_DIR}/DefaultTimestamp.timestamp"
|
||||
Packaged/Fonts.gpa
|
||||
-patch Packaged/FontCacheManifest.json
|
||||
{TMPDIR}/Fonts.gpa
|
||||
-patch {TMPDIR}/FontCacheManifest.json
|
||||
COMMAND FTagData
|
||||
DefaultTimestamp.timestamp
|
||||
Packaged/Fonts.gpf
|
||||
{TMPDIR}/Fonts.gpf
|
||||
data ozm5 0 0 locked
|
||||
COMMAND MergeGPF Packaged/Fonts.gpf
|
||||
COMMAND MergeGPF {TMPDIR}/Fonts.gpf
|
||||
)
|
||||
|
||||
# These files are committed to the repo and aren't currently useful on non-Windows systems anyway.
|
||||
@@ -600,8 +598,10 @@ add_data_file(Fonts.gpf
|
||||
#
|
||||
#add_custom_command(
|
||||
# OUTPUT ${CONVERTED_ICONS}
|
||||
# DEPENDS ConvertColorCursors Packaged/ApplicationResources.gpr
|
||||
# COMMAND ConvertColorCursors
|
||||
# )
|
||||
#add_custom_target(Icons DEPENDS ${CONVERTED_ICONS})
|
||||
|
||||
set(HOUSE_FILES)
|
||||
|
||||
@@ -620,20 +620,22 @@ function(add_house NAME)
|
||||
list(APPEND HOUSE_FILES "${BASE_PATH}.gpf")
|
||||
|
||||
set(BYPRODUCTS "${BASE_PATH}.gpr" "${BASE_PATH}.gpa" "${BASE_PATH}.gpd")
|
||||
set(BINHEX_SRC "${CMAKE_SOURCE_DIR}/GliderProData/Houses/${NAME}.binhex")
|
||||
set(TS "${CMAKE_SOURCE_DIR}/DefaultTimestamp.timestamp")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT
|
||||
"${BASE_PATH}.gpf"
|
||||
BYPRODUCTS
|
||||
${BYPRODUCTS}
|
||||
DEPENDS hqx2gp gpr2gpa MergeGPF
|
||||
DEPENDS hqx2gp gpr2gpa MergeGPF BuildDirs "${BINHEX_SRC}" "${TS}"
|
||||
COMMAND hqx2gp
|
||||
"${CMAKE_SOURCE_DIR}/GliderProData/Houses/${NAME}.binhex"
|
||||
"${CMAKE_SOURCE_DIR}/DefaultTimestamp.timestamp"
|
||||
"${BINHEX_SRC}"
|
||||
"${TS}"
|
||||
"${BASE_PATH}"
|
||||
COMMAND gpr2gpa
|
||||
"${BASE_PATH}.gpr"
|
||||
"${CMAKE_SOURCE_DIR}/DefaultTimestamp.timestamp"
|
||||
"${TS}"
|
||||
"${BASE_PATH}.gpa"
|
||||
${PATCH_ARGS}
|
||||
${HOUSE_EXTRA_COMMANDS}
|
||||
@@ -644,7 +646,8 @@ function(add_house NAME)
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
if(EXISTS "${CMAKE_SOURCE_DIR}/GliderProData/ConvertedMovies/${NAME}.mov.gpa")
|
||||
set(MOV_GPA_SRC "${CMAKE_SOURCE_DIR}/GliderProData/ConvertedMovies/${NAME}.mov.gpa")
|
||||
if(EXISTS "${MOV_GPA_SRC}")
|
||||
list(APPEND HOUSE_FILES "${BASE_PATH}.mov.gpf")
|
||||
|
||||
add_custom_command(
|
||||
@@ -652,13 +655,14 @@ function(add_house NAME)
|
||||
"${BASE_PATH}.mov.gpf"
|
||||
BYPRODUCTS
|
||||
"${BASE_PATH}.mov.gpa"
|
||||
DEPENDS FTagData MergeGPF BuildDirs "${MOV_GPA_SRC}" "${TS}"
|
||||
COMMAND FTagData
|
||||
"${CMAKE_SOURCE_DIR}/DefaultTimestamp.timestamp"
|
||||
"${TS}"
|
||||
"${BASE_PATH}.mov.gpf"
|
||||
MooV ozm5 0 0 locked
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy
|
||||
-t "Packaged/Houses"
|
||||
"${CMAKE_SOURCE_DIR}/GliderProData/ConvertedMovies/${NAME}.mov.gpa"
|
||||
"${MOV_GPA_SRC}"
|
||||
COMMAND MergeGPF
|
||||
"${BASE_PATH}.mov.gpf"
|
||||
COMMAND "${CMAKE_COMMAND}" -E rm
|
||||
|
@@ -8,12 +8,11 @@
|
||||
#include "QDStandardPalette.h"
|
||||
#include "PLBigEndian.h"
|
||||
#include "PLDrivers.h"
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include "UnixCompat.h"
|
||||
#endif
|
||||
#include "WindowsUnicodeToolShim.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -96,12 +95,12 @@ void ConvertIconFamily(PortabilityLayer::ResourceFile *resFile, int32_t iconBitm
|
||||
item.a = 0;
|
||||
}
|
||||
|
||||
char outPath[256];
|
||||
sprintf_s(outPath, "Aerofoil/ConvertedResources/%s%i.ico", prefix, resID);
|
||||
std::string outPath = (
|
||||
std::ostringstream() << "Aerofoil/ConvertedResources/" << prefix << resID << ".ico"
|
||||
).str();
|
||||
|
||||
FILE *outF = nullptr;
|
||||
errno_t outErr = fopen_s(&outF, outPath, "wb");
|
||||
if (!outErr)
|
||||
FILE *outF = fopen_utf8(outPath.c_str(), "wb");
|
||||
if (outF)
|
||||
{
|
||||
IconDir iconDir;
|
||||
iconDir.m_reserved = 0;
|
||||
@@ -131,6 +130,8 @@ void ConvertIconFamily(PortabilityLayer::ResourceFile *resFile, int32_t iconBitm
|
||||
fwrite(&iconDirEntry, 1, sizeof(IconDirEntry), outF);
|
||||
fclose(outF);
|
||||
}
|
||||
else
|
||||
perror(outPath.c_str());
|
||||
|
||||
delete[] pixelData;
|
||||
bwBlock.Dispose();
|
||||
@@ -138,12 +139,14 @@ void ConvertIconFamily(PortabilityLayer::ResourceFile *resFile, int32_t iconBitm
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
int toolMain(int argc, const char **argv)
|
||||
{
|
||||
FILE *f = nullptr;
|
||||
errno_t err = fopen_s(&f, "Packaged/ApplicationResources.gpr", "rb");
|
||||
if (err)
|
||||
return err;
|
||||
FILE *f = fopen_utf8("Packaged/ApplicationResources.gpr", "rb");
|
||||
if (!f)
|
||||
{
|
||||
perror("Cannot open Packaged/ApplicationResources.gpr");
|
||||
return -1;
|
||||
}
|
||||
|
||||
PortabilityLayer::CFileStream stream(f);
|
||||
|
||||
|
@@ -5,13 +5,7 @@
|
||||
#include "CFileStream.h"
|
||||
#include "CombinedTimestamp.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
|
||||
#include "WindowsUnicodeToolShim.h"
|
||||
#else
|
||||
#include "UnixCompat.h"
|
||||
#endif
|
||||
|
||||
int toolMain(int argc, const char **argv)
|
||||
{
|
||||
|
@@ -17,13 +17,7 @@
|
||||
#include "RenderedFont.h"
|
||||
#include "RenderedFontCatalog.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "WindowsUnicodeToolShim.h"
|
||||
#include "GpFileSystem_Win32.h"
|
||||
#include "GpSystemServices_Win32.h"
|
||||
#else
|
||||
#include "UnixCompat.h"
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
#ifdef _MSC_VER
|
||||
|
@@ -3,15 +3,10 @@
|
||||
#include "PLBigEndian.h"
|
||||
#include "MacRomanConversion.h"
|
||||
#include "GpUnicode.h"
|
||||
#include "WindowsUnicodeToolShim.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "WindowsUnicodeToolShim.h"
|
||||
#else
|
||||
#include "UnixCompat.h"
|
||||
#endif
|
||||
|
||||
typedef uint8_t Boolean;
|
||||
|
||||
#define kMaxScores 10
|
||||
|
@@ -1,16 +1,13 @@
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
#else
|
||||
#include <string.h>
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "UnixCompat.h"
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <cstdio>
|
||||
|
||||
#include "CombinedTimestamp.h"
|
||||
|
||||
@@ -77,7 +74,7 @@ int main(int argc, const char **argv)
|
||||
ts.SetMacEpochTime(currentTimeUnix + ts.kMacEpochToUTC);
|
||||
|
||||
ts.SetLocalYear(currentTimeStruct->tm_year + 1900);
|
||||
ts.m_localMonth = currentTimeStruct->tm_mon;
|
||||
ts.m_localMonth = currentTimeStruct->tm_mon + 1;
|
||||
ts.m_localDay = currentTimeStruct->tm_mday;
|
||||
|
||||
ts.m_localHour = currentTimeStruct->tm_hour;
|
||||
@@ -87,10 +84,10 @@ int main(int argc, const char **argv)
|
||||
|
||||
memset(ts.m_padding, 0, sizeof(ts.m_padding));
|
||||
|
||||
FILE *f;
|
||||
if (fopen_s(&f, argv[1], "wb"))
|
||||
FILE *f = fopen(argv[1], "wb");
|
||||
if (!f)
|
||||
{
|
||||
fprintf(stderr, "Error opening output file");
|
||||
perror("Error opening output file");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,4 @@
|
||||
#ifdef _WIN32
|
||||
#include "WindowsUnicodeToolShim.h"
|
||||
#else
|
||||
#include "UnixCompat.h"
|
||||
#endif
|
||||
|
||||
#include "CFileStream.h"
|
||||
#include "CombinedTimestamp.h"
|
||||
|
@@ -10,12 +10,7 @@
|
||||
|
||||
#include "MacBinary2.h"
|
||||
#include "MacFileMem.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "WindowsUnicodeToolShim.h"
|
||||
#else
|
||||
#include "UnixCompat.h"
|
||||
#endif
|
||||
|
||||
// Very simplified resource compiler
|
||||
|
||||
|
@@ -1,58 +0,0 @@
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <dirent.h>
|
||||
|
||||
void ScanDirectoryForExtension
|
||||
(
|
||||
std::vector<std::string> &outPaths,
|
||||
const char *path,
|
||||
const char *ending,
|
||||
bool recursive
|
||||
) {
|
||||
DIR *dir = opendir(path);
|
||||
if (!dir)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
size_t endingLen = strlen(ending);
|
||||
|
||||
dirent *ent;
|
||||
while ((ent = readdir(dir)))
|
||||
{
|
||||
if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0)
|
||||
continue;
|
||||
else if (recursive && ent->d_type == DT_DIR)
|
||||
{
|
||||
std::string tmpPath(path);
|
||||
tmpPath.append("/");
|
||||
tmpPath.append(ent->d_name);
|
||||
ScanDirectoryForExtension(
|
||||
outPaths,
|
||||
tmpPath.c_str(),
|
||||
ending,
|
||||
recursive
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t nameLen = strlen(ent->d_name);
|
||||
|
||||
if (endingLen <= nameLen && memcmp
|
||||
(
|
||||
ent->d_name + nameLen - endingLen,
|
||||
ending,
|
||||
endingLen
|
||||
) == 0
|
||||
) {
|
||||
std::string tmpPath(path);
|
||||
tmpPath.append("/");
|
||||
tmpPath.append(ent->d_name);
|
||||
outPaths.push_back(std::move(tmpPath));
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
}
|
@@ -1,13 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
// This header provides POSIX-compatible versions of some functions from
|
||||
// WindowsUnicodeToolShim and the Windows API.
|
||||
#include "WindowsUnicodeToolShim.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdarg>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
// Linux and macOS (and probably other non-Windows systems in general) do not
|
||||
@@ -31,63 +30,18 @@
|
||||
// though on the major non-Windows systems, assuming UTF-8 encoding is
|
||||
// reasonable. For now, this header simply maps the WindowsUnicodeToolShim
|
||||
// functions to their regular C API counterparts.
|
||||
#define toolMain main
|
||||
#define fopen_utf8 fopen
|
||||
#define fputs_utf8 fputs
|
||||
int toolMain(int argc, const char **argv);
|
||||
int main(int argc, const char **argv) { return toolMain(argc, argv); }
|
||||
|
||||
typedef int errno_t;
|
||||
FILE *fopen_utf8(const char *path, const char *options) { return fopen(path, options); }
|
||||
int fputs_utf8(const char *str, FILE *f) { return fputs(str, f); }
|
||||
int mkdir_utf8(const char *path) { return mkdir(path, 0777); }
|
||||
|
||||
inline int mkdir_utf8(const char *path)
|
||||
void TerminateDirectoryPath(std::string &path)
|
||||
{
|
||||
return mkdir(path, 0777);
|
||||
}
|
||||
const size_t len = path.length();
|
||||
|
||||
// These use long as the offset type, which is 64 bits on 64-bit Linux and macOS
|
||||
// systems, so explicitly 64-bit variants aren't necessary. 32-bit systems are
|
||||
// likely to have a 32-bit long type, but we aren't likely to deal with
|
||||
// multi-gigabyte files, are we?
|
||||
#define _fseeki64 fseek
|
||||
#define _ftelli64 ftell
|
||||
|
||||
// On Windows this is supposed to call an error handler if the buffer is too
|
||||
// small. I don't think this is likely to happen in Aerofoil's case, but if it
|
||||
// does, this function will crash the program as a precaution.
|
||||
template <size_t size> int sprintf_s
|
||||
(
|
||||
char (&buffer)[size],
|
||||
const char *format,
|
||||
...
|
||||
) {
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
int count = vsnprintf(buffer, size, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (count >= size)
|
||||
exit(1);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
inline errno_t fopen_s(FILE **pFile, const char *name, const char *mode)
|
||||
{
|
||||
FILE *f = fopen(name, mode);
|
||||
if (!f)
|
||||
{
|
||||
// Error codes might not match those from Windows, but all are
|
||||
// non-zero, so *detecting* an error will work fine.
|
||||
return errno;
|
||||
}
|
||||
*pFile = f;
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline void TerminateDirectoryPath(std::string &path)
|
||||
{
|
||||
const size_t length = path.length();
|
||||
|
||||
if (length == 0 || path[length - 1] != '/')
|
||||
if (len == 0 || path[len - 1] != '/')
|
||||
path.push_back('/');
|
||||
}
|
||||
|
||||
@@ -97,4 +51,49 @@ void ScanDirectoryForExtension
|
||||
const char *path,
|
||||
const char *ending,
|
||||
bool recursive
|
||||
);
|
||||
) {
|
||||
DIR *dir = opendir(path);
|
||||
if (!dir)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
size_t endingLen = strlen(ending);
|
||||
|
||||
dirent *ent;
|
||||
while ((ent = readdir(dir)))
|
||||
{
|
||||
if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0)
|
||||
continue;
|
||||
else if (recursive && ent->d_type == DT_DIR)
|
||||
{
|
||||
std::string tmpPath(path);
|
||||
tmpPath.append("/");
|
||||
tmpPath.append(ent->d_name);
|
||||
ScanDirectoryForExtension(
|
||||
outPaths,
|
||||
tmpPath.c_str(),
|
||||
ending,
|
||||
recursive
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t nameLen = strlen(ent->d_name);
|
||||
|
||||
if (endingLen <= nameLen && memcmp
|
||||
(
|
||||
ent->d_name + nameLen - endingLen,
|
||||
ending,
|
||||
endingLen
|
||||
) == 0
|
||||
) {
|
||||
std::string tmpPath(path);
|
||||
tmpPath.append("/");
|
||||
tmpPath.append(ent->d_name);
|
||||
outPaths.push_back(std::move(tmpPath));
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
}
|
@@ -8,6 +8,7 @@ int mkdir_utf8(const char *path);
|
||||
void TerminateDirectoryPath(std::string &path);
|
||||
void ScanDirectoryForExtension(std::vector<std::string>& outPaths, const char *path, const char *ending, bool recursive);
|
||||
|
||||
#ifdef _WIN32
|
||||
struct DirectoryScanContext;
|
||||
struct DirectoryScanEntry
|
||||
{
|
||||
@@ -17,3 +18,11 @@ struct DirectoryScanEntry
|
||||
DirectoryScanContext *opendir_utf8(const char *name);
|
||||
DirectoryScanEntry *readdir_utf8(DirectoryScanContext *dir);
|
||||
void closedir_utf8(DirectoryScanContext *context);
|
||||
|
||||
#else
|
||||
|
||||
inline int _fseeki64(FILE *stream, long offset, int whence) {
|
||||
return fseek(stream, offset, whence);
|
||||
}
|
||||
inline long _ftelli64(FILE *stream) { return ftell(stream); };
|
||||
#endif
|
||||
|
@@ -24,21 +24,17 @@
|
||||
#include "rapidjson/rapidjson.h"
|
||||
#include "rapidjson/document.h"
|
||||
|
||||
#include "WindowsUnicodeToolShim.h"
|
||||
|
||||
#include "macedec.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "WindowsUnicodeToolShim.h"
|
||||
#include "GpWindows.h"
|
||||
#else
|
||||
#include "UnixCompat.h"
|
||||
#endif
|
||||
|
||||
enum AudioCompressionCodecID
|
||||
{
|
||||
AudioCompressionCodecID_VariableRate = -2,
|
||||
@@ -2436,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++)
|
||||
@@ -2462,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<int>(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))
|
||||
@@ -2479,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<int>(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))
|
||||
@@ -2496,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<int>(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))
|
||||
@@ -2511,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<int>(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))
|
||||
@@ -2533,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<int>(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))
|
||||
@@ -2554,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<int>(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());
|
||||
|
||||
@@ -2609,6 +2608,7 @@ int ConvertDirectory(const std::string &basePath, const PortabilityLayer::Combin
|
||||
fprintf(stderr, "Failed to open metadata file ");
|
||||
fputs_utf8(metaPath.c_str(), stderr);
|
||||
fprintf(stderr, "\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
PortabilityLayer::MacFilePropertiesSerialized mfps;
|
||||
|
@@ -31,12 +31,7 @@ SOFTWARE.
|
||||
#include "MacBinary2.h"
|
||||
#include "MacFileMem.h"
|
||||
#include "ZipFile.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "WindowsUnicodeToolShim.h"
|
||||
#else
|
||||
#include "UnixCompat.h"
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
|
||||
#include "IDecompressor.h"
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <cstddef>
|
||||
|
||||
struct CSInputBuffer;
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
struct IFileReader
|
||||
{
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include <limits.h>
|
||||
#include <climits>
|
||||
|
||||
#include "PrefixCode.h"
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
|
||||
#include "IDecompressor.h"
|
||||
|
||||
|
@@ -1,17 +1,4 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
#include <shellapi.h>
|
||||
|
||||
#include "WindowsUnicodeToolShim.h"
|
||||
#else
|
||||
#include "UnixCompat.h"
|
||||
#endif
|
||||
|
||||
#include "IArchiveParser.h"
|
||||
#include "IFileReader.h"
|
||||
@@ -35,8 +22,15 @@
|
||||
#include "CompactProLZHRLEDecompressor.h"
|
||||
|
||||
#include "CSInputBuffer.h"
|
||||
#include "WindowsUnicodeToolShim.h"
|
||||
|
||||
#include "CombinedTimestamp.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class CFileReader final : public IFileReader
|
||||
{
|
||||
public:
|
||||
|
Reference in New Issue
Block a user