MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / read

Method read

Engine/source/persistence/taml/taml.cpp:254–302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

252 //-----------------------------------------------------------------------------
253
254 SimObject* Taml::read(const char* pFilename)
255 {
256 // Debug Profiling.
257 PROFILE_SCOPE(Taml_Read);
258
259 // Sanity!
260 AssertFatal(pFilename != NULL, "Cannot read from a NULL filename.");
261
262 // Expand the file-name into the file-path buffer.
263 Con::expandScriptFilename(mFilePathBuffer, sizeof(mFilePathBuffer), pFilename);
264
265 FileStream stream;
266
267 // File opened?
268 if (!stream.open(mFilePathBuffer, Torque::FS::File::Read))
269 {
270 // No, so warn.
271 Con::warnf("Taml::read() - Could not open filename '%s' for read.", mFilePathBuffer);
272 return NULL;
273 }
274
275 // Get the file auto-format mode.
276 const TamlFormatMode formatMode = getFileAutoFormatMode(mFilePathBuffer);
277
278 // Reset the compilation.
279 resetCompilation();
280
281 // Write object.
282 SimObject* pSimObject = read(stream, formatMode);
283
284 // Close file.
285 stream.close();
286
287 // Reset the compilation.
288 resetCompilation();
289
290 // Did we generate an object?
291 if (pSimObject == NULL)
292 {
293 // No, so warn.
294 Con::warnf("Taml::read() - Failed to load an object from the file '%s'.", mFilePathBuffer);
295 }
296 else
297 {
298 pSimObject->onPostAdd();
299 }
300
301 return pSimObject;
302 }
303
304 //-----------------------------------------------------------------------------
305

Callers 3

LoadFileMethod · 0.45
ReadFunction · 0.45

Calls 6

expandScriptFilenameFunction · 0.85
openMethod · 0.65
closeMethod · 0.65
warnfFunction · 0.50
readFunction · 0.50
onPostAddMethod · 0.45

Tested by

no test coverage detected