mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 16:44:36 +00:00
Update POSIXFileio.cpp
fixe fileio test linux
This commit is contained in:
parent
2e91837f6a
commit
3d46cf51d0
1 changed files with 34 additions and 10 deletions
|
|
@ -990,19 +990,43 @@ StringTableEntry Platform::getExecutablePath()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool Platform::isFile(const char *pFilePath)
|
bool Platform::isFile(const char *pFilePath)
|
||||||
{
|
{
|
||||||
if (!pFilePath || !*pFilePath)
|
if (!pFilePath || !*pFilePath)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
char pathName[MaxPath];
|
||||||
|
|
||||||
|
// if it starts with cwd, we need to strip that off so that we can look for
|
||||||
|
// the file in the pref dir
|
||||||
|
char cwd[MaxPath];
|
||||||
|
getcwd(cwd, MaxPath);
|
||||||
|
|
||||||
|
if (dStrstr(pFilePath, cwd) == pFilePath)
|
||||||
|
pFilePath = pFilePath + dStrlen(cwd) + 1;
|
||||||
|
|
||||||
|
// if its relative, first look in the pref dir
|
||||||
|
if (pFilePath[0] != '/' && pFilePath[0] != '\\')
|
||||||
|
{
|
||||||
|
MungePath(pathName, MaxPath, pFilePath, GetPrefDir());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// here if the path is absolute or not in the pref dir
|
||||||
|
MungePath(pathName, MaxPath, pFilePath, cwd);
|
||||||
|
}
|
||||||
|
|
||||||
// Get file info
|
// Get file info
|
||||||
struct stat fStat;
|
struct stat fStat;
|
||||||
if (stat(pFilePath, &fStat) < 0)
|
if (stat(pFilePath, &fStat) == 0)
|
||||||
{
|
if ((fStat.st_mode & S_IFMT) == S_IFREG)
|
||||||
// Since file does not exist on disk see if it exists in a zip file loaded
|
return true;
|
||||||
return Torque::FS::IsFile(pFilePath);
|
|
||||||
}
|
// Since stat failed see if it exists in a zip file loaded
|
||||||
|
if (Torque::FS::IsFile(pFilePath))
|
||||||
|
return true;
|
||||||
|
|
||||||
// if the file is a "regular file" then true
|
// if the file is a "regular file" then true
|
||||||
if ( (fStat.st_mode & S_IFMT) == S_IFREG)
|
|
||||||
return true;
|
|
||||||
// must be some other file (directory, device, etc.)
|
// must be some other file (directory, device, etc.)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -1341,4 +1365,4 @@ void setExePathName(const char* exePathName)
|
||||||
sBinName = binName;
|
sBinName = binName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue