This commit is contained in:
Igor Pavlov
2005-05-30 00:00:00 +00:00
committed by Kornel Lesiński
parent 8c1b5c7b7e
commit 3c510ba80b
926 changed files with 40559 additions and 23519 deletions

View File

@@ -3,20 +3,32 @@
#include "StdAfx.h"
#include "ExtractingFilePath.h"
static void ReplaceDisk(UString &s)
{
int i;
for (i = 0; i < s.Length(); i++)
if (s[i] != ' ')
break;
if (s.Length() > i + 1)
{
if (s[i + 1] == L':')
{
s.Delete(i + 1);
// s.Insert(i + 1, L'_');
}
}
}
UString GetCorrectFileName(const UString &path)
{
UString result = path;
result.Trim();
result.Replace(L"..\\", L"");
result.Replace(L"../", L"");
if (result.Length() > 1)
{
if (result[1] == L':')
{
result.Delete(1);
// result.Insert(first + 1, L'_');
}
UString test = path;
test.Trim();
if (test == L"..")
result.Replace(L"..", L"");
}
ReplaceDisk(result);
return result;
}
@@ -29,7 +41,6 @@ UString GetCorrectPath(const UString &path)
break;
while(result.Length() > first)
{
if (result[first] == L'\\' || result[first] == L'/')
{
result.Delete(first);
@@ -40,15 +51,19 @@ UString GetCorrectPath(const UString &path)
result.Replace(L"..\\", L"");
result.Replace(L"../", L"");
if (result.Length() > 1)
{
if (result[first + 1] == L':')
{
result.Delete(first + 1);
// result.Insert(first + 1, L'_');
}
}
ReplaceDisk(result);
return result;
}
void MakeCorrectPath(UStringVector &pathParts)
{
for (int i = 0; i < pathParts.Size();)
{
UString &s = pathParts[i];
s = GetCorrectFileName(s);
if (s.IsEmpty())
pathParts.Delete(i);
else
i++;
}
}