From aa7ae6128d40245cfc224b552ff9a3a8303b4d46 Mon Sep 17 00:00:00 2001 From: TaurusXin Date: Sun, 24 Mar 2024 09:20:25 +0800 Subject: [PATCH] refactor: project file structure --- CMakeLists.txt | 10 +++++++--- aes.h => src/include/aes.h | 0 base64.h => src/include/base64.h | 0 cJSON.h => src/include/cJSON.h | 0 color.h => src/include/color.h | 0 ncmcrypt.h => src/include/ncmcrypt.h | 0 platform.h => src/include/platform.h | 0 main.cpp => src/main.cpp | 4 ++-- ncmcrypt.cpp => src/ncmcrypt.cpp | 0 win32_init.cpp => src/platform/win32_init.cpp | 0 aes.cpp => src/utils/aes.cpp | 0 cJSON.cpp => src/utils/cJSON.cpp | 0 12 files changed, 9 insertions(+), 5 deletions(-) rename aes.h => src/include/aes.h (100%) rename base64.h => src/include/base64.h (100%) rename cJSON.h => src/include/cJSON.h (100%) rename color.h => src/include/color.h (100%) rename ncmcrypt.h => src/include/ncmcrypt.h (100%) rename platform.h => src/include/platform.h (100%) rename main.cpp => src/main.cpp (97%) rename ncmcrypt.cpp => src/ncmcrypt.cpp (100%) rename win32_init.cpp => src/platform/win32_init.cpp (100%) rename aes.cpp => src/utils/aes.cpp (100%) rename cJSON.cpp => src/utils/cJSON.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index dce0630..3e7f652 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,9 +14,10 @@ if(MSVC) add_compile_options("$<$:/execution-charset:utf-8>") endif() -FILE(GLOB HEADERS ./*.h) -FILE(GLOB COMMON_SOURCES cJSON.cpp aes.cpp main.cpp ncmcrypt.cpp) -FILE(GLOB WIN_SOURCES win32_init.cpp) +FILE(GLOB HEADERS ./src/include/*.h) +FILE(GLOB COMMON_SOURCES ./src/*.cpp ./src/utils/*.cpp) +FILE(GLOB WIN_SOURCES ./src/platform/win32_init.cpp) + if(WIN32) set(SOURCES ${COMMON_SOURCES} ${WIN_SOURCES}) @@ -27,6 +28,9 @@ add_executable(ncmdump ${HEADERS} ${SOURCES} ) + +target_include_directories(ncmdump PRIVATE src/include) + target_link_libraries(ncmdump tag) target_include_directories(ncmdump PRIVATE taglib) target_include_directories(ncmdump PRIVATE taglib/taglib) diff --git a/aes.h b/src/include/aes.h similarity index 100% rename from aes.h rename to src/include/aes.h diff --git a/base64.h b/src/include/base64.h similarity index 100% rename from base64.h rename to src/include/base64.h diff --git a/cJSON.h b/src/include/cJSON.h similarity index 100% rename from cJSON.h rename to src/include/cJSON.h diff --git a/color.h b/src/include/color.h similarity index 100% rename from color.h rename to src/include/color.h diff --git a/ncmcrypt.h b/src/include/ncmcrypt.h similarity index 100% rename from ncmcrypt.h rename to src/include/ncmcrypt.h diff --git a/platform.h b/src/include/platform.h similarity index 100% rename from platform.h rename to src/include/platform.h diff --git a/main.cpp b/src/main.cpp similarity index 97% rename from main.cpp rename to src/main.cpp index 96e9d1a..7d8bfc5 100644 --- a/main.cpp +++ b/src/main.cpp @@ -77,7 +77,7 @@ int main(int argc, char **argv) #define COMPARE_STR(s1, s2) (strcmp(s1, s2) == 0) #define HELP_SHORT "-h" #define HELP_LONG "--help" -#define FOLDER "-d" +#define PROCESS_FOLDER "-d" for (int i = 1; i < argc; ++i) { if (COMPARE_STR(argv[i], HELP_SHORT) || COMPARE_STR(argv[i], HELP_LONG)) @@ -85,7 +85,7 @@ int main(int argc, char **argv) displayHelp(); return 0; } - else if (COMPARE_STR(argv[i], FOLDER)) + else if (COMPARE_STR(argv[i], PROCESS_FOLDER)) { processFolders = true; if (i + 1 < argc && argv[i + 1][0] != '-') diff --git a/ncmcrypt.cpp b/src/ncmcrypt.cpp similarity index 100% rename from ncmcrypt.cpp rename to src/ncmcrypt.cpp diff --git a/win32_init.cpp b/src/platform/win32_init.cpp similarity index 100% rename from win32_init.cpp rename to src/platform/win32_init.cpp diff --git a/aes.cpp b/src/utils/aes.cpp similarity index 100% rename from aes.cpp rename to src/utils/aes.cpp diff --git a/cJSON.cpp b/src/utils/cJSON.cpp similarity index 100% rename from cJSON.cpp rename to src/utils/cJSON.cpp