[Box Backup-commit] COMMIT r2511 - box/trunk/lib/win32

boxbackup-dev@boxbackup.org boxbackup-dev@boxbackup.org
Sun, 26 Apr 2009 15:40:19 +0100 (BST)


Author: chris
Date: 2009-04-26 15:40:17 +0100 (Sun, 26 Apr 2009)
New Revision: 2511

Modified:
   box/trunk/lib/win32/emu.h
Log:
Provide a function to close a file handle on Windows, analogous to
openfile().


Modified: box/trunk/lib/win32/emu.h
===================================================================
--- box/trunk/lib/win32/emu.h	2009-04-26 14:39:21 UTC (rev 2510)
+++ box/trunk/lib/win32/emu.h	2009-04-26 14:40:17 UTC (rev 2511)
@@ -117,7 +117,7 @@
 #ifndef __MINGW32__
 	//not sure if these are correct
 	//S_IWRITE -   writing permitted
-	//_S_IREAD -    reading permitted
+	//_S_IREAD -   reading permitted
 	//_S_IREAD | _S_IWRITE - 
 	#define S_IRUSR S_IWRITE
 	#define S_IWUSR S_IREAD
@@ -242,6 +242,15 @@
 
 extern DWORD winerrno; /* used to report errors from openfile() */
 HANDLE openfile(const char *filename, int flags, int mode);
+inline int closefile(HANDLE handle)
+{
+	if (CloseHandle(handle) != TRUE)
+	{
+		errno = EINVAL;
+		return -1;
+	}
+	return 0;
+}
 
 #define LOG_DEBUG LOG_INFO
 #define LOG_INFO 6