From 84dd8601e0f37301b82aa035ceac32b0264b4748 Mon Sep 17 00:00:00 2001 From: Alain Frisch Date: Tue, 13 Dec 2011 16:18:13 +0000 Subject: #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 --- otherlibs/win32unix/open.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'otherlibs/win32unix/open.c') 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()); -- cgit v1.2.3-70-g09d2