[Box Backup-commit] COMMIT r2549 - box/trunk/lib/win32
boxbackup-dev at boxbackup.org
boxbackup-dev at boxbackup.org
Sun Aug 2 19:58:53 BST 2009
Author: chris
Date: 2009-08-02 19:58:51 +0100 (Sun, 02 Aug 2009)
New Revision: 2549
Modified:
box/trunk/lib/win32/emu.cpp
Log:
Add handling of relative paths to emu.cpp's openfile(), needed to handle
relative paths in test configuration on Windows.
Modified: box/trunk/lib/win32/emu.cpp
===================================================================
--- box/trunk/lib/win32/emu.cpp 2009-08-01 10:49:15 UTC (rev 2548)
+++ box/trunk/lib/win32/emu.cpp 2009-08-02 18:58:51 UTC (rev 2549)
@@ -417,6 +417,32 @@
}
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;
}
More information about the Boxbackup-commit
mailing list