Fix update failing to install if the system temporary directory path starts with a lower-case letter.

Fix FileUtils::isRelative() to check if the upper-case version of the first character
in the path is a letter.
This commit is contained in:
Robert Knight 2011-12-01 11:49:27 +00:00
parent df89da7ebd
commit 66bafb317f
3 changed files with 16 additions and 3 deletions

View file

@ -461,7 +461,7 @@ std::string FileUtils::tempPath()
bool startsWithDriveLetter(const char* path)
{
return strlen(path) >= 2 &&
(path[0] >= 'A' && path[0] <= 'Z') &&
(isalpha(path[0])) &&
path[1] == ':';
}

View file

@ -11,9 +11,21 @@ void TestFileUtils::testDirName()
#endif
}
void TestFileUtils::testIsRelative()
{
#ifdef PLATFORM_WINDOWS
TEST_COMPARE(FileUtils::isRelative("temp"),true);
TEST_COMPARE(FileUtils::isRelative("D:/temp"),false);
TEST_COMPARE(FileUtils::isRelative("d:/temp"),false);
#else
TEST_COMPARE(FileUtils::isRelative("/tmp"),false);
TEST_COMPARE(FileUtils::isRelative("tmp"),true);
#endif
}
int main(int,char**)
{
TestList<TestFileUtils> tests;
tests.addTest(&TestFileUtils::testDirName);
return TestUtils::runTest(tests);
}
}

View file

@ -4,4 +4,5 @@ class TestFileUtils
{
public:
void testDirName();
};
void testIsRelative();
};