---------------------------------------------------------------------
| 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 | { |
nothing calls this directly
no test coverage detected