Skip to content

Commit

Permalink
build_tools: Fix Windows assertion when path contains ellipses
Browse files Browse the repository at this point in the history
A path of "$(SRCROOT)/../../SomeFile.cpp" would lose the fake C:\ prefix
when the ellipses are collapsed, and trigger a non-absolute File
assertion.
  • Loading branch information
szarvas committed Jan 3, 2024
1 parent b016798 commit 9694c1a
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions extras/Build/juce_build_tools/utils/juce_RelativePath.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,12 @@ namespace juce::build_tools

File getFakeFile() const
{
#if JUCE_WINDOWS
if (isAbsolutePath (path))
{
// This is a hack to convert unix-style absolute paths into valid absolute Windows paths to avoid hitting
// an assertion in File::parseAbsolutePath().
if (path.startsWithChar (L'/') || path.startsWithChar (L'$') || path.startsWithChar (L'~'))
return File (String ("C:\\") + windowsStylePath (path.substring (1)));

return File (path);
}
#endif
const auto unixStylePath = toUnixStyle();
const auto name = unixStylePath.substring (unixStylePath.lastIndexOfChar ('/') + 1);

// This method gets called very often, so we'll cache this directory.
static const File currentWorkingDirectory (File::getCurrentWorkingDirectory());
return currentWorkingDirectory.getChildFile (path);
return currentWorkingDirectory.getChildFile (name);
}
};

Expand Down

0 comments on commit 9694c1a

Please sign in to comment.