Explorar o código

Taml Write Creates Path

This change causes Taml::WriteFile to create the path before attempting
to write the file.
Peter Robinson %!s(int64=8) %!d(string=hai) anos
pai
achega
a1e111d891
Modificáronse 1 ficheiros con 6 adicións e 0 borrados
  1. 6 0
      engine/source/persistence/taml/taml.cc

+ 6 - 0
engine/source/persistence/taml/taml.cc

@@ -226,6 +226,12 @@ bool Taml::write( SimObject* pSimObject, const char* pFilename )
     AssertFatal( pSimObject != NULL, "Cannot write a NULL object." );
     AssertFatal( pFilename != NULL, "Cannot write to a NULL filename." );
 
+    if (!Platform::createPath(pFilename))
+    {
+       Con::warnf("Taml::writeFile() - Unable to create path for file '%s'", pFilename);
+       return false;
+    }
+
     // Expand the file-name into the file-path buffer.
     Con::expandPath( mFilePathBuffer, sizeof(mFilePathBuffer), pFilename );