From ce810ff0b95edaffd781f9a1ba1e39c32410c7e5 Mon Sep 17 00:00:00 2001 From: hogliux Date: Thu, 15 Mar 2018 14:37:10 +0000 Subject: [PATCH] Modify examples directory search so that the directory can be found when the DemoRunner is in the JUCE root folder --- examples/Assets/DemoUtilities.h | 4 ++++ examples/DemoRunner/Source/Demos/JUCEDemos.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/Assets/DemoUtilities.h b/examples/Assets/DemoUtilities.h index fa995e374e..b8b60d001c 100644 --- a/examples/Assets/DemoUtilities.h +++ b/examples/Assets/DemoUtilities.h @@ -59,6 +59,10 @@ inline File getExamplesDirectory() noexcept return mo.toString(); #else auto currentFile = File::getSpecialLocation (File::SpecialLocationType::currentExecutableFile); + auto exampleDir = currentFile.getParentDirectory().getChildFile ("examples"); + + if (exampleDir.exists()) + return exampleDir; int numTries = 0; // keep track of the number of parent directories so we don't go on endlessly diff --git a/examples/DemoRunner/Source/Demos/JUCEDemos.cpp b/examples/DemoRunner/Source/Demos/JUCEDemos.cpp index d459204b54..79934b0c5d 100644 --- a/examples/DemoRunner/Source/Demos/JUCEDemos.cpp +++ b/examples/DemoRunner/Source/Demos/JUCEDemos.cpp @@ -67,13 +67,15 @@ void JUCEDemos::registerDemo (std::function constructorCallback, c File JUCEDemos::findExamplesDirectoryFromExecutable (File exec) { int numTries = 15; + auto exampleDir = exec.getParentDirectory().getChildFile ("examples"); + + if (exampleDir.exists()) + return exampleDir; while (exec.getFileName() != "examples" && numTries-- > 0) exec = exec.getParentDirectory(); - if (exec.getFileName() == "examples") return exec; - return {}; }