mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 16:44:36 +00:00
Merge pull request #625 from Ragora/bugfix-case-insensitivity-fatal-assert
BugFix: Correct a fatal error that may be thrown in case insensitive Unix IO
This commit is contained in:
commit
14ebeaf3eb
2 changed files with 14 additions and 8 deletions
|
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
|
|
||||||
//#define DEBUG_SPEW
|
//#define DEBUG_SPEW
|
||||||
extern void ResolvePathCaseInsensitive(char* pathName, S32 pathNameSize);
|
extern bool ResolvePathCaseInsensitive(char* pathName, S32 pathNameSize, bool requiredAbsolute);
|
||||||
|
|
||||||
namespace Torque
|
namespace Torque
|
||||||
{
|
{
|
||||||
|
|
@ -160,8 +160,7 @@ FileNodeRef PosixFileSystem::resolve(const Path& path)
|
||||||
UTF8* caseSensitivePath = new UTF8[fileLength + 1];
|
UTF8* caseSensitivePath = new UTF8[fileLength + 1];
|
||||||
dMemcpy(caseSensitivePath, file.c_str(), fileLength);
|
dMemcpy(caseSensitivePath, file.c_str(), fileLength);
|
||||||
caseSensitivePath[fileLength] = 0x00;
|
caseSensitivePath[fileLength] = 0x00;
|
||||||
ResolvePathCaseInsensitive(caseSensitivePath, fileLength);
|
ResolvePathCaseInsensitive(caseSensitivePath, fileLength, false);
|
||||||
|
|
||||||
String caseSensitiveFile(caseSensitivePath);
|
String caseSensitiveFile(caseSensitivePath);
|
||||||
#else
|
#else
|
||||||
String caseSensitiveFile = file;
|
String caseSensitiveFile = file;
|
||||||
|
|
@ -181,6 +180,7 @@ FileNodeRef PosixFileSystem::resolve(const Path& path)
|
||||||
#ifdef TORQUE_POSIX_PATH_CASE_INSENSITIVE
|
#ifdef TORQUE_POSIX_PATH_CASE_INSENSITIVE
|
||||||
delete[] caseSensitivePath;
|
delete[] caseSensitivePath;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -183,12 +183,17 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
|
||||||
// munge the case of the specified pathName. This means try to find the actual
|
// munge the case of the specified pathName. This means try to find the actual
|
||||||
// filename in with case-insensitive matching on the specified pathName, and
|
// filename in with case-insensitive matching on the specified pathName, and
|
||||||
// store the actual found name.
|
// store the actual found name.
|
||||||
void ResolvePathCaseInsensitive(char* pathName, S32 pathNameSize)
|
bool ResolvePathCaseInsensitive(char* pathName, S32 pathNameSize, bool requiredAbsolute)
|
||||||
{
|
{
|
||||||
char tempBuf[MaxPath];
|
char tempBuf[MaxPath];
|
||||||
dStrncpy(tempBuf, pathName, pathNameSize);
|
dStrncpy(tempBuf, pathName, pathNameSize);
|
||||||
|
|
||||||
AssertFatal(pathName[0] == '/', "PATH must be absolute");
|
// Check if we're an absolute path
|
||||||
|
if (pathName[0] != '/')
|
||||||
|
{
|
||||||
|
AssertFatal(!requiredAbsolute, "PATH must be absolute");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
struct stat filestat;
|
struct stat filestat;
|
||||||
const int MaxPathEl = 200;
|
const int MaxPathEl = 200;
|
||||||
|
|
@ -196,6 +201,7 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
|
||||||
char testPath[MaxPath];
|
char testPath[MaxPath];
|
||||||
char pathEl[MaxPathEl];
|
char pathEl[MaxPathEl];
|
||||||
bool done = false;
|
bool done = false;
|
||||||
|
bool foundMatch = false;
|
||||||
|
|
||||||
dStrncpy(tempBuf, "/", MaxPath);
|
dStrncpy(tempBuf, "/", MaxPath);
|
||||||
currChar++;
|
currChar++;
|
||||||
|
|
@ -220,7 +226,6 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
|
||||||
{
|
{
|
||||||
DIR *dir = opendir(tempBuf);
|
DIR *dir = opendir(tempBuf);
|
||||||
struct dirent* ent;
|
struct dirent* ent;
|
||||||
bool foundMatch = false;
|
|
||||||
while (dir != NULL && (ent = readdir(dir)) != NULL)
|
while (dir != NULL && (ent = readdir(dir)) != NULL)
|
||||||
{
|
{
|
||||||
if (dStricmp(pathEl, ent->d_name) == 0)
|
if (dStricmp(pathEl, ent->d_name) == 0)
|
||||||
|
|
@ -247,6 +252,7 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
|
||||||
}
|
}
|
||||||
|
|
||||||
dStrncpy(pathName, tempBuf, pathNameSize);
|
dStrncpy(pathName, tempBuf, pathNameSize);
|
||||||
|
return foundMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -296,7 +302,7 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// otherwise munge the case of the path
|
// otherwise munge the case of the path
|
||||||
ResolvePathCaseInsensitive(dest, destSize);
|
ResolvePathCaseInsensitive(dest, destSize, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -1291,7 +1297,7 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
|
||||||
// Load path into temporary buffer
|
// Load path into temporary buffer
|
||||||
dMemcpy(caseSensitivePath, path, pathLength);
|
dMemcpy(caseSensitivePath, path, pathLength);
|
||||||
caseSensitivePath[pathLength] = 0x00;
|
caseSensitivePath[pathLength] = 0x00;
|
||||||
ResolvePathCaseInsensitive(caseSensitivePath, pathLength);
|
ResolvePathCaseInsensitive(caseSensitivePath, pathLength, false);
|
||||||
#else
|
#else
|
||||||
const char* caseSensitivePath = path;
|
const char* caseSensitivePath = path;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue