mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 17:29:10 +00:00
Replace ifstream and ofstream to manage UTF-8 filenames, issue #261
This commit is contained in:
parent
ee1d69503b
commit
eee72ce77f
3 changed files with 27 additions and 17 deletions
|
@ -82,9 +82,10 @@ TReportResult report(const std::string &title, const std::string &subject, const
|
|||
{
|
||||
std::string reportFile = getLogDirectory() + NLMISC::toString("nel_report_%u.log", (uint)time(NULL));
|
||||
reportPath = CFile::findNewFile(reportFile);
|
||||
std::ofstream f;
|
||||
f.open(reportPath.c_str());
|
||||
if (!f.good())
|
||||
|
||||
FILE *f = nlfopen(reportPath, "wb"); // write as binary so \n are preserved
|
||||
|
||||
if (!f)
|
||||
{
|
||||
#if NL_DEBUG_REPORT
|
||||
if (INelContext::isContextInitialised())
|
||||
|
@ -94,8 +95,14 @@ TReportResult report(const std::string &title, const std::string &subject, const
|
|||
}
|
||||
else
|
||||
{
|
||||
f << body;
|
||||
f.close();
|
||||
size_t written = fwrite(body.c_str(), 1, body.length(), f);
|
||||
|
||||
if (written != body.length())
|
||||
{
|
||||
nlwarning("Unable to write %u bytes to %s, only %u written", (uint)body.length(), reportPath.c_str(), (uint)written);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -104,29 +104,31 @@ void CCDBSynchronised::read( const string &fileName )
|
|||
int linecount=1;
|
||||
#endif
|
||||
|
||||
if( _Database == 0 )
|
||||
if (_Database == NULL)
|
||||
{
|
||||
throw CCDBSynchronised::EDBNotInit();
|
||||
}
|
||||
|
||||
ifstream f(fileName.c_str(), ios::in);
|
||||
if( !f.is_open() )
|
||||
CIFile f;
|
||||
|
||||
if (!f.open(fileName, true))
|
||||
{
|
||||
nlerror("can't open file : %s\n", fileName.c_str());
|
||||
}
|
||||
|
||||
while( !f.eof() )
|
||||
while(!f.eof())
|
||||
{
|
||||
string line;
|
||||
getline(f,line,'\n');
|
||||
char line[1024];
|
||||
f.getline(line, 1024);
|
||||
|
||||
#ifdef _DEBUG
|
||||
nlinfo("%s:%i",fileName.c_str(),linecount);
|
||||
linecount++;
|
||||
nlinfo("%s:%i", fileName.c_str(), linecount);
|
||||
linecount++;
|
||||
#endif
|
||||
|
||||
char * token;
|
||||
char * buffer = new char[line.size()+1];
|
||||
strcpy(buffer,line.c_str());
|
||||
char * buffer = new char[strlen(line)+1];
|
||||
strcpy(buffer, line);
|
||||
|
||||
// value
|
||||
token = strtok(buffer," \t");
|
||||
|
|
|
@ -1028,10 +1028,11 @@ void CSoundManager::loadProperties(const string &soundName, USource *source)
|
|||
|
||||
// Search for the file.
|
||||
string filePath = CPath::lookup(soundName+".sdf");
|
||||
ifstream file(filePath.c_str(), ios::in);
|
||||
|
||||
CIFile file;
|
||||
|
||||
// Try to open the file.
|
||||
if(file.is_open())
|
||||
if (file.open(filePath))
|
||||
{
|
||||
char tmpBuff[260];
|
||||
char delimiterBox[] = "\t ";
|
||||
|
|
Loading…
Reference in a new issue