From 718aeb89374691e3ac0d634f0630b873b5ac5a6d Mon Sep 17 00:00:00 2001 From: MegaMech Date: Wed, 22 May 2024 19:26:06 -0600 Subject: [PATCH] Update CourseMetadata.cpp --- src/factories/mk64/CourseMetadata.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) 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 +#include #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(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;