[Box Backup-commit] COMMIT r1756 - in box/chris/merge/lib: backupclient win32
boxbackup-dev@fluffy.co.uk
boxbackup-dev@fluffy.co.uk
Thu, 26 Jul 2007 22:58:40 +0100
Author: chris
Date: 2007-07-26 22:58:40 +0100 (Thu, 26 Jul 2007)
New Revision: 1756
Modified:
box/chris/merge/lib/backupclient/BackupClientRestore.cpp
box/chris/merge/lib/win32/emu.cpp
Log:
Fix restoring to top-level directories (e.g. c:\test) (refs #3,
merges [1661])
Modified: box/chris/merge/lib/backupclient/BackupClientRestore.cpp
===================================================================
--- box/chris/merge/lib/backupclient/BackupClientRestore.cpp 2007-07-26 21:56:06 UTC (rev 1755)
+++ box/chris/merge/lib/backupclient/BackupClientRestore.cpp 2007-07-26 21:58:40 UTC (rev 1756)
@@ -311,6 +311,10 @@
{
parentDirectoryName += '\\';
}
+ else if (lastSlash == 0)
+ {
+ parentDirectoryName += '\\';
+ }
#endif
int parentExists;
Modified: box/chris/merge/lib/win32/emu.cpp
===================================================================
--- box/chris/merge/lib/win32/emu.cpp 2007-07-26 21:56:06 UTC (rev 1755)
+++ box/chris/merge/lib/win32/emu.cpp 2007-07-26 21:58:40 UTC (rev 1756)
@@ -460,23 +460,28 @@
// Is the path relative or absolute?
// Absolute paths on Windows are always a drive letter
// followed by ':'
+
+ char wd[PATH_MAX];
+ if (::getcwd(wd, PATH_MAX) == 0)
+ {
+ ::syslog(LOG_WARNING,
+ "Failed to open '%s': path too long",
+ pFileName);
+ errno = ENAMETOOLONG;
+ tmpStr = "";
+ return tmpStr;
+ }
- if (filename.length() >= 2 && filename[1] != ':')
+ if (filename.length() >= 1 && filename[0] == '\\')
{
+ // root directory of current drive.
+ tmpStr = wd;
+ tmpStr.resize(2); // drive letter and colon
+ }
+ else if (filename.length() >= 2 && filename[1] != ':')
+ {
// Must be relative. We need to get the
// current directory to make it absolute.
-
- char wd[PATH_MAX];
- if (::getcwd(wd, PATH_MAX) == 0)
- {
- ::syslog(LOG_WARNING,
- "Failed to open '%s': path too long",
- pFileName);
- errno = ENAMETOOLONG;
- tmpStr = "";
- return tmpStr;
- }
-
tmpStr += wd;
if (tmpStr[tmpStr.length()] != '\\')
{