1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

Use getSiblingFile in more places

This commit is contained in:
Tom Poole 2024-11-20 10:10:35 +00:00
parent 5d5fdaf008
commit 5737c42ccf
7 changed files with 17 additions and 17 deletions

View file

@ -63,7 +63,7 @@ inline File getExamplesDirectory() noexcept
return File { CharPointer_UTF8 { PIP_JUCE_EXAMPLES_DIRECTORY_STRING } }; return File { CharPointer_UTF8 { PIP_JUCE_EXAMPLES_DIRECTORY_STRING } };
#else #else
auto currentFile = File::getSpecialLocation (File::SpecialLocationType::currentApplicationFile); auto currentFile = File::getSpecialLocation (File::SpecialLocationType::currentApplicationFile);
auto exampleDir = currentFile.getParentDirectory().getChildFile ("examples"); auto exampleDir = currentFile.getSiblingFile ("examples");
if (exampleDir.exists()) if (exampleDir.exists())
return exampleDir; return exampleDir;
@ -109,10 +109,10 @@ inline std::unique_ptr<InputStream> createAssetInputStream (const char* resource
#else #else
#if JUCE_IOS #if JUCE_IOS
auto assetsDir = File::getSpecialLocation (File::currentExecutableFile) auto assetsDir = File::getSpecialLocation (File::currentExecutableFile)
.getParentDirectory().getChildFile ("Assets"); .getSiblingFile ("Assets");
#elif JUCE_MAC #elif JUCE_MAC
auto assetsDir = File::getSpecialLocation (File::currentExecutableFile) auto assetsDir = File::getSpecialLocation (File::currentExecutableFile)
.getParentDirectory().getParentDirectory().getChildFile ("Resources").getChildFile ("Assets"); .getParentDirectory().getSiblingFile ("Resources").getChildFile ("Assets");
if (! assetsDir.exists()) if (! assetsDir.exists())
assetsDir = getExamplesDirectory().getChildFile ("Assets"); assetsDir = getExamplesDirectory().getChildFile ("Assets");

View file

@ -63,7 +63,7 @@ inline File getExamplesDirectory() noexcept
return File { CharPointer_UTF8 { PIP_JUCE_EXAMPLES_DIRECTORY_STRING } }; return File { CharPointer_UTF8 { PIP_JUCE_EXAMPLES_DIRECTORY_STRING } };
#else #else
auto currentFile = File::getSpecialLocation (File::SpecialLocationType::currentApplicationFile); auto currentFile = File::getSpecialLocation (File::SpecialLocationType::currentApplicationFile);
auto exampleDir = currentFile.getParentDirectory().getChildFile ("examples"); auto exampleDir = currentFile.getSiblingFile ("examples");
if (exampleDir.exists()) if (exampleDir.exists())
return exampleDir; return exampleDir;
@ -109,10 +109,10 @@ inline std::unique_ptr<InputStream> createAssetInputStream (const char* resource
#else #else
#if JUCE_IOS #if JUCE_IOS
auto assetsDir = File::getSpecialLocation (File::currentExecutableFile) auto assetsDir = File::getSpecialLocation (File::currentExecutableFile)
.getParentDirectory().getChildFile ("Assets"); .getSiblingFile ("Assets");
#elif JUCE_MAC #elif JUCE_MAC
auto assetsDir = File::getSpecialLocation (File::currentExecutableFile) auto assetsDir = File::getSpecialLocation (File::currentExecutableFile)
.getParentDirectory().getParentDirectory().getChildFile ("Resources").getChildFile ("Assets"); .getParentDirectory().getSiblingFile ("Resources").getChildFile ("Assets");
if (! assetsDir.exists()) if (! assetsDir.exists())
assetsDir = getExamplesDirectory().getChildFile ("Assets"); assetsDir = getExamplesDirectory().getChildFile ("Assets");

View file

@ -50,7 +50,7 @@ void JUCEDemos::registerDemo (std::function<Component*()> constructorCallback, c
{ {
#if JUCE_MAC #if JUCE_MAC
auto f = File::getSpecialLocation (File::currentExecutableFile) auto f = File::getSpecialLocation (File::currentExecutableFile)
.getParentDirectory().getParentDirectory().getChildFile ("Resources"); .getParentDirectory().getSiblingFile ("Resources");
#else #else
auto f = findExamplesDirectoryFromExecutable (File::getSpecialLocation (File::currentApplicationFile)); auto f = findExamplesDirectoryFromExecutable (File::getSpecialLocation (File::currentApplicationFile));
#endif #endif
@ -69,7 +69,7 @@ void JUCEDemos::registerDemo (std::function<Component*()> constructorCallback, c
File JUCEDemos::findExamplesDirectoryFromExecutable (File exec) File JUCEDemos::findExamplesDirectoryFromExecutable (File exec)
{ {
int numTries = 15; int numTries = 15;
auto exampleDir = exec.getParentDirectory().getChildFile ("examples"); auto exampleDir = exec.getSiblingFile ("examples");
if (exampleDir.exists()) if (exampleDir.exists())
return exampleDir; return exampleDir;

View file

@ -63,7 +63,7 @@ inline File getExamplesDirectory() noexcept
return File { CharPointer_UTF8 { PIP_JUCE_EXAMPLES_DIRECTORY_STRING } }; return File { CharPointer_UTF8 { PIP_JUCE_EXAMPLES_DIRECTORY_STRING } };
#else #else
auto currentFile = File::getSpecialLocation (File::SpecialLocationType::currentApplicationFile); auto currentFile = File::getSpecialLocation (File::SpecialLocationType::currentApplicationFile);
auto exampleDir = currentFile.getParentDirectory().getChildFile ("examples"); auto exampleDir = currentFile.getSiblingFile ("examples");
if (exampleDir.exists()) if (exampleDir.exists())
return exampleDir; return exampleDir;
@ -109,10 +109,10 @@ inline std::unique_ptr<InputStream> createAssetInputStream (const char* resource
#else #else
#if JUCE_IOS #if JUCE_IOS
auto assetsDir = File::getSpecialLocation (File::currentExecutableFile) auto assetsDir = File::getSpecialLocation (File::currentExecutableFile)
.getParentDirectory().getChildFile ("Assets"); .getSiblingFile ("Assets");
#elif JUCE_MAC #elif JUCE_MAC
auto assetsDir = File::getSpecialLocation (File::currentExecutableFile) auto assetsDir = File::getSpecialLocation (File::currentExecutableFile)
.getParentDirectory().getParentDirectory().getChildFile ("Resources").getChildFile ("Assets"); .getParentDirectory().getSiblingFile ("Resources").getChildFile ("Assets");
if (! assetsDir.exists()) if (! assetsDir.exists())
assetsDir = getExamplesDirectory().getChildFile ("Assets"); assetsDir = getExamplesDirectory().getChildFile ("Assets");

View file

@ -507,7 +507,7 @@ Array<File> PIPGenerator::replaceRelativeIncludesAndGetFilesToMove()
if (path.startsWith ("<") && path.endsWith (">")) if (path.startsWith ("<") && path.endsWith (">"))
continue; continue;
auto file = pipFile.getParentDirectory().getChildFile (path); auto file = pipFile.getSiblingFile (path);
files.add (file); files.add (file);
line = line.replace (path, file.getFileName()); line = line.replace (path, file.getFileName());

View file

@ -1158,10 +1158,10 @@ public:
expect (home.getChildFile ("...xyz").getFileName() == "...xyz"); expect (home.getChildFile ("...xyz").getFileName() == "...xyz");
expect (home.getChildFile ("./xyz") == home.getChildFile ("xyz")); expect (home.getChildFile ("./xyz") == home.getChildFile ("xyz"));
expect (home.getChildFile ("././xyz") == home.getChildFile ("xyz")); expect (home.getChildFile ("././xyz") == home.getChildFile ("xyz"));
expect (home.getChildFile ("../xyz") == home.getParentDirectory().getChildFile ("xyz")); expect (home.getChildFile ("../xyz") == home.getSiblingFile ("xyz"));
expect (home.getChildFile (".././xyz") == home.getParentDirectory().getChildFile ("xyz")); expect (home.getChildFile (".././xyz") == home.getSiblingFile ("xyz"));
expect (home.getChildFile (".././xyz/./abc") == home.getParentDirectory().getChildFile ("xyz/abc")); expect (home.getChildFile (".././xyz/./abc") == home.getSiblingFile ("xyz/abc"));
expect (home.getChildFile ("./../xyz") == home.getParentDirectory().getChildFile ("xyz")); expect (home.getChildFile ("./../xyz") == home.getSiblingFile ("xyz"));
expect (home.getChildFile ("a1/a2/a3/./../../a4") == home.getChildFile ("a1/a4")); expect (home.getChildFile ("a1/a2/a3/./../../a4") == home.getChildFile ("a1/a4"));
expect (! File().hasReadAccess()); expect (! File().hasReadAccess());

View file

@ -1299,7 +1299,7 @@ private:
} }
else else
{ {
auto linkedFile = originalFile.getParentDirectory().getChildFile (link); auto linkedFile = originalFile.getSiblingFile (link);
if (linkedFile.existsAsFile()) if (linkedFile.existsAsFile())
inputStream = linkedFile.createInputStream(); inputStream = linkedFile.createInputStream();