summaryrefslogtreecommitdiffstats
path: root/otherlibs/win32unix/open.c
diff options
context:
space:
mode:
Diffstat (limited to 'otherlibs/win32unix/open.c')
-rw-r--r--otherlibs/win32unix/open.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/otherlibs/win32unix/open.c b/otherlibs/win32unix/open.c
index 4f90ed761..1e3e09a70 100644
--- a/otherlibs/win32unix/open.c
+++ b/otherlibs/win32unix/open.c
@@ -20,20 +20,25 @@
static int open_access_flags[12] = {
GENERIC_READ, GENERIC_WRITE, GENERIC_READ|GENERIC_WRITE,
- 0, 0, 0, 0, 0, 0, 0, 0, 0
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
static int open_create_flags[12] = {
- 0, 0, 0, 0, 0, O_CREAT, O_TRUNC, O_EXCL, 0, 0, 0, 0
+ 0, 0, 0, 0, 0, O_CREAT, O_TRUNC, O_EXCL, 0, 0, 0, 0, 0
};
+static int open_share_flags[12] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, FILE_SHARE_DELETE
+}
+
CAMLprim value unix_open(value path, value flags, value perm)
{
- int fileaccess, createflags, fileattrib, filecreate;
+ int fileaccess, createflags, fileattrib, filecreate, sharemode;
SECURITY_ATTRIBUTES attr;
HANDLE h;
fileaccess = convert_flag_list(flags, open_access_flags);
+ sharemode = FILE_SHARE_READ | FILE_SHARE_WRITE | convert_flag_list(flags, open_share_flags);
createflags = convert_flag_list(flags, open_create_flags);
if ((createflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
@@ -57,7 +62,7 @@ CAMLprim value unix_open(value path, value flags, value perm)
attr.bInheritHandle = TRUE;
h = CreateFile(String_val(path), fileaccess,
- FILE_SHARE_READ | FILE_SHARE_WRITE, &attr,
+ sharemode, &attr,
filecreate, fileattrib, NULL);
if (h == INVALID_HANDLE_VALUE) {
win32_maperr(GetLastError());