Skip to content

Commit

Permalink
Use getSiblingFile in more places
Browse files Browse the repository at this point in the history
  • Loading branch information
tpoole committed Nov 20, 2024
1 parent 5d5fdaf commit 5737c42
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions examples/Assets/DemoUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ inline File getExamplesDirectory() noexcept
return File { CharPointer_UTF8 { PIP_JUCE_EXAMPLES_DIRECTORY_STRING } };
#else
auto currentFile = File::getSpecialLocation (File::SpecialLocationType::currentApplicationFile);
auto exampleDir = currentFile.getParentDirectory().getChildFile ("examples");
auto exampleDir = currentFile.getSiblingFile ("examples");

if (exampleDir.exists())
return exampleDir;
Expand Down Expand Up @@ -109,10 +109,10 @@ inline std::unique_ptr<InputStream> createAssetInputStream (const char* resource
#else
#if JUCE_IOS
auto assetsDir = File::getSpecialLocation (File::currentExecutableFile)
.getParentDirectory().getChildFile ("Assets");
.getSiblingFile ("Assets");
#elif JUCE_MAC
auto assetsDir = File::getSpecialLocation (File::currentExecutableFile)
.getParentDirectory().getParentDirectory().getChildFile ("Resources").getChildFile ("Assets");
.getParentDirectory().getSiblingFile ("Resources").getChildFile ("Assets");

if (! assetsDir.exists())
assetsDir = getExamplesDirectory().getChildFile ("Assets");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ inline File getExamplesDirectory() noexcept
return File { CharPointer_UTF8 { PIP_JUCE_EXAMPLES_DIRECTORY_STRING } };
#else
auto currentFile = File::getSpecialLocation (File::SpecialLocationType::currentApplicationFile);
auto exampleDir = currentFile.getParentDirectory().getChildFile ("examples");
auto exampleDir = currentFile.getSiblingFile ("examples");

if (exampleDir.exists())
return exampleDir;
Expand Down Expand Up @@ -109,10 +109,10 @@ inline std::unique_ptr<InputStream> createAssetInputStream (const char* resource
#else
#if JUCE_IOS
auto assetsDir = File::getSpecialLocation (File::currentExecutableFile)
.getParentDirectory().getChildFile ("Assets");
.getSiblingFile ("Assets");
#elif JUCE_MAC
auto assetsDir = File::getSpecialLocation (File::currentExecutableFile)
.getParentDirectory().getParentDirectory().getChildFile ("Resources").getChildFile ("Assets");
.getParentDirectory().getSiblingFile ("Resources").getChildFile ("Assets");

if (! assetsDir.exists())
assetsDir = getExamplesDirectory().getChildFile ("Assets");
Expand Down
4 changes: 2 additions & 2 deletions examples/DemoRunner/Source/Demos/JUCEDemos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void JUCEDemos::registerDemo (std::function<Component*()> constructorCallback, c
{
#if JUCE_MAC
auto f = File::getSpecialLocation (File::currentExecutableFile)
.getParentDirectory().getParentDirectory().getChildFile ("Resources");
.getParentDirectory().getSiblingFile ("Resources");
#else
auto f = findExamplesDirectoryFromExecutable (File::getSpecialLocation (File::currentApplicationFile));
#endif
Expand All @@ -69,7 +69,7 @@ void JUCEDemos::registerDemo (std::function<Component*()> constructorCallback, c
File JUCEDemos::findExamplesDirectoryFromExecutable (File exec)
{
int numTries = 15;
auto exampleDir = exec.getParentDirectory().getChildFile ("examples");
auto exampleDir = exec.getSiblingFile ("examples");

if (exampleDir.exists())
return exampleDir;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ inline File getExamplesDirectory() noexcept
return File { CharPointer_UTF8 { PIP_JUCE_EXAMPLES_DIRECTORY_STRING } };
#else
auto currentFile = File::getSpecialLocation (File::SpecialLocationType::currentApplicationFile);
auto exampleDir = currentFile.getParentDirectory().getChildFile ("examples");
auto exampleDir = currentFile.getSiblingFile ("examples");

if (exampleDir.exists())
return exampleDir;
Expand Down Expand Up @@ -109,10 +109,10 @@ inline std::unique_ptr<InputStream> createAssetInputStream (const char* resource
#else
#if JUCE_IOS
auto assetsDir = File::getSpecialLocation (File::currentExecutableFile)
.getParentDirectory().getChildFile ("Assets");
.getSiblingFile ("Assets");
#elif JUCE_MAC
auto assetsDir = File::getSpecialLocation (File::currentExecutableFile)
.getParentDirectory().getParentDirectory().getChildFile ("Resources").getChildFile ("Assets");
.getParentDirectory().getSiblingFile ("Resources").getChildFile ("Assets");

if (! assetsDir.exists())
assetsDir = getExamplesDirectory().getChildFile ("Assets");
Expand Down
2 changes: 1 addition & 1 deletion extras/Projucer/Source/Utility/PIPs/jucer_PIPGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ Array<File> PIPGenerator::replaceRelativeIncludesAndGetFilesToMove()
if (path.startsWith ("<") && path.endsWith (">"))
continue;

auto file = pipFile.getParentDirectory().getChildFile (path);
auto file = pipFile.getSiblingFile (path);
files.add (file);

line = line.replace (path, file.getFileName());
Expand Down
8 changes: 4 additions & 4 deletions modules/juce_core/files/juce_File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1158,10 +1158,10 @@ class FileTests final : public UnitTest
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.getParentDirectory().getChildFile ("xyz"));
expect (home.getChildFile (".././xyz") == home.getParentDirectory().getChildFile ("xyz"));
expect (home.getChildFile (".././xyz/./abc") == home.getParentDirectory().getChildFile ("xyz/abc"));
expect (home.getChildFile ("./../xyz") == home.getParentDirectory().getChildFile ("xyz"));
expect (home.getChildFile ("../xyz") == home.getSiblingFile ("xyz"));
expect (home.getChildFile (".././xyz") == home.getSiblingFile ("xyz"));
expect (home.getChildFile (".././xyz/./abc") == home.getSiblingFile ("xyz/abc"));
expect (home.getChildFile ("./../xyz") == home.getSiblingFile ("xyz"));
expect (home.getChildFile ("a1/a2/a3/./../../a4") == home.getChildFile ("a1/a4"));

expect (! File().hasReadAccess());
Expand Down
2 changes: 1 addition & 1 deletion modules/juce_gui_basics/drawables/juce_SVGParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,7 @@ class SVGState
}
else
{
auto linkedFile = originalFile.getParentDirectory().getChildFile (link);
auto linkedFile = originalFile.getSiblingFile (link);

if (linkedFile.existsAsFile())
inputStream = linkedFile.createInputStream();
Expand Down

0 comments on commit 5737c42

Please sign in to comment.