DirectoryExists: Return true for the root directory ("/")

stable-5.2
Armin Burgmeier 2009-09-22 22:09:13 -04:00
parent 5c6a9b2347
commit d8950094d8
1 changed files with 6 additions and 2 deletions

View File

@ -618,15 +618,19 @@ bool CreatePath(const std::string &path)
bool DirectoryExists(const char *szFilename)
{
// Ignore trailing slash or backslash
// Ignore trailing slash or backslash, except when we are probing the
// root directory '/'.
char bufFilename[_MAX_PATH + 1];
if (szFilename && szFilename[0])
if ((szFilename[SLen(szFilename) - 1] == '\\') || (szFilename[SLen(szFilename) - 1] == '/'))
{
unsigned int len = SLen(szFilename);
if (len > 1 && ((szFilename[len - 1] == '\\') || (szFilename[len - 1] == '/')))
{
SCopy(szFilename, bufFilename, _MAX_PATH);
bufFilename[SLen(bufFilename) - 1] = 0;
szFilename = bufFilename;
}
}
// Check file attributes
#ifdef _WIN32
struct _finddata_t fdt; int shnd;