[Box Backup-commit] COMMIT r1015 - box/chris/merge/lib/common

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Sat Oct 14 00:00:29 BST 2006


Author: chris
Date: 2006-10-14 00:00:29 +0100 (Sat, 14 Oct 2006)
New Revision: 1015

Modified:
   box/chris/merge/lib/common/FileStream.cpp
Log:
 * Use INVALID_HANDLE_VALUE instead of NULL to represent invalid file 
   handles under Win32 (refs #3)


Modified: box/chris/merge/lib/common/FileStream.cpp
===================================================================
--- box/chris/merge/lib/common/FileStream.cpp	2006-10-13 22:58:37 UTC (rev 1014)
+++ box/chris/merge/lib/common/FileStream.cpp	2006-10-13 23:00:29 UTC (rev 1015)
@@ -274,7 +274,7 @@
 	conv.QuadPart = Offset;
 	DWORD retVal = SetFilePointer(this->mOSFileHandle, conv.LowPart, &conv.HighPart, ConvertSeekTypeToOSWhence(SeekType));
 
-	if ( retVal == INVALID_SET_FILE_POINTER && (GetLastError() != NO_ERROR) )
+	if(retVal == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR)
 	{
 		THROW_EXCEPTION(CommonException, OSFileError)
 	}
@@ -300,25 +300,25 @@
 // --------------------------------------------------------------------------
 void FileStream::Close()
 {
-	if(mOSFileHandle < 0)
+	if(mOSFileHandle == INVALID_FILE)
 	{
 		THROW_EXCEPTION(CommonException, FileAlreadyClosed)
 	}
+
 #ifdef WIN32
 	if(::CloseHandle(mOSFileHandle) == 0)
 	{
 		THROW_EXCEPTION(CommonException, OSFileCloseError)
 	}
-	mOSFileHandle = NULL;
-	mIsEOF = true;
 #else
 	if(::close(mOSFileHandle) != 0)
 	{
 		THROW_EXCEPTION(CommonException, OSFileCloseError)
 	}
-	mOSFileHandle = -1;
+#endif
+
+	mOSFileHandle = INVALID_FILE;
 	mIsEOF = true;
-#endif
 }
 
 




More information about the Boxbackup-commit mailing list