[Box Backup-commit] COMMIT r1661 - in box/chris/general/lib: backupclient win32

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Tue May 15 23:57:21 BST 2007


Author: chris
Date: 2007-05-15 23:57:20 +0100 (Tue, 15 May 2007)
New Revision: 1661

Modified:
   box/chris/general/lib/backupclient/BackupClientRestore.cpp
   box/chris/general/lib/win32/emu.cpp
Log:
Fix restoring to top-level directories (e.g. c:\test)


Modified: box/chris/general/lib/backupclient/BackupClientRestore.cpp
===================================================================
--- box/chris/general/lib/backupclient/BackupClientRestore.cpp	2007-05-15 21:06:51 UTC (rev 1660)
+++ box/chris/general/lib/backupclient/BackupClientRestore.cpp	2007-05-15 22:57:20 UTC (rev 1661)
@@ -311,6 +311,10 @@
 			{
 				parentDirectoryName += '\\';
 			}
+			else if (lastSlash == 0)
+			{
+				parentDirectoryName += '\\';
+			}
 		#endif
 
 		int parentExists;

Modified: box/chris/general/lib/win32/emu.cpp
===================================================================
--- box/chris/general/lib/win32/emu.cpp	2007-05-15 21:06:51 UTC (rev 1660)
+++ box/chris/general/lib/win32/emu.cpp	2007-05-15 22:57:20 UTC (rev 1661)
@@ -455,23 +455,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()] != '\\')
 		{




More information about the Boxbackup-commit mailing list