mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 15:44:36 +00:00
Merge pull request #617 from Ragora/adjustment-unix-case-insensitivity
Adjustment: POSIX Case Insensitivty
This commit is contained in:
commit
ba9debf89f
6 changed files with 74 additions and 12 deletions
|
|
@ -407,8 +407,15 @@ FileNodeRef ZipFileSystem::resolve(const Path& path)
|
||||||
if(mZipNameIsDir)
|
if(mZipNameIsDir)
|
||||||
{
|
{
|
||||||
// Remove the fake root from the name so things can be found
|
// Remove the fake root from the name so things can be found
|
||||||
|
#ifdef TORQUE_ZIP_PATH_CASE_INSENSITIVE
|
||||||
|
String lowerFakeRoot = String::ToLower(mFakeRoot);
|
||||||
|
String lowerName = String::ToLower(name);
|
||||||
|
if(lowerName.find(lowerFakeRoot) == 0)
|
||||||
|
name = name.substr(mFakeRoot.length());
|
||||||
|
#else
|
||||||
if(name.find(mFakeRoot) == 0)
|
if(name.find(mFakeRoot) == 0)
|
||||||
name = name.substr(mFakeRoot.length());
|
name = name.substr(mFakeRoot.length());
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef TORQUE_DISABLE_FIND_ROOT_WITHIN_ZIP
|
#ifdef TORQUE_DISABLE_FIND_ROOT_WITHIN_ZIP
|
||||||
else
|
else
|
||||||
|
|
@ -480,8 +487,15 @@ FileNodeRef ZipFileSystem::resolveLoose(const Path& path)
|
||||||
if(mZipNameIsDir)
|
if(mZipNameIsDir)
|
||||||
{
|
{
|
||||||
// Remove the fake root from the name so things can be found
|
// Remove the fake root from the name so things can be found
|
||||||
|
#ifdef TORQUE_ZIP_PATH_CASE_INSENSITIVE
|
||||||
|
String lowerFakeRoot = String::ToLower(mFakeRoot);
|
||||||
|
String lowerName = String::ToLower(name);
|
||||||
|
if(lowerName.find(lowerFakeRoot) == 0)
|
||||||
|
name = name.substr(mFakeRoot.length());
|
||||||
|
#else
|
||||||
if(name.find(mFakeRoot) == 0)
|
if(name.find(mFakeRoot) == 0)
|
||||||
name = name.substr(mFakeRoot.length());
|
name = name.substr(mFakeRoot.length());
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef TORQUE_DISABLE_FIND_ROOT_WITHIN_ZIP
|
#ifdef TORQUE_DISABLE_FIND_ROOT_WITHIN_ZIP
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
|
|
||||||
//#define DEBUG_SPEW
|
//#define DEBUG_SPEW
|
||||||
|
extern void ResolvePathCaseInsensitive(char* pathName, S32 pathNameSize);
|
||||||
|
|
||||||
namespace Torque
|
namespace Torque
|
||||||
{
|
{
|
||||||
|
|
@ -153,17 +153,35 @@ FileNodeRef PosixFileSystem::resolve(const Path& path)
|
||||||
{
|
{
|
||||||
String file = buildFileName(_volume,path);
|
String file = buildFileName(_volume,path);
|
||||||
struct stat info;
|
struct stat info;
|
||||||
if (stat(file.c_str(),&info) == 0)
|
|
||||||
|
#ifdef TORQUE_POSIX_PATH_CASE_INSENSITIVE
|
||||||
|
// Resolve the case sensitive filepath
|
||||||
|
String::SizeType fileLength = file.length();
|
||||||
|
UTF8* caseSensitivePath = new UTF8[fileLength + 1];
|
||||||
|
dMemcpy(caseSensitivePath, file.c_str(), fileLength);
|
||||||
|
caseSensitivePath[fileLength] = 0x00;
|
||||||
|
ResolvePathCaseInsensitive(caseSensitivePath, fileLength);
|
||||||
|
|
||||||
|
String caseSensitiveFile(caseSensitivePath);
|
||||||
|
#else
|
||||||
|
String caseSensitiveFile = file;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FileNodeRef result = 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,file);
|
result = new PosixFile(path,caseSensitiveFile);
|
||||||
|
|
||||||
if (S_ISDIR(info.st_mode))
|
if (S_ISDIR(info.st_mode))
|
||||||
return new PosixDirectory(path,file);
|
result = new PosixDirectory(path,caseSensitiveFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
#ifdef TORQUE_POSIX_PATH_CASE_INSENSITIVE
|
||||||
|
delete[] caseSensitivePath;
|
||||||
|
#endif
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileNodeRef PosixFileSystem::create(const Path& path, FileNode::Mode mode)
|
FileNodeRef PosixFileSystem::create(const Path& path, FileNode::Mode mode)
|
||||||
|
|
|
||||||
|
|
@ -238,10 +238,12 @@ Win32FileSystem::~Win32FileSystem()
|
||||||
|
|
||||||
void Win32FileSystem::verifyCompatibility(const Path& _path, WIN32_FIND_DATAW _info)
|
void Win32FileSystem::verifyCompatibility(const Path& _path, WIN32_FIND_DATAW _info)
|
||||||
{
|
{
|
||||||
|
#ifndef TORQUE_POSIX_PATH_CASE_INSENSITIVE
|
||||||
if (_path.getFullFileName().isNotEmpty() && _path.getFullFileName().compare(String(_info.cFileName)) != 0)
|
if (_path.getFullFileName().isNotEmpty() && _path.getFullFileName().compare(String(_info.cFileName)) != 0)
|
||||||
{
|
{
|
||||||
Con::warnf("Linux Compatibility Warning: %s != %s", String(_info.cFileName).c_str(), _path.getFullFileName().c_str());
|
Con::warnf("Linux Compatibility Warning: %s != %s", String(_info.cFileName).c_str(), _path.getFullFileName().c_str());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
FileNodeRef Win32FileSystem::resolve(const Path& path)
|
FileNodeRef Win32FileSystem::resolve(const Path& path)
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
directory. Files are never created or modified in the game directory.
|
directory. Files are never created or modified in the game directory.
|
||||||
|
|
||||||
For case-sensitivity, the MungePath code will test whether a given path
|
For case-sensitivity, the MungePath code will test whether a given path
|
||||||
specified by the engine exists. If not, it will use the MungeCase function
|
specified by the engine exists. If not, it will use the ResolvePathCaseInsensitive function
|
||||||
which will try to determine if an actual filesystem path matches the
|
which will try to determine if an actual filesystem path matches the
|
||||||
specified path case insensitive. If one is found, the actual path
|
specified path case insensitive. If one is found, the actual path
|
||||||
transparently (we hope) replaces the one requested by the engine.
|
transparently (we hope) replaces the one requested by the engine.
|
||||||
|
|
@ -183,7 +183,7 @@ 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.
|
||||||
static void MungeCase(char* pathName, S32 pathNameSize)
|
void ResolvePathCaseInsensitive(char* pathName, S32 pathNameSize)
|
||||||
{
|
{
|
||||||
char tempBuf[MaxPath];
|
char tempBuf[MaxPath];
|
||||||
dStrncpy(tempBuf, pathName, pathNameSize);
|
dStrncpy(tempBuf, pathName, pathNameSize);
|
||||||
|
|
@ -296,7 +296,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
|
||||||
MungeCase(dest, destSize);
|
ResolvePathCaseInsensitive(dest, destSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -1284,8 +1284,24 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
|
||||||
|
|
||||||
bool Platform::dumpDirectories(const char *path, Vector<StringTableEntry> &directoryVector, S32 depth, bool noBasePath)
|
bool Platform::dumpDirectories(const char *path, Vector<StringTableEntry> &directoryVector, S32 depth, bool noBasePath)
|
||||||
{
|
{
|
||||||
bool retVal = recurseDumpDirectories(path, "", directoryVector, -1, depth, noBasePath);
|
#ifdef TORQUE_POSIX_PATH_CASE_INSENSITIVE
|
||||||
|
dsize_t pathLength = dStrlen(path);
|
||||||
|
char* caseSensitivePath = new char[pathLength + 1];
|
||||||
|
|
||||||
|
// Load path into temporary buffer
|
||||||
|
dMemcpy(caseSensitivePath, path, pathLength);
|
||||||
|
caseSensitivePath[pathLength] = 0x00;
|
||||||
|
ResolvePathCaseInsensitive(caseSensitivePath, pathLength);
|
||||||
|
#else
|
||||||
|
const char* caseSensitivePath = path;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool retVal = recurseDumpDirectories(caseSensitivePath, "", directoryVector, -1, depth, noBasePath);
|
||||||
clearExcludedDirectories();
|
clearExcludedDirectories();
|
||||||
|
|
||||||
|
#ifdef TORQUE_POSIX_PATH_CASE_INSENSITIVE
|
||||||
|
delete[] caseSensitivePath;
|
||||||
|
#endif
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -163,6 +163,12 @@ endif()
|
||||||
option(TORQUE_MULTITHREAD "Multi Threading" ON)
|
option(TORQUE_MULTITHREAD "Multi Threading" ON)
|
||||||
mark_as_advanced(TORQUE_MULTITHREAD)
|
mark_as_advanced(TORQUE_MULTITHREAD)
|
||||||
|
|
||||||
|
option(TORQUE_POSIX_PATH_CASE_INSENSITIVE "POSIX Pathing Case Insensitivity" ON)
|
||||||
|
mark_as_advanced(TORQUE_POSIX_PATH_CASE_INSENSITIVE)
|
||||||
|
|
||||||
|
option(TORQUE_ZIP_PATH_CASE_INSENSITIVE "ZIP Pathing Case Insensitivity" ON)
|
||||||
|
mark_as_advanced(TORQUE_ZIP_PATH_CASE_INSENSITIVE)
|
||||||
|
|
||||||
option(TORQUE_DISABLE_MEMORY_MANAGER "Disable memory manager" ON)
|
option(TORQUE_DISABLE_MEMORY_MANAGER "Disable memory manager" ON)
|
||||||
mark_as_advanced(TORQUE_DISABLE_MEMORY_MANAGER)
|
mark_as_advanced(TORQUE_DISABLE_MEMORY_MANAGER)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,12 @@
|
||||||
/// Define me if you want to enable Arcane FX support.
|
/// Define me if you want to enable Arcane FX support.
|
||||||
#cmakedefine TORQUE_AFX_ENABLED
|
#cmakedefine TORQUE_AFX_ENABLED
|
||||||
|
|
||||||
|
/// Define me if you want path case insensitivity support on POSIX systems. Does nothing on Windows.
|
||||||
|
#cmakedefine TORQUE_POSIX_PATH_CASE_INSENSITIVE
|
||||||
|
|
||||||
|
/// Define me if you want path case insensitivity support in ZIP files.
|
||||||
|
#cmakedefine TORQUE_ZIP_PATH_CASE_INSENSITIVE
|
||||||
|
|
||||||
/// Define me if you want to enable multithreading support.
|
/// Define me if you want to enable multithreading support.
|
||||||
#cmakedefine TORQUE_MULTITHREAD
|
#cmakedefine TORQUE_MULTITHREAD
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue