mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 00:24:40 +00:00
refactor new IsScriptFile method to be zip-safe
This commit is contained in:
parent
8976250fdf
commit
b8eaefc21e
11 changed files with 30 additions and 28 deletions
|
|
@ -136,7 +136,7 @@ void CubemapAsset::initializeAsset()
|
||||||
{
|
{
|
||||||
mScriptFile = expandAssetFilePath(mScriptFile);
|
mScriptFile = expandAssetFilePath(mScriptFile);
|
||||||
|
|
||||||
if(Platform::isScriptFile(mScriptFile))
|
if(Torque::FS::IsScriptFile(mScriptFile))
|
||||||
Con::executeFile(mScriptFile, false, false);
|
Con::executeFile(mScriptFile, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -144,7 +144,7 @@ void CubemapAsset::onAssetRefresh()
|
||||||
{
|
{
|
||||||
mScriptFile = expandAssetFilePath(mScriptFile);
|
mScriptFile = expandAssetFilePath(mScriptFile);
|
||||||
|
|
||||||
if (Platform::isScriptFile(mScriptFile))
|
if (Torque::FS::IsScriptFile(mScriptFile))
|
||||||
Con::executeFile(mScriptFile, false, false);
|
Con::executeFile(mScriptFile, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -119,12 +119,12 @@ void GUIAsset::initializeAsset()
|
||||||
{
|
{
|
||||||
mGUIPath = expandAssetFilePath(mGUIFile);
|
mGUIPath = expandAssetFilePath(mGUIFile);
|
||||||
|
|
||||||
if (Platform::isScriptFile(mGUIPath))
|
if (Torque::FS::IsScriptFile(mGUIPath))
|
||||||
Con::executeFile(mGUIPath, false, false);
|
Con::executeFile(mGUIPath, false, false);
|
||||||
|
|
||||||
mScriptPath = expandAssetFilePath(mScriptFile);
|
mScriptPath = expandAssetFilePath(mScriptFile);
|
||||||
|
|
||||||
if (Platform::isScriptFile(mScriptPath))
|
if (Torque::FS::IsScriptFile(mScriptPath))
|
||||||
Con::executeFile(mScriptPath, false, false);
|
Con::executeFile(mScriptPath, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -132,12 +132,12 @@ void GUIAsset::onAssetRefresh()
|
||||||
{
|
{
|
||||||
mGUIPath = expandAssetFilePath(mGUIFile);
|
mGUIPath = expandAssetFilePath(mGUIFile);
|
||||||
|
|
||||||
if (Platform::isScriptFile(mGUIPath))
|
if (Torque::FS::IsScriptFile(mGUIPath))
|
||||||
Con::executeFile(mGUIPath, false, false);
|
Con::executeFile(mGUIPath, false, false);
|
||||||
|
|
||||||
mScriptPath = expandAssetFilePath(mScriptFile);
|
mScriptPath = expandAssetFilePath(mScriptFile);
|
||||||
|
|
||||||
if (Platform::isScriptFile(mScriptPath))
|
if (Torque::FS::IsScriptFile(mScriptPath))
|
||||||
Con::executeFile(mScriptPath, false, false);
|
Con::executeFile(mScriptPath, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@ void GameObjectAsset::initializeAsset()
|
||||||
//Ensure we have an expanded filepath
|
//Ensure we have an expanded filepath
|
||||||
mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;
|
mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;
|
||||||
|
|
||||||
if (Platform::isScriptFile(mScriptPath))
|
if (Torque::FS::IsScriptFile(mScriptPath))
|
||||||
Con::executeFile(mScriptPath, false, false);
|
Con::executeFile(mScriptPath, false, false);
|
||||||
|
|
||||||
mTAMLPath = getOwned() ? expandAssetFilePath(mTAMLFile) : mTAMLPath;
|
mTAMLPath = getOwned() ? expandAssetFilePath(mTAMLFile) : mTAMLPath;
|
||||||
|
|
@ -144,7 +144,7 @@ void GameObjectAsset::onAssetRefresh()
|
||||||
//Ensure we have an expanded filepath
|
//Ensure we have an expanded filepath
|
||||||
mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;
|
mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;
|
||||||
|
|
||||||
if (Platform::isScriptFile(mScriptPath))
|
if (Torque::FS::IsScriptFile(mScriptPath))
|
||||||
Con::executeFile(mScriptPath, false, false);
|
Con::executeFile(mScriptPath, false, false);
|
||||||
|
|
||||||
mTAMLPath = getOwned() ? expandAssetFilePath(mTAMLFile) : mTAMLPath;
|
mTAMLPath = getOwned() ? expandAssetFilePath(mTAMLFile) : mTAMLPath;
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,7 @@ void MaterialAsset::initializeAsset()
|
||||||
|
|
||||||
mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;
|
mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;
|
||||||
|
|
||||||
if (Platform::isScriptFile(mScriptPath))
|
if (Torque::FS::IsScriptFile(mScriptPath))
|
||||||
Con::executeFile(mScriptPath, false, false);
|
Con::executeFile(mScriptPath, false, false);
|
||||||
|
|
||||||
loadMaterial();
|
loadMaterial();
|
||||||
|
|
@ -176,7 +176,7 @@ void MaterialAsset::onAssetRefresh()
|
||||||
{
|
{
|
||||||
mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;
|
mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;
|
||||||
|
|
||||||
if (Platform::isScriptFile(mScriptPath))
|
if (Torque::FS::IsScriptFile(mScriptPath))
|
||||||
Con::executeFile(mScriptPath, false, false);
|
Con::executeFile(mScriptPath, false, false);
|
||||||
|
|
||||||
loadMaterial();
|
loadMaterial();
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ void PostEffectAsset::initializeAsset()
|
||||||
mHLSLShaderPath = expandAssetFilePath(mHLSLShaderFile);
|
mHLSLShaderPath = expandAssetFilePath(mHLSLShaderFile);
|
||||||
mGLSLShaderPath = expandAssetFilePath(mGLSLShaderFile);
|
mGLSLShaderPath = expandAssetFilePath(mGLSLShaderFile);
|
||||||
|
|
||||||
if (Platform::isScriptFile(mScriptPath))
|
if (Torque::FS::IsScriptFile(mScriptPath))
|
||||||
Con::executeFile(mScriptPath, false, false);
|
Con::executeFile(mScriptPath, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -146,7 +146,7 @@ void PostEffectAsset::onAssetRefresh()
|
||||||
mHLSLShaderPath = expandAssetFilePath(mHLSLShaderFile);
|
mHLSLShaderPath = expandAssetFilePath(mHLSLShaderFile);
|
||||||
mGLSLShaderPath = expandAssetFilePath(mGLSLShaderFile);
|
mGLSLShaderPath = expandAssetFilePath(mGLSLShaderFile);
|
||||||
|
|
||||||
if (Platform::isScriptFile(mScriptPath))
|
if (Torque::FS::IsScriptFile(mScriptPath))
|
||||||
Con::executeFile(mScriptPath, false, false);
|
Con::executeFile(mScriptPath, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ void ScriptAsset::initializeAsset()
|
||||||
{
|
{
|
||||||
mScriptPath = expandAssetFilePath(mScriptFile);
|
mScriptPath = expandAssetFilePath(mScriptFile);
|
||||||
|
|
||||||
if (Platform::isScriptFile(mScriptPath))
|
if (Torque::FS::IsScriptFile(mScriptPath))
|
||||||
{
|
{
|
||||||
//We're initialized properly, so we'll go ahead and kick along any dependencies we may have as well
|
//We're initialized properly, so we'll go ahead and kick along any dependencies we may have as well
|
||||||
AssetManager::typeAssetDependsOnHash::Iterator assetDependenciesItr = mpOwningAssetManager->getDependedOnAssets()->find(mpAssetDefinition->mAssetId);
|
AssetManager::typeAssetDependsOnHash::Iterator assetDependenciesItr = mpOwningAssetManager->getDependedOnAssets()->find(mpAssetDefinition->mAssetId);
|
||||||
|
|
@ -152,7 +152,7 @@ void ScriptAsset::onAssetRefresh()
|
||||||
{
|
{
|
||||||
mScriptPath = expandAssetFilePath(mScriptFile);
|
mScriptPath = expandAssetFilePath(mScriptFile);
|
||||||
|
|
||||||
if (Platform::isScriptFile(mScriptPath))
|
if (Torque::FS::IsScriptFile(mScriptPath))
|
||||||
{
|
{
|
||||||
//Refresh any dependencies we may have
|
//Refresh any dependencies we may have
|
||||||
for (U32 i = 0; i < mScriptAssets.size(); i++)
|
for (U32 i = 0; i < mScriptAssets.size(); i++)
|
||||||
|
|
@ -192,7 +192,7 @@ bool ScriptAsset::execScript()
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (Platform::isScriptFile(mScriptPath))
|
if (Torque::FS::IsScriptFile(mScriptPath))
|
||||||
{
|
{
|
||||||
return Con::executeFile(mScriptPath, false, false);
|
return Con::executeFile(mScriptPath, false, false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -337,7 +337,7 @@ void Prefab::_loadFile( bool addFileNotify )
|
||||||
if ( mFilename == StringTable->EmptyString())
|
if ( mFilename == StringTable->EmptyString())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( !Platform::isScriptFile( mFilename ) )
|
if ( !Torque::FS::IsScriptFile( mFilename ) )
|
||||||
{
|
{
|
||||||
Con::errorf( "Prefab::_loadFile() - file %s was not found.", mFilename );
|
Con::errorf( "Prefab::_loadFile() - file %s was not found.", mFilename );
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -1074,6 +1074,18 @@ bool IsFile(const Path &path)
|
||||||
return sgMountSystem.isFile(path);
|
return sgMountSystem.isFile(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsScriptFile(const char* pFilePath)
|
||||||
|
{
|
||||||
|
return (sgMountSystem.isFile(pFilePath)
|
||||||
|
|| sgMountSystem.isFile(pFilePath + String(".dso"))
|
||||||
|
|| sgMountSystem.isFile(pFilePath + String(".mis"))
|
||||||
|
|| sgMountSystem.isFile(pFilePath + String(".mis.dso"))
|
||||||
|
|| sgMountSystem.isFile(pFilePath + String(".gui"))
|
||||||
|
|| sgMountSystem.isFile(pFilePath + String(".gui.dso"))
|
||||||
|
|| sgMountSystem.isFile(pFilePath + String("." TORQUE_SCRIPT_EXTENSION))
|
||||||
|
|| sgMountSystem.isFile(pFilePath + String("." TORQUE_SCRIPT_EXTENSION) + String(".dso")));
|
||||||
|
}
|
||||||
|
|
||||||
bool IsDirectory(const Path &path)
|
bool IsDirectory(const Path &path)
|
||||||
{
|
{
|
||||||
return sgMountSystem.isDirectory(path);
|
return sgMountSystem.isDirectory(path);
|
||||||
|
|
|
||||||
|
|
@ -550,6 +550,7 @@ bool CreatePath(const Path &path);
|
||||||
bool IsReadOnly(const Path &path);
|
bool IsReadOnly(const Path &path);
|
||||||
bool IsDirectory(const Path &path);
|
bool IsDirectory(const Path &path);
|
||||||
bool IsFile(const Path &path);
|
bool IsFile(const Path &path);
|
||||||
|
bool IsScriptFile(const char* pFilePath);
|
||||||
bool VerifyWriteAccess(const Path &path);
|
bool VerifyWriteAccess(const Path &path);
|
||||||
|
|
||||||
/// This returns a unique file path from the components
|
/// This returns a unique file path from the components
|
||||||
|
|
|
||||||
|
|
@ -155,14 +155,4 @@ void Platform::setWebDeployment(bool v)
|
||||||
gWebDeployment = v;
|
gWebDeployment = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Platform::isScriptFile(const char* pFilePath)
|
|
||||||
{
|
|
||||||
return (isFile(pFilePath)
|
|
||||||
|| isFile(pFilePath + String(".dso"))
|
|
||||||
|| isFile(pFilePath + String(".mis"))
|
|
||||||
|| isFile(pFilePath + String(".mis.dso"))
|
|
||||||
|| isFile(pFilePath + String(".gui"))
|
|
||||||
|| isFile(pFilePath + String(".gui.dso"))
|
|
||||||
|| isFile(pFilePath + String("." TORQUE_SCRIPT_EXTENSION))
|
|
||||||
|| isFile(pFilePath + String("." TORQUE_SCRIPT_EXTENSION) + String(".dso")));
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -289,7 +289,6 @@ namespace Platform
|
||||||
bool hasSubDirectory( const char *pPath );
|
bool hasSubDirectory( const char *pPath );
|
||||||
bool getFileTimes(const char *filePath, FileTime *createTime, FileTime *modifyTime);
|
bool getFileTimes(const char *filePath, FileTime *createTime, FileTime *modifyTime);
|
||||||
bool isFile(const char *pFilePath);
|
bool isFile(const char *pFilePath);
|
||||||
bool isScriptFile(const char* pFilePath);
|
|
||||||
S32 getFileSize(const char *pFilePath);
|
S32 getFileSize(const char *pFilePath);
|
||||||
bool isDirectory(const char *pDirPath);
|
bool isDirectory(const char *pDirPath);
|
||||||
bool isSubDirectory(const char *pParent, const char *pDir);
|
bool isSubDirectory(const char *pParent, const char *pDir);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue