[Box Backup-commit] COMMIT r1090 - box/chris/merge/lib/common
boxbackup-dev@fluffy.co.uk
boxbackup-dev@fluffy.co.uk
Tue, 17 Oct 2006 00:24:18 +0100
Author: chris
Date: 2006-10-17 00:24:18 +0100 (Tue, 17 Oct 2006)
New Revision: 1090
Modified:
box/chris/merge/lib/common/FileStream.cpp
Log:
Set the filename to "HANDLE" under Win32 when initialising from an
existing handle.
Handle ERROR_BROKEN_PIPE as EOF when using FileStream to read from a
pipe in LocalProcessStream. (refs #3)
Modified: box/chris/merge/lib/common/FileStream.cpp
===================================================================
--- box/chris/merge/lib/common/FileStream.cpp 2006-10-16 23:23:03 UTC (rev 1089)
+++ box/chris/merge/lib/common/FileStream.cpp 2006-10-16 23:24:18 UTC (rev 1090)
@@ -47,7 +47,7 @@
// --------------------------------------------------------------------------
//
// Function
-// Name: FileStream::FileStream(int)
+// Name: FileStream::FileStream(tOSFileHandle)
// Purpose: Constructor, using existing file descriptor
// Created: 2003/08/28
//
@@ -65,6 +65,9 @@
MEMLEAKFINDER_NOT_A_LEAK(this);
THROW_EXCEPTION(CommonException, OSFileOpenError)
}
+#ifdef WIN32
+ this->fileName = "HANDLE";
+#endif
}
#if 0
@@ -138,8 +141,14 @@
{
r = numBytesRead;
}
+ else if (GetLastError() == ERROR_BROKEN_PIPE)
+ {
+ r = 0;
+ }
else
{
+ ::syslog(LOG_ERR, "Failed to read from file: error %d",
+ GetLastError());
r = -1;
}
#else
@@ -307,15 +316,12 @@
#ifdef WIN32
if(::CloseHandle(mOSFileHandle) == 0)
- {
- THROW_EXCEPTION(CommonException, OSFileCloseError)
- }
#else
if(::close(mOSFileHandle) != 0)
+#endif
{
THROW_EXCEPTION(CommonException, OSFileCloseError)
}
-#endif
mOSFileHandle = INVALID_FILE;
mIsEOF = true;