[Box Backup-dev] COMMIT r607 - box/chris/general/lib/win32
boxbackup-dev@fluffy.co.uk
boxbackup-dev@fluffy.co.uk
Tue, 30 May 2006 20:01:12 +0000 (GMT)
Author: chris
Date: 2006-05-30 20:01:08 +0000 (Tue, 30 May 2006)
New Revision: 607
Modified:
box/chris/general/lib/win32/emu.cpp
Log:
* emu.cpp
- Improved error return values from emu_unlink()
- Fixed reading from console in debug-compiled code
Modified: box/chris/general/lib/win32/emu.cpp
===================================================================
--- box/chris/general/lib/win32/emu.cpp 2006-05-30 19:26:11 UTC (rev 606)
+++ box/chris/general/lib/win32/emu.cpp 2006-05-30 20:01:08 UTC (rev 607)
@@ -485,7 +485,8 @@
//
// Function
// Name: openfile
-// Purpose: replacement for any open calls - handles unicode filenames - supplied in utf8
+// Purpose: replacement for any open calls - handles unicode
+// filenames - supplied in utf8
// Created: 25th October 2004
//
// --------------------------------------------------------------------------
@@ -1387,11 +1388,29 @@
}
BOOL result = DeleteFileW(pBuffer);
+ DWORD err = GetLastError();
delete [] pBuffer;
if (!result)
{
- errno = EACCES;
+ if (err == ERROR_FILE_NOT_FOUND || err == ERROR_PATH_NOT_FOUND)
+ {
+ errno = ENOENT;
+ }
+ else if (err == ERROR_SHARING_VIOLATION)
+ {
+ errno = EBUSY;
+ }
+ else if (err == ERROR_ACCESS_DENIED)
+ {
+ errno = EACCES;
+ }
+ else
+ {
+ ::syslog(LOG_WARNING, "Failed to delete file "
+ "'%s': error %d", pFileName, (int)err);
+ errno = ENOSYS;
+ }
return -1;
}
@@ -1423,7 +1442,7 @@
if (!ReadConsoleW(
hConsole,
pWideBuffer,
- WideSize - 1,
+ WideSize, // will not be null terminated by ReadConsole
&numCharsRead,
NULL // reserved
))