---------------------------------------------------------------------
| 1281 | } |
| 1282 | //--------------------------------------------------------------------- |
| 1283 | DataStreamPtr Root::createFileStream( const String &filename, const String &groupName, |
| 1284 | bool overwrite, const String &locationPattern ) |
| 1285 | { |
| 1286 | // Does this file include path specifiers? |
| 1287 | String path, basename; |
| 1288 | StringUtil::splitFilename( filename, basename, path ); |
| 1289 | |
| 1290 | // no path elements, try the resource system first |
| 1291 | DataStreamPtr stream; |
| 1292 | if( path.empty() ) |
| 1293 | { |
| 1294 | try |
| 1295 | { |
| 1296 | stream = ResourceGroupManager::getSingleton().createResource( |
| 1297 | filename, groupName, overwrite, locationPattern ); |
| 1298 | } |
| 1299 | catch( ... ) |
| 1300 | { |
| 1301 | } |
| 1302 | } |
| 1303 | |
| 1304 | if( !stream ) |
| 1305 | { |
| 1306 | // save direct in filesystem |
| 1307 | std::fstream *fs = OGRE_NEW_T( std::fstream, MEMCATEGORY_GENERAL ); |
| 1308 | fs->open( filename.c_str(), std::ios::out | std::ios::binary ); |
| 1309 | if( !*fs ) |
| 1310 | { |
| 1311 | OGRE_DELETE_T( fs, basic_fstream, MEMCATEGORY_GENERAL ); |
| 1312 | OGRE_EXCEPT( Exception::ERR_CANNOT_WRITE_TO_FILE, |
| 1313 | "Can't open " + filename + " for writing", __FUNCTION__ ); |
| 1314 | } |
| 1315 | |
| 1316 | stream = DataStreamPtr( OGRE_NEW FileStreamDataStream( filename, fs ) ); |
| 1317 | } |
| 1318 | |
| 1319 | return stream; |
| 1320 | } |
| 1321 | //--------------------------------------------------------------------- |
| 1322 | DataStreamPtr Root::openFileStream( const String &filename, const String &groupName, |
| 1323 | const String &locationPattern ) |
no test coverage detected