Commit 5a265656 authored by cutealien's avatar cutealien

Fix compiling with _IRR_WCHAR_FILESYSTEM on MinGW. Thx @ alexzk for...

Fix compiling with _IRR_WCHAR_FILESYSTEM on MinGW. Thx @  alexzk for reporting. Note that I tested this with gcc 4.7.0 and only compiling is tested.
Also added some documentation that UNICODE must be set as well for compiling with _IRR_WCHAR_FILESYSTEM ('cause I always forget to set that at first otherwise...).

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4322 dfc29bdd-3216-0410-991c-e03cc46cb475
parent cbe3f1ac
Changes in 1.8 (??.10.2012) Changes in 1.8 (??.10.2012)
- Gcc on Win32 (MinGW) now also works with the _w file access functions when compiled with _IRR_WCHAR_FILESYSTEM. (thx @ alexzk for reporting compile troubles)
- Fix a bunch of off-by one errors in irr::core::string in functions equals_substring_ignore_case, findFirst, findFirstChar, findNext, findLast, findLastChar, replace, remove and removeChars. - Fix a bunch of off-by one errors in irr::core::string in functions equals_substring_ignore_case, findFirst, findFirstChar, findNext, findLast, findLastChar, replace, remove and removeChars.
This prevents some potential memory access errors, find functions no longer try to find the \0, replace no longer replaces the \0 and remove no longer tries to remove it (which did remove the last character instead). This prevents some potential memory access errors, find functions no longer try to find the \0, replace no longer replaces the \0 and remove no longer tries to remove it (which did remove the last character instead).
......
...@@ -227,7 +227,8 @@ you will not be able to use anything provided by the GUI Environment, including ...@@ -227,7 +227,8 @@ you will not be able to use anything provided by the GUI Environment, including
//! Define _IRR_WCHAR_FILESYSTEM to enable unicode filesystem support for the engine. //! Define _IRR_WCHAR_FILESYSTEM to enable unicode filesystem support for the engine.
/** This enables the engine to read/write from unicode filesystem. If you /** This enables the engine to read/write from unicode filesystem. If you
disable this feature, the engine behave as before (ansi). This is currently only supported disable this feature, the engine behave as before (ansi). This is currently only supported
for Windows based systems. */ for Windows based systems. You also have to set #define UNICODE for this to compile.
*/
//#define _IRR_WCHAR_FILESYSTEM //#define _IRR_WCHAR_FILESYSTEM
#ifdef NO_IRR_WCHAR_FILESYSTEM #ifdef NO_IRR_WCHAR_FILESYSTEM
#undef _IRR_WCHAR_FILESYSTEM #undef _IRR_WCHAR_FILESYSTEM
......
...@@ -458,7 +458,7 @@ bool CFileSystem::removeFileArchive(u32 index) ...@@ -458,7 +458,7 @@ bool CFileSystem::removeFileArchive(u32 index)
//! removes an archive from the file system. //! removes an archive from the file system.
bool CFileSystem::removeFileArchive(const io::path& filename) bool CFileSystem::removeFileArchive(const io::path& filename)
{ {
const path absPath = getAbsolutePath(filename); const path absPath = getAbsolutePath(filename);
for (u32 i=0; i < FileArchives.size(); ++i) for (u32 i=0; i < FileArchives.size(); ++i)
{ {
if (absPath == FileArchives[i]->getFileList()->getPath()) if (absPath == FileArchives[i]->getFileList()->getPath())
...@@ -593,7 +593,11 @@ bool CFileSystem::changeWorkingDirectoryTo(const io::path& newDirectory) ...@@ -593,7 +593,11 @@ bool CFileSystem::changeWorkingDirectoryTo(const io::path& newDirectory)
success = (_chdir(newDirectory.c_str()) == 0); success = (_chdir(newDirectory.c_str()) == 0);
#endif #endif
#else #else
success = (chdir(newDirectory.c_str()) == 0); #if defined(_IRR_WCHAR_FILESYSTEM)
success = (_wchdir(newDirectory.c_str()) == 0);
#else
success = (chdir(newDirectory.c_str()) == 0);
#endif
#endif #endif
} }
...@@ -777,7 +781,7 @@ path CFileSystem::getRelativeFilename(const path& filename, const path& director ...@@ -777,7 +781,7 @@ path CFileSystem::getRelativeFilename(const path& filename, const path& director
#endif #endif
for (; i<list1.size() && i<list2.size() for (; i<list1.size() && i<list2.size()
#if defined (_IRR_WINDOWS_API_) #if defined (_IRR_WINDOWS_API_)
&& (io::path(*it1).make_lower()==io::path(*it2).make_lower()) && (io::path(*it1).make_lower()==io::path(*it2).make_lower())
#else #else
...@@ -969,13 +973,17 @@ bool CFileSystem::existFile(const io::path& filename) const ...@@ -969,13 +973,17 @@ bool CFileSystem::existFile(const io::path& filename) const
#else #else
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
#if defined(_MSC_VER) #if defined(_MSC_VER)
#if defined(_IRR_WCHAR_FILESYSTEM) #if defined(_IRR_WCHAR_FILESYSTEM)
return (_waccess(filename.c_str(), 0) != -1); return (_waccess(filename.c_str(), 0) != -1);
#else #else
return (_access(filename.c_str(), 0) != -1); return (_access(filename.c_str(), 0) != -1);
#endif #endif
#elif defined(F_OK) #elif defined(F_OK)
return (access(filename.c_str(), F_OK) != -1); #if defined(_IRR_WCHAR_FILESYSTEM)
return (_waccess(filename.c_str(), F_OK) != -1);
#else
return (access(filename.c_str(), F_OK) != -1);
#endif
#else #else
return (access(filename.c_str(), 0) != -1); return (access(filename.c_str(), 0) != -1);
#endif #endif
......
...@@ -1598,12 +1598,12 @@ void CIrrDeviceWin32::getWindowsVersion(core::stringc& out) ...@@ -1598,12 +1598,12 @@ void CIrrDeviceWin32::getWindowsVersion(core::stringc& out)
sprintf(tmp, "version %ld.%ld %s (Build %ld)", sprintf(tmp, "version %ld.%ld %s (Build %ld)",
osvi.dwMajorVersion, osvi.dwMajorVersion,
osvi.dwMinorVersion, osvi.dwMinorVersion,
osvi.szCSDVersion, irr::core::stringc(osvi.szCSDVersion).c_str(),
osvi.dwBuildNumber & 0xFFFF); osvi.dwBuildNumber & 0xFFFF);
} }
else else
{ {
sprintf(tmp, "%s (Build %ld)", osvi.szCSDVersion, sprintf(tmp, "%s (Build %ld)", irr::core::stringc(osvi.szCSDVersion).c_str(),
osvi.dwBuildNumber & 0xFFFF); osvi.dwBuildNumber & 0xFFFF);
} }
......
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