Commit f4ea5ae4 authored by mercury233's avatar mercury233

fix irrlicht file name on linux

parent 82c21b26
......@@ -11,7 +11,13 @@ IFileSystem* DataManager::FileSystem;
DataManager dataManager;
bool DataManager::LoadDB(const wchar_t* wfile) {
char file[256];
BufferIO::EncodeUTF8(wfile, file);
#ifdef _WIN32
IReadFile* reader = FileSystem->createAndOpenFile(wfile);
#else
IReadFile* reader = FileSystem->createAndOpenFile(file);
#endif
if(reader == NULL)
return false;
spmemvfs_db_t db;
......@@ -22,8 +28,6 @@ bool DataManager::LoadDB(const wchar_t* wfile) {
reader->read(mem->data, mem->total);
reader->drop();
(mem->data)[mem->total] = '\0';
char file[256];
BufferIO::EncodeUTF8(wfile, file);
if(spmemvfs_open_db(&db, file, mem) != SQLITE_OK)
return Error(&db);
sqlite3* pDB = db.handle;
......@@ -362,9 +366,13 @@ byte* DataManager::ScriptReaderEx(const char* script_name, int* slen) {
return ScriptReader(second, slen);
}
byte* DataManager::ScriptReader(const char* script_name, int* slen) {
#ifdef _WIN32
wchar_t fname[256];
BufferIO::DecodeUTF8(script_name, fname);
IReadFile* reader = FileSystem->createAndOpenFile(fname);
#else
IReadFile* reader = FileSystem->createAndOpenFile(script_name);
#endif
if(reader == NULL)
return 0;
size_t size = reader->getSize();
......
......@@ -917,7 +917,13 @@ void Game::LoadExpansions() {
if(!isdir && wcsrchr(name, '.') && !mywcsncasecmp(wcsrchr(name, '.'), L".zip", 4)) {
wchar_t fpath[1024];
myswprintf(fpath, L"./expansions/%ls", name);
#ifdef _WIN32
dataManager.FileSystem->addFileArchive(fpath, true, false);
#else
char upath[1024];
BufferIO::EncodeUTF8(fpath, upath);
dataManager.FileSystem->addFileArchive(upath, true, false);
#endif
}
});
for(u32 i = 0; i < DataManager::FileSystem->getFileArchiveCount(); ++i) {
......@@ -933,7 +939,11 @@ void Game::LoadExpansions() {
if(wcsrchr(fname, '.') && !mywcsncasecmp(wcsrchr(fname, '.'), L".cdb", 4))
dataManager.LoadDB(fname);
if(wcsrchr(fname, '.') && !mywcsncasecmp(wcsrchr(fname, '.'), L".conf", 5)) {
#ifdef _WIN32
IReadFile* reader = DataManager::FileSystem->createAndOpenFile(fname);
#else
IReadFile* reader = DataManager::FileSystem->createAndOpenFile(uname);
#endif
dataManager.LoadStrings(reader);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment