summaryrefslogtreecommitdiff
path: root/lib/win32
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2007-05-09 10:49:50 +0000
committerChris Wilson <chris+github@qwirx.com>2007-05-09 10:49:50 +0000
commit8da5d31e2f3a22a52b6228a289efe9c7b1d9f6c7 (patch)
tree61f41660af8eb64ec030c994b8ee0799505a2fb5 /lib/win32
parent76396f594e6e3050bbde6a324e8f79be9cf4d4a3 (diff)
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])
Diffstat (limited to 'lib/win32')
-rw-r--r--lib/win32/emu.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/win32/emu.cpp b/lib/win32/emu.cpp
index 7f665629..0077166f 100644
--- a/lib/win32/emu.cpp
+++ b/lib/win32/emu.cpp
@@ -503,6 +503,10 @@ std::string GetErrorMessage(DWORD errorCode)
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 @@ void syslog(int loglevel, const char *frmt, ...)
int emu_chdir(const char* pDirName)
{
+ /*
std::string AbsPathWithUnicode =
ConvertPathToAbsoluteUnicode(pDirName);
@@ -1484,11 +1489,19 @@ int emu_chdir(const char* pDirName)
}
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;
}