[Box Backup-commit] COMMIT r1646 - box/chris/merge/lib/win32

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Wed May 9 11:49:50 BST 2007


Author: chris
Date: 2007-05-09 11:49:50 +0100 (Wed, 09 May 2007)
New Revision: 1646

Modified:
   box/chris/merge/lib/win32/emu.cpp
Log:
Fix emulated chdir to work with relative paths and with bbackupquery's
"sh" command (which doesn't like UNC paths).

Fix error messages by removing surplus newline kindly added by Windows.

(refs #3, merges [1514] and [1569])


Modified: box/chris/merge/lib/win32/emu.cpp
===================================================================
--- box/chris/merge/lib/win32/emu.cpp	2007-05-09 10:37:57 UTC (rev 1645)
+++ box/chris/merge/lib/win32/emu.cpp	2007-05-09 10:49:50 UTC (rev 1646)
@@ -503,6 +503,10 @@
 		return std::string("failed to get error message");
 	}
 
+	// remove embedded newline
+	pMsgBuf[chars - 1] = 0;
+	pMsgBuf[chars - 2] = 0;
+
 	std::ostringstream line;
 	line << pMsgBuf << " (" << errorCode << ")";
 	LocalFree(pMsgBuf);
@@ -1474,6 +1478,7 @@
 
 int emu_chdir(const char* pDirName)
 {
+	/*
 	std::string AbsPathWithUnicode = 
 		ConvertPathToAbsoluteUnicode(pDirName);
 
@@ -1484,11 +1489,19 @@
 	}
 
 	WCHAR* pBuffer = ConvertUtf8ToWideString(AbsPathWithUnicode.c_str());
+	*/
+
+	WCHAR* pBuffer = ConvertUtf8ToWideString(pDirName);
 	if (!pBuffer) return -1;
+
 	int result = SetCurrentDirectoryW(pBuffer);
 	delete [] pBuffer;
+
 	if (result != 0) return 0;
+
 	errno = EACCES;
+	fprintf(stderr, "Failed to change directory to '%s': %s\n",
+		pDirName, GetErrorMessage(GetLastError()).c_str());
 	return -1;
 }
 




More information about the Boxbackup-commit mailing list