summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2009-08-02 18:58:51 +0000
committerChris Wilson <chris+github@qwirx.com>2009-08-02 18:58:51 +0000
commit4f73df1c4f401a56dfcb1ad6bcc01e830b3b3d5d (patch)
treee236f655d20d4f13c1899e7fedd2b457c3c3d31b
parentfc6e0b8830c0dc0651b8a6533adb293c1417feff (diff)
Add handling of relative paths to emu.cpp's openfile(), needed to handle
relative paths in test configuration on Windows.
-rw-r--r--lib/win32/emu.cpp26
1 files changed, 26 insertions, 0 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;
}