Browse Source

Modify examples directory search so that the directory can be found when the DemoRunner is in the JUCE root folder

tags/2021-05-28
hogliux 7 years ago
parent
commit
ce810ff0b9
2 changed files with 8 additions and 2 deletions
  1. +4
    -0
      examples/Assets/DemoUtilities.h
  2. +4
    -2
      examples/DemoRunner/Source/Demos/JUCEDemos.cpp

+ 4
- 0
examples/Assets/DemoUtilities.h View File

@@ -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


+ 4
- 2
examples/DemoRunner/Source/Demos/JUCEDemos.cpp View File

@@ -67,13 +67,15 @@ void JUCEDemos::registerDemo (std::function<Component*()> 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 {};
}


Loading…
Cancel
Save