summaryrefslogtreecommitdiffstats
path: root/otherlibs/win32unix/open.c
diff options
context:
space:
mode:
authorAlain Frisch <alain@frisch.fr>2011-12-13 16:18:13 +0000
committerAlain Frisch <alain@frisch.fr>2011-12-13 16:18:13 +0000
commit84dd8601e0f37301b82aa035ceac32b0264b4748 (patch)
tree3ca62ca6c41424dad3b69db4f49fbb410716c6cc /otherlibs/win32unix/open.c
parentd187828b8cab7db61101e9cea09fb035df96cf74 (diff)
#5420: adding a O_SHARE_DELETE flag to Unix.openfile, for enabling FILE_SHARE_DELETE mode under Windows (ignored under Unix).
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11304 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
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());