summaryrefslogtreecommitdiffstats
path: root/otherlibs/win32unix/open.c
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>1997-09-04 13:45:56 +0000
committerXavier Leroy <xavier.leroy@inria.fr>1997-09-04 13:45:56 +0000
commit0efc0065fc1c1f1709ffd9abeee1751409c2170a (patch)
tree7e9e59e604771b609405ed77fff0c938a6205812 /otherlibs/win32unix/open.c
parent1e664b94467a65841e63d2dea50cd1f64e8a3258 (diff)
Debug, tests
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1701 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs/win32unix/open.c')
-rw-r--r--otherlibs/win32unix/open.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/otherlibs/win32unix/open.c b/otherlibs/win32unix/open.c
index 63e370392..3e4980d3d 100644
--- a/otherlibs/win32unix/open.c
+++ b/otherlibs/win32unix/open.c
@@ -26,10 +26,12 @@ static int open_create_flags[10] = {
value unix_open(value path, value flags, value perm) /* ML */
{
- int fileaccess, createflags, fileattrib;
+ int fileaccess, createflags, fileattrib, filecreate;
+ SECURITY_ATTRIBUTES attr;
HANDLE h;
fileaccess = convert_flag_list(flags, open_access_flags);
+
createflags = convert_flag_list(flags, open_create_flags);
if ((createflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
filecreate = CREATE_NEW;
@@ -41,12 +43,21 @@ value unix_open(value path, value flags, value perm) /* ML */
filecreate = OPEN_ALWAYS;
else
filecreate = OPEN_EXISTING;
+
if ((createflags & O_CREAT) && (Int_val(perm) & 0200) == 0)
fileattrib = FILE_ATTRIBUTE_READONLY;
else
fileattrib = FILE_ATTRIBUTE_NORMAL;
- h = CreateFile(String_val(path), fileaccess, 0, NULL,
+
+ attr.nLength = sizeof(attr);
+ attr.lpSecurityDescriptor = NULL;
+ attr.bInheritHandle = TRUE;
+
+ h = CreateFile(String_val(path), fileaccess, 0, &attr,
filecreate, fileattrib, NULL);
- if (h == INVALID_HANDLE_VALUE) uerror("open", path);
+ if (h == INVALID_HANDLE_VALUE) {
+ _dosmaperr(GetLastError());
+ uerror("open", path);
+ }
return win_alloc_handle(h);
}