MCPcopy Create free account
hub / github.com/OGRECave/ogre-next / create

Method create

OgreMain/src/OgreFileSystem.cpp:376–408  ·  view source on GitHub ↗

---------------------------------------------------------------------

Source from the content-addressed store, hash-verified

374 }
375 //---------------------------------------------------------------------
376 DataStreamPtr FileSystemArchive::create( const String &filename )
377 {
378 if( isReadOnly() )
379 {
380 OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, "Cannot create a file in a read-only archive",
381 "FileSystemArchive::remove" );
382 }
383
384 String full_path = concatenate_path( mName, filename );
385
386 // Always open in binary mode
387 // Also, always include reading
388 std::ios::openmode mode = std::ios::out | std::ios::binary;
389 std::fstream *rwStream = OGRE_NEW_T( std::fstream, MEMCATEGORY_GENERAL )();
390#ifdef _OGRE_FILESYSTEM_ARCHIVE_UNICODE
391 rwStream->open( to_wpath( full_path ).c_str(), mode );
392#else
393 rwStream->open( full_path.c_str(), mode );
394#endif
395
396 // Should check ensure open succeeded, in case fail for some reason.
397 if( rwStream->fail() )
398 {
399 OGRE_DELETE_T( rwStream, basic_fstream, MEMCATEGORY_GENERAL );
400 OGRE_EXCEPT( Exception::ERR_FILE_NOT_FOUND, "Cannot open file: " + filename,
401 "FileSystemArchive::create" );
402 }
403
404 /// Construct return stream, tell it to delete on destroy
405 FileStreamDataStream *stream = OGRE_NEW FileStreamDataStream( filename, rwStream, 0, true );
406
407 return DataStreamPtr( stream );
408 }
409 //---------------------------------------------------------------------
410 void FileSystemArchive::remove( const String &filename )
411 {

Callers

nothing calls this directly

Calls 5

isReadOnlyFunction · 0.85
concatenate_pathFunction · 0.85
to_wpathFunction · 0.85
openMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected