summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2009-04-26 14:40:17 +0000
committerChris Wilson <chris+github@qwirx.com>2009-04-26 14:40:17 +0000
commitafcac9017d4a46f4c69bdd0b4151daf2f6d4e68f (patch)
tree64b9b280a73b502675a1f6db2adf35dbb0a91ba0 /lib
parente01a99783734f3fafb22a0e15c0bf7904870889a (diff)
Provide a function to close a file handle on Windows, analogous to
openfile().
Diffstat (limited to 'lib')
-rw-r--r--lib/win32/emu.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/win32/emu.h b/lib/win32/emu.h
index 811e6495..f3389590 100644
--- a/lib/win32/emu.h
+++ b/lib/win32/emu.h
@@ -117,7 +117,7 @@ inline struct passwd * getpwnam(const char * name)
#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 @@ int closedir(DIR *dp);
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