|
@@ -42,7 +42,7 @@
|
|
|
|
|
|
|
|
|
|
//#define DEBUG_SPEW
|
|
//#define DEBUG_SPEW
|
|
-
|
|
|
|
|
|
+extern void ResolvePathCaseInsensitive(char* pathName, S32 pathNameSize);
|
|
|
|
|
|
namespace Torque
|
|
namespace Torque
|
|
{
|
|
{
|
|
@@ -149,95 +149,32 @@ PosixFileSystem::~PosixFileSystem()
|
|
{
|
|
{
|
|
}
|
|
}
|
|
|
|
|
|
-static void MungeCase(char* pathName, S32 pathNameSize)
|
|
|
|
-{
|
|
|
|
- const int MaxPath = PATH_MAX;
|
|
|
|
-
|
|
|
|
- char tempBuf[MaxPath];
|
|
|
|
- dStrncpy(tempBuf, pathName, pathNameSize);
|
|
|
|
-
|
|
|
|
- AssertFatal(pathName[0] == '/', "PATH must be absolute");
|
|
|
|
-
|
|
|
|
- struct stat filestat;
|
|
|
|
- const int MaxPathEl = 200;
|
|
|
|
- char *currChar = pathName;
|
|
|
|
- char testPath[MaxPath];
|
|
|
|
- char pathEl[MaxPathEl];
|
|
|
|
- bool done = false;
|
|
|
|
-
|
|
|
|
- dStrncpy(tempBuf, "/", MaxPath);
|
|
|
|
- currChar++;
|
|
|
|
-
|
|
|
|
- while (!done)
|
|
|
|
- {
|
|
|
|
- char* termChar = dStrchr(currChar, '/');
|
|
|
|
- if (termChar == NULL)
|
|
|
|
- termChar = dStrchr(currChar, '\0');
|
|
|
|
- AssertFatal(termChar, "Can't find / or NULL terminator");
|
|
|
|
-
|
|
|
|
- S32 pathElLen = (termChar - currChar);
|
|
|
|
- dStrncpy(pathEl, currChar, pathElLen);
|
|
|
|
- pathEl[pathElLen] = '\0';
|
|
|
|
- dStrncpy(testPath, tempBuf, MaxPath);
|
|
|
|
- dStrcat(testPath, pathEl, MaxPath);
|
|
|
|
- if (stat(testPath, &filestat) != -1)
|
|
|
|
- {
|
|
|
|
- dStrncpy(tempBuf, testPath, MaxPath);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- DIR *dir = opendir(tempBuf);
|
|
|
|
- struct dirent* ent;
|
|
|
|
- bool foundMatch = false;
|
|
|
|
- while (dir != NULL && (ent = readdir(dir)) != NULL)
|
|
|
|
- {
|
|
|
|
- if (dStricmp(pathEl, ent->d_name) == 0)
|
|
|
|
- {
|
|
|
|
- foundMatch = true;
|
|
|
|
- dStrcat(tempBuf, ent->d_name, MaxPath);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!foundMatch)
|
|
|
|
- dStrncpy(tempBuf, testPath, MaxPath);
|
|
|
|
- if (dir)
|
|
|
|
- closedir(dir);
|
|
|
|
- }
|
|
|
|
- if (*termChar == '/')
|
|
|
|
- {
|
|
|
|
- dStrcat(tempBuf, "/", MaxPath);
|
|
|
|
- termChar++;
|
|
|
|
- currChar = termChar;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- done = true;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- dStrncpy(pathName, tempBuf, pathNameSize);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// static void MungeCase(char* pathName, S32 pathNameSize)
|
|
|
|
FileNodeRef PosixFileSystem::resolve(const Path& path)
|
|
FileNodeRef PosixFileSystem::resolve(const Path& path)
|
|
{
|
|
{
|
|
String file = buildFileName(_volume,path);
|
|
String file = buildFileName(_volume,path);
|
|
struct stat info;
|
|
struct stat info;
|
|
|
|
|
|
- UTF8 testPath[1024];
|
|
|
|
- dMemcpy(testPath, file.c_str(), file.length());
|
|
|
|
- testPath[file.length()] = 0x00;
|
|
|
|
- MungeCase(testPath, file.length());
|
|
|
|
-
|
|
|
|
- String realFile(testPath);
|
|
|
|
|
|
+#ifdef TORQUE_POSIX_PATH_CASE_INSENSITIVE
|
|
|
|
+ // Resolve the case sensitive filepath
|
|
|
|
+ String::SizeType fileLength = file.length();
|
|
|
|
+ UTF8 caseSensitivePath[fileLength + 1];
|
|
|
|
+ dMemcpy(caseSensitivePath, file.c_str(), fileLength);
|
|
|
|
+ caseSensitivePath[fileLength] = 0x00;
|
|
|
|
+ ResolvePathCaseInsensitive(caseSensitivePath, fileLength);
|
|
|
|
+
|
|
|
|
+ String caseSensitiveFile(caseSensitivePath);
|
|
|
|
+#else
|
|
|
|
+ String caseSensitiveFile = file;
|
|
|
|
+#endif
|
|
|
|
|
|
- if (stat(realFile.c_str(),&info) == 0)
|
|
|
|
|
|
+ if (stat(caseSensitiveFile.c_str(),&info) == 0)
|
|
{
|
|
{
|
|
// Construct the appropriate object
|
|
// Construct the appropriate object
|
|
if (S_ISREG(info.st_mode))
|
|
if (S_ISREG(info.st_mode))
|
|
- return new PosixFile(path,realFile);
|
|
|
|
|
|
+ return new PosixFile(path,caseSensitiveFile);
|
|
|
|
|
|
if (S_ISDIR(info.st_mode))
|
|
if (S_ISDIR(info.st_mode))
|
|
- return new PosixDirectory(path,realFile);
|
|
|
|
|
|
+ return new PosixDirectory(path,caseSensitiveFile);
|
|
}
|
|
}
|
|
|
|
|
|
return 0;
|
|
return 0;
|