The following is the source code related to file operations in ogre.
Code Datastreamptr filesystemarchive: open ( Const String & Filename) Const
{
String full_path = Concatenate_path (mname, filename );
// Use filesystem to determine size
// (Quicker than streaming to the end and back)
Struct Stat tagstat;
Int RET = Stat (full_path.c_str (), & Tagstat );
Assert (Ret = 0 && " Problem getting File Size " );
//Always open in binary mode
STD: ifstream*Origstream=Ogre_new_t (STD: ifstream, memcategory_general )();
Origstream->Open (full_path.c_str (), STD: IOS ::In |STD: IOS: Binary );
// Shocould check ensure open succeeded, in case fail for some reason.
If (Origstream -> Fail ())
{
Ogre_delete_t (origstream, basic_ifstream, memcategory_general );
Ogre_effect (exception: err_file_not_found,
" Cannot open file: " + Filename,
" Filesystemarchive: Open " );
}
/// construct return stream, tell it to delete on destroy
filestreamdatastream * stream = ogre_new filestreamdatastream (filename,
origstream, tagstat. st_size, true );
return datastreamptr (Stream);
}< br>
MainCodeYes
Origstream -> Open (full_path.c_str (), STD: IOS :: In | STD: IOS: Binary );
Before opening a file in a file stream, set the language environment.
STD: locale :: Global (STD: locale ( "" ));
Next we found that the problem of Chinese path was solved,There is a problem when writing integer or floating point data to a file, such as "1000". After the output, it becomes "1,000"
This is because we changed the language environment. To minimize the modification, we should restore the previous settings after opening the file.
STD: locale savelocal = STD: locale :: Global (STD: locale ( "" ));
Origstream -> Open (full_path.c_str (), STD: IOS :: In | STD: IOS: Binary );
STD: locale :: Global (Savelocal );
Everything is fine now ~