diff options
| author | MegaMech <MegaMech@users.noreply.github.com> | 2024-05-22 19:26:06 -0600 |
|---|---|---|
| committer | Lywx <kiritodev01@gmail.com> | 2024-05-24 17:05:56 -0600 |
| commit | 718aeb89374691e3ac0d634f0630b873b5ac5a6d (patch) | |
| tree | d62db96a4c9e357e8ee16f64025df15bc77ff623 | |
| parent | fd8430de34ad9378bb1fe40b47152c57879d6e36 (diff) | |
Update CourseMetadata.cpp
| -rw-r--r-- | src/factories/mk64/CourseMetadata.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/factories/mk64/CourseMetadata.cpp b/src/factories/mk64/CourseMetadata.cpp index d866179..509dcc5 100644 --- a/src/factories/mk64/CourseMetadata.cpp +++ b/src/factories/mk64/CourseMetadata.cpp @@ -3,6 +3,7 @@ #include "Companion.h" #include "spdlog/spdlog.h" #include <algorithm> +#include <filesystem> #define NUM(x) std::dec << std::setfill(' ') << std::setw(6) << x #define COL(c) "0x" << std::hex << std::setw(2) << std::setfill('0') << c @@ -14,6 +15,8 @@ ExportResult MK64::CourseMetadataCodeExporter::Export(std::ostream &write, std:: throw std::runtime_error("Course metadata null"); } + + // Sort the data by id, 0 to 20 and beyond. std::sort(metadata.begin(), metadata.end(), [this](const CourseMetadata& a, const CourseMetadata& b) { @@ -23,6 +26,11 @@ ExportResult MK64::CourseMetadataCodeExporter::Export(std::ostream &write, std:: std::ofstream file; auto outDir = GetSafeNode<std::string>(node, "out_directory") + "/"; + // Check if the output directory exists, and create it if it doesn't. + if (!std::filesystem::exists(outDir)) { + std::filesystem::create_directory(outDir); + } + file.open(outDir+"gCourseNames.inc.c", std::ios_base::binary | std::ios_base::out); if (file.is_open()) { // file << "char *gCourseNames[] = {\n" << fourSpaceTab; |
