mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 15:44:36 +00:00
fix isFile detection, and aug for script extension searching
This commit is contained in:
parent
b6f3c25fea
commit
f77fa1f286
1 changed files with 13 additions and 1 deletions
|
|
@ -387,7 +387,10 @@ DefineEngineFunction(isFile, bool, ( const char* fileName ),,
|
||||||
|
|
||||||
"@ingroup FileSystem")
|
"@ingroup FileSystem")
|
||||||
{
|
{
|
||||||
Torque::Path givenPath(fileName);
|
String cleanfilename(Torque::Path::CleanSeparators(fileName));
|
||||||
|
Con::expandScriptFilename(sgScriptFilenameBuffer, sizeof(sgScriptFilenameBuffer), cleanfilename.c_str());
|
||||||
|
|
||||||
|
Torque::Path givenPath(Torque::Path::CompressPath(sgScriptFilenameBuffer));
|
||||||
|
|
||||||
if (givenPath.getFileName().isEmpty() && givenPath.getExtension().isNotEmpty())
|
if (givenPath.getFileName().isEmpty() && givenPath.getExtension().isNotEmpty())
|
||||||
{
|
{
|
||||||
|
|
@ -396,7 +399,16 @@ DefineEngineFunction(isFile, bool, ( const char* fileName ),,
|
||||||
givenPath.setFileName(String(".") + givenPath.getExtension());
|
givenPath.setFileName(String(".") + givenPath.getExtension());
|
||||||
givenPath.setExtension("");
|
givenPath.setExtension("");
|
||||||
}
|
}
|
||||||
|
if (Torque::FS::IsFile(givenPath)) return true;
|
||||||
|
|
||||||
|
//try with script file extension
|
||||||
|
if (!Torque::FS::IsFile(givenPath) && givenPath.getExtension().isEmpty())
|
||||||
|
givenPath.setExtension(TORQUE_SCRIPT_EXTENSION);
|
||||||
|
if (Torque::FS::IsFile(givenPath)) return true;
|
||||||
|
|
||||||
|
//finally, try with compiled script file extension
|
||||||
|
if (!Torque::FS::IsFile(givenPath))
|
||||||
|
givenPath.setExtension(String(TORQUE_SCRIPT_EXTENSION)+String(".dso"));
|
||||||
return Torque::FS::IsFile(givenPath);
|
return Torque::FS::IsFile(givenPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue