From f77fa1f28633565bf8f3e272f1a1ff4aadf671c8 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Thu, 23 Feb 2023 16:59:10 -0600 Subject: [PATCH] fix isFile detection, and aug for script extension searching --- Engine/source/console/fileSystemFunctions.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Engine/source/console/fileSystemFunctions.cpp b/Engine/source/console/fileSystemFunctions.cpp index cabb0b8d7..a9e2f47e6 100644 --- a/Engine/source/console/fileSystemFunctions.cpp +++ b/Engine/source/console/fileSystemFunctions.cpp @@ -387,7 +387,10 @@ DefineEngineFunction(isFile, bool, ( const char* fileName ),, "@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()) { @@ -396,7 +399,16 @@ DefineEngineFunction(isFile, bool, ( const char* fileName ),, givenPath.setFileName(String(".") + givenPath.getExtension()); 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); }