| 205 | //----------------------------------------------------------------------------- |
| 206 | |
| 207 | bool Taml::write(SimObject* pSimObject, const char* pFilename) |
| 208 | { |
| 209 | // Debug Profiling. |
| 210 | PROFILE_SCOPE(Taml_Write); |
| 211 | |
| 212 | // Sanity! |
| 213 | AssertFatal(pSimObject != NULL, "Cannot write a NULL object."); |
| 214 | AssertFatal(pFilename != NULL, "Cannot write to a NULL filename."); |
| 215 | |
| 216 | // Expand the file-name into the file-path buffer unless we're a secure VFS |
| 217 | #ifndef TORQUE_SECURE_VFS |
| 218 | Con::expandToolScriptFilename(mFilePathBuffer, sizeof(mFilePathBuffer), pFilename); |
| 219 | #else |
| 220 | dMemset(mFilePathBuffer, 0x00, sizeof(mFilePathBuffer)); |
| 221 | dMemcpy(mFilePathBuffer, pFilename, dStrlen(pFilename)); |
| 222 | #endif |
| 223 | |
| 224 | FileStream stream; |
| 225 | |
| 226 | // File opened? |
| 227 | if (!stream.open(mFilePathBuffer, Torque::FS::File::Write)) |
| 228 | { |
| 229 | // No, so warn. |
| 230 | Con::warnf("Taml::writeFile() - Could not open filename '%s' for write.", mFilePathBuffer); |
| 231 | return false; |
| 232 | } |
| 233 | |
| 234 | // Get the file auto-format mode. |
| 235 | const TamlFormatMode formatMode = getFileAutoFormatMode(mFilePathBuffer); |
| 236 | |
| 237 | // Reset the compilation. |
| 238 | resetCompilation(); |
| 239 | |
| 240 | // Write object. |
| 241 | const bool status = write(stream, pSimObject, formatMode); |
| 242 | |
| 243 | // Close file. |
| 244 | stream.close(); |
| 245 | |
| 246 | // Reset the compilation. |
| 247 | resetCompilation(); |
| 248 | |
| 249 | return status; |
| 250 | } |
| 251 | |
| 252 | //----------------------------------------------------------------------------- |
| 253 |
no test coverage detected