summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2007-07-26 21:58:40 +0000
committerChris Wilson <chris+github@qwirx.com>2007-07-26 21:58:40 +0000
commita436702cdf84264e1176548a4dd0f78f8eeb123a (patch)
tree4a3b507d924f3317baf512af7b4203fb038dce18
parent18b71f8cbbdf85907a9e204b9e9f2d056ac43419 (diff)
Fix restoring to top-level directories (e.g. c:\test) (refs #3,
merges [1661])
-rw-r--r--lib/backupclient/BackupClientRestore.cpp4
-rw-r--r--lib/win32/emu.cpp31
2 files changed, 22 insertions, 13 deletions
diff --git a/lib/backupclient/BackupClientRestore.cpp b/lib/backupclient/BackupClientRestore.cpp
index 028c1659..9b3a3edc 100644
--- a/lib/backupclient/BackupClientRestore.cpp
+++ b/lib/backupclient/BackupClientRestore.cpp
@@ -311,6 +311,10 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir
{
parentDirectoryName += '\\';
}
+ else if (lastSlash == 0)
+ {
+ parentDirectoryName += '\\';
+ }
#endif
int parentExists;
diff --git a/lib/win32/emu.cpp b/lib/win32/emu.cpp
index d69d8197..4224d62e 100644
--- a/lib/win32/emu.cpp
+++ b/lib/win32/emu.cpp
@@ -460,23 +460,28 @@ std::string ConvertPathToAbsoluteUnicode(const char *pFileName)
// 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()] != '\\')
{