summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--otherlibs/threads/unix.ml1
-rw-r--r--otherlibs/unix/open.c2
-rw-r--r--otherlibs/unix/unix.ml1
-rw-r--r--otherlibs/unix/unix.mli1
-rw-r--r--otherlibs/unix/unixLabels.mli1
-rw-r--r--otherlibs/win32unix/open.c13
-rw-r--r--otherlibs/win32unix/unix.ml1
7 files changed, 15 insertions, 5 deletions
diff --git a/otherlibs/threads/unix.ml b/otherlibs/threads/unix.ml
index 230617072..609c098a3 100644
--- a/otherlibs/threads/unix.ml
+++ b/otherlibs/threads/unix.ml
@@ -192,6 +192,7 @@ type open_flag =
| O_DSYNC
| O_SYNC
| O_RSYNC
+ | O_SHARE_DELETE
type file_perm = int
diff --git a/otherlibs/unix/open.c b/otherlibs/unix/open.c
index 39c7328f9..214a550d3 100644
--- a/otherlibs/unix/open.c
+++ b/otherlibs/unix/open.c
@@ -36,7 +36,7 @@
static int open_flag_table[] = {
O_RDONLY, O_WRONLY, O_RDWR, O_NONBLOCK, O_APPEND, O_CREAT, O_TRUNC, O_EXCL,
- O_NOCTTY, O_DSYNC, O_SYNC, O_RSYNC
+ O_NOCTTY, O_DSYNC, O_SYNC, O_RSYNC, 0
};
CAMLprim value unix_open(value path, value flags, value perm)
diff --git a/otherlibs/unix/unix.ml b/otherlibs/unix/unix.ml
index eda85de0f..bfade0389 100644
--- a/otherlibs/unix/unix.ml
+++ b/otherlibs/unix/unix.ml
@@ -151,6 +151,7 @@ type open_flag =
| O_DSYNC
| O_SYNC
| O_RSYNC
+ | O_SHARE_DELETE
type file_perm = int
diff --git a/otherlibs/unix/unix.mli b/otherlibs/unix/unix.mli
index 38d1b9659..0cf4fdf20 100644
--- a/otherlibs/unix/unix.mli
+++ b/otherlibs/unix/unix.mli
@@ -238,6 +238,7 @@ type open_flag =
| O_DSYNC (** Writes complete as `Synchronised I/O data integrity completion' *)
| O_SYNC (** Writes complete as `Synchronised I/O file integrity completion' *)
| O_RSYNC (** Reads complete as writes (depending on O_SYNC/O_DSYNC) *)
+ | O_SHARE_DELETE (** Windows only: open the file in FILE_SHARE_DELETE mode *)
(** The flags to {!Unix.openfile}. *)
diff --git a/otherlibs/unix/unixLabels.mli b/otherlibs/unix/unixLabels.mli
index 702a656a4..db3fadf8d 100644
--- a/otherlibs/unix/unixLabels.mli
+++ b/otherlibs/unix/unixLabels.mli
@@ -240,6 +240,7 @@ type open_flag = Unix.open_flag =
| O_DSYNC (** Writes complete as `Synchronised I/O data integrity completion' *)
| O_SYNC (** Writes complete as `Synchronised I/O file integrity completion' *)
| O_RSYNC (** Reads complete as writes (depending on O_SYNC/O_DSYNC) *)
+ | O_SHARE_DELETE (** Windows only: open the file in FILE_SHARE_DELETE mode *)
(** The flags to {!UnixLabels.openfile}. *)
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());
diff --git a/otherlibs/win32unix/unix.ml b/otherlibs/win32unix/unix.ml
index c513ee4da..56d33bde8 100644
--- a/otherlibs/win32unix/unix.ml
+++ b/otherlibs/win32unix/unix.ml
@@ -170,6 +170,7 @@ type open_flag =
| O_DSYNC
| O_SYNC
| O_RSYNC
+ | O_SHARE_DELETE
type file_perm = int