|
|
|
@@ -70,8 +70,24 @@ File& File::operator= (File&& other) noexcept |
|
|
|
|
|
|
|
const File File::nonexistent;
|
|
|
|
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
static String removeEllipsis (const String& path)
|
|
|
|
{
|
|
|
|
StringArray toks;
|
|
|
|
toks.addTokens (path, File::separatorString, StringRef());
|
|
|
|
|
|
|
|
for (int i = 1; i < toks.size(); ++i)
|
|
|
|
{
|
|
|
|
if (toks[i] == ".." && toks[i - 1] != "..")
|
|
|
|
{
|
|
|
|
toks.removeRange (i - 1, 2);
|
|
|
|
i = jmax (0, i - 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return toks.joinIntoString (File::separatorString);
|
|
|
|
}
|
|
|
|
|
|
|
|
String File::parseAbsolutePath (const String& p)
|
|
|
|
{
|
|
|
|
if (p.isEmpty())
|
|
|
|
@@ -81,6 +97,9 @@ String File::parseAbsolutePath (const String& p) |
|
|
|
// Windows..
|
|
|
|
String path (p.replaceCharacter ('/', '\\'));
|
|
|
|
|
|
|
|
if (path.contains ("\\..\\"))
|
|
|
|
path = removeEllipsis (path);
|
|
|
|
|
|
|
|
if (path.startsWithChar (separator))
|
|
|
|
{
|
|
|
|
if (path[1] != separator)
|
|
|
|
@@ -120,6 +139,9 @@ String File::parseAbsolutePath (const String& p) |
|
|
|
|
|
|
|
String path (p);
|
|
|
|
|
|
|
|
if (path.contains ("/../"))
|
|
|
|
path = removeEllipsis (path);
|
|
|
|
|
|
|
|
if (path.startsWithChar ('~'))
|
|
|
|
{
|
|
|
|
if (path[1] == separator || path[1] == 0)
|
|
|
|
|