diff options
author | Reinhard Tartler <siretart@tauware.de> | 2010-11-09 17:28:58 +0100 |
---|---|---|
committer | Reinhard Tartler <siretart@tauware.de> | 2010-11-09 17:28:58 +0100 |
commit | 8a937bd354001a190dbe66538aacb353e7c99341 (patch) | |
tree | 9db021722d1743482e76f93d00fb97bed32a3ea7 /lib/win32 | |
parent | b591c86a418e8d5a0d1c1afd319d9acdad6fd4e3 (diff) |
Import upstream version 0.11~rc8~r2714
Diffstat (limited to 'lib/win32')
-rw-r--r-- | lib/win32/emu.cpp | 26 | ||||
-rw-r--r-- | lib/win32/emu.h | 11 |
2 files changed, 36 insertions, 1 deletions
diff --git a/lib/win32/emu.cpp b/lib/win32/emu.cpp index ad8c3041..3a56661a 100644 --- a/lib/win32/emu.cpp +++ b/lib/win32/emu.cpp @@ -417,6 +417,32 @@ std::string ConvertPathToAbsoluteUnicode(const char *pFileName) } tmpStr += filename; + + // We are using direct filename access, which does not support .., + // so we need to implement it ourselves. + + for (std::string::size_type i = 1; i < tmpStr.size() - 3; i++) + { + if (tmpStr.substr(i, 3) == "\\..") + { + std::string::size_type lastSlash = + tmpStr.rfind('\\', i - 1); + + if (lastSlash == std::string::npos) + { + // no previous directory, ignore it, + // CreateFile will fail with error 123 + } + else + { + tmpStr.replace(lastSlash, i + 3 - lastSlash, + ""); + } + + i = lastSlash; + } + } + return tmpStr; } diff --git a/lib/win32/emu.h b/lib/win32/emu.h index 811e6495..f3389590 100644 --- a/lib/win32/emu.h +++ b/lib/win32/emu.h @@ -117,7 +117,7 @@ inline struct passwd * getpwnam(const char * name) #ifndef __MINGW32__ //not sure if these are correct //S_IWRITE - writing permitted - //_S_IREAD - reading permitted + //_S_IREAD - reading permitted //_S_IREAD | _S_IWRITE - #define S_IRUSR S_IWRITE #define S_IWUSR S_IREAD @@ -242,6 +242,15 @@ int closedir(DIR *dp); extern DWORD winerrno; /* used to report errors from openfile() */ HANDLE openfile(const char *filename, int flags, int mode); +inline int closefile(HANDLE handle) +{ + if (CloseHandle(handle) != TRUE) + { + errno = EINVAL; + return -1; + } + return 0; +} #define LOG_DEBUG LOG_INFO #define LOG_INFO 6 |