diff --git a/soh/macosx/soh-macos.sh.in b/soh/macosx/soh-macos.sh.in index 177e309f4..0983f63b1 100755 --- a/soh/macosx/soh-macos.sh.in +++ b/soh/macosx/soh-macos.sh.in @@ -219,12 +219,14 @@ if [ ! -e "$SHIP_HOME"/oot.otr ] || [ ! -e "$SHIP_HOME"/oot-mq.otr ]; then *) osascript -e 'display notification "One or more invalid ROM provided" with title "Ship Of Harkinian"' rm -r "$ASSETDIR" + cd "$SNAME" continue; esac # Only generate OTR if we don't have on of this type yet if [ -e "$SHIP_HOME"/"$OTRNAME" ]; then rm -r "$ASSETDIR" + cd "$SNAME" continue; fi @@ -234,6 +236,7 @@ if [ ! -e "$SHIP_HOME"/oot.otr ] || [ ! -e "$SHIP_HOME"/oot-mq.otr ]; then osascript -e 'display notification "OTR successfully generated" with title "Ship Of Harkinian"' cp "$ASSETDIR"/oot.otr "$SHIP_HOME"/"$OTRNAME" rm -r "$ASSETDIR" + cd "$SNAME" fi done @@ -243,6 +246,8 @@ if [ ! -e "$SHIP_HOME"/oot.otr ] || [ ! -e "$SHIP_HOME"/oot-mq.otr ]; then fi fi +cd "$SNAME" + arch_name="$(uname -m)" launch_arch="arm64" if [ "${arch_name}" = "x86_64" ] && [ "$(sysctl -in sysctl.proc_translated)" != "1" ]; then diff --git a/soh/soh/Extractor/Extract.cpp b/soh/soh/Extractor/Extract.cpp index 4769c48f6..d4b524474 100644 --- a/soh/soh/Extractor/Extract.cpp +++ b/soh/soh/Extractor/Extract.cpp @@ -225,7 +225,7 @@ void Extractor::GetRoms(std::vector& roms) { //} #elif unix // Open the directory of the app. - DIR* d = opendir("."); + DIR* d = opendir(mSearchPath.c_str()); struct dirent* dir; if (d != NULL) { @@ -248,7 +248,7 @@ void Extractor::GetRoms(std::vector& roms) { } closedir(d); #else - for (const auto& file : std::filesystem::directory_iterator("./")) { + for (const auto& file : std::filesystem::directory_iterator(mSearchPath)) { if (file.is_directory()) continue; if ((file.path().extension() == ".n64") || (file.path().extension() == ".z64") || @@ -297,7 +297,7 @@ bool Extractor::GetRomPathFromBox() { } mCurrentRomPath = nameBuffer; #else - auto selection = pfd::open_file("Select a file", ".", { "N64 Roms", "*.z64 *.n64 *.v64" }).result(); + auto selection = pfd::open_file("Select a file", mSearchPath, { "N64 Roms", "*.z64 *.n64 *.v64" }).result(); if (selection.empty()) { return false; @@ -430,10 +430,12 @@ bool Extractor::ManuallySearchForRomMatchingType(RomSearchMode searchMode) { return true; } -bool Extractor::Run(RomSearchMode searchMode) { +bool Extractor::Run(std::string searchPath, RomSearchMode searchMode) { std::vector roms; std::ifstream inFile; + mSearchPath = searchPath; + GetRoms(roms); FilterRoms(roms, searchMode); diff --git a/soh/soh/Extractor/Extract.h b/soh/soh/Extractor/Extract.h index 4ff7cb92f..ce4008fbe 100644 --- a/soh/soh/Extractor/Extract.h +++ b/soh/soh/Extractor/Extract.h @@ -28,6 +28,7 @@ enum class RomSearchMode { class Extractor { std::unique_ptr mRomData = std::make_unique(MB64); std::string mCurrentRomPath; + std::string mSearchPath; size_t mCurRomSize = 0; bool GetRomPathFromBox(); @@ -58,7 +59,7 @@ class Extractor { static void ShowErrorBox(const char* title, const char* text); bool IsMasterQuest() const; - bool Run(RomSearchMode searchMode = RomSearchMode::Both); + bool Run(std::string searchPath, RomSearchMode searchMode = RomSearchMode::Both); bool CallZapd(std::string installPath, std::string exportdir); const char* GetZapdStr(); std::string Mkdtemp(); diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 7f0d8c5d6..1199a7e99 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -890,7 +890,7 @@ void DetectOTRVersion(std::string fileName, bool isMQ) { } Extractor extract; - if (!extract.Run(isMQ ? RomSearchMode::MQ : RomSearchMode::Vanilla)) { + if (!extract.Run(LUS::Context::GetAppDirectoryPath(appShortName), isMQ ? RomSearchMode::MQ : RomSearchMode::Vanilla)) { Extractor::ShowErrorBox("Error", "An error occured, no OTR file was generated.\n\nExiting..."); exit(1); } @@ -932,7 +932,8 @@ extern "C" void InitOTR() { #elif defined(__WIIU__) LUS::WiiU::Init(appShortName); #endif - #ifdef _WIN32 + +#ifdef _WIN32 char* tempVar = getenv("TEMP"); std::filesystem::path tempPath; try { @@ -985,7 +986,7 @@ extern "C" void InitOTR() { bool generatedOtrIsMQ = false; if (Extractor::ShowYesNoBox("No OTR Files", "No OTR files found. Generate one now?") == IDYES) { Extractor extract; - if (!extract.Run()) { + if (!extract.Run(LUS::Context::GetAppDirectoryPath(appShortName))) { Extractor::ShowErrorBox("Error", "An error occured, no OTR file was generated.\n\nExiting..."); exit(1); } @@ -996,7 +997,7 @@ extern "C" void InitOTR() { } if (Extractor::ShowYesNoBox("Extraction Complete", "ROM Extracted. Extract another?") == IDYES) { Extractor extract; - if (!extract.Run(generatedOtrIsMQ ? RomSearchMode::Vanilla : RomSearchMode::MQ)) { + if (!extract.Run(LUS::Context::GetAppDirectoryPath(appShortName), generatedOtrIsMQ ? RomSearchMode::Vanilla : RomSearchMode::MQ)) { Extractor::ShowErrorBox("Error", "An error occured, an OTR file may have been generated by a different step.\n\nContinuing..."); } else { extract.CallZapd(installPath, LUS::Context::GetAppDirectoryPath(appShortName));