diff options
Diffstat (limited to 'pr/src/md/os2/os2io.c')
-rw-r--r-- | pr/src/md/os2/os2io.c | 59 |
1 files changed, 42 insertions, 17 deletions
diff --git a/pr/src/md/os2/os2io.c b/pr/src/md/os2/os2io.c index e6977ff7..e7e7b705 100644 --- a/pr/src/md/os2/os2io.c +++ b/pr/src/md/os2/os2io.c @@ -14,6 +14,23 @@ * Communications Corporation. Portions created by Netscape are * Copyright (C) 1998 Netscape Communications Corporation. All Rights * Reserved. + * + * This Original Code has been modified by IBM Corporation. + * Modifications made by IBM described herein are + * Copyright (c) International Business Machines + * Corporation, 2000 + * + * Modifications to Mozilla code or documentation + * identified per MPL Section 3.3 + * + * Date Modified by Description of modification + * 03/23/2000 IBM Corp. Changed write() to DosWrite(). EMX i/o + * calls cannot be intermixed with DosXXX + * calls since EMX remaps file/socket + * handles. + * 04/27/2000 IBM Corp. Changed open file to be more like NT and + * better handle PR_TRUNCATE | PR_CREATE_FILE + * and also fixed _PR_MD_SET_FD_INHERITABLE */ /* OS2 IO module @@ -107,25 +124,40 @@ _PR_MD_OPEN(const char *name, PRIntn osflags, int mode) { HFILE file; PRInt32 access = OPEN_SHARE_DENYNONE; - PRInt32 flags = OPEN_ACTION_OPEN_IF_EXISTS; + PRInt32 flags = 0L; PRInt32 rc; PRUword actionTaken; ULONG CurMaxFH = 0; LONG ReqCount = 1; ULONG fattr; - + + if (osflags & PR_SYNC) access |= OPEN_FLAGS_WRITE_THROUGH; + if (osflags & PR_RDONLY) access |= OPEN_ACCESS_READONLY; else if (osflags & PR_WRONLY) access |= OPEN_ACCESS_WRITEONLY; else if(osflags & PR_RDWR) access |= OPEN_ACCESS_READWRITE; - if (osflags & PR_CREATE_FILE) - flags |= OPEN_ACTION_CREATE_IF_NEW; - else if (osflags & PR_TRUNCATE){ - flags &= ~OPEN_ACTION_OPEN_IF_EXISTS; - flags |= OPEN_ACTION_REPLACE_IF_EXISTS; + + if ( osflags & PR_CREATE_FILE && osflags & PR_EXCL ) + { + flags = OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_FAIL_IF_EXISTS; + } + else if (osflags & PR_CREATE_FILE) + { + if (osflags & PR_TRUNCATE) + flags = OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS; + else + flags = OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS; + } + else + { + if (osflags & PR_TRUNCATE) + flags = OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS; + else + flags = OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS; } if (isxdigit(mode) == 0) /* file attribs are hex, UNIX modes octal */ @@ -182,23 +214,16 @@ _PR_MD_WRITE(PRFileDesc *fd, const void *buf, PRInt32 len) PRInt32 bytes; int rv; - /* No longer using DosWrite since it doesn't convert \n to \n\r like C runtime does */ -#if 0 rv = DosWrite((HFILE)fd->secret->md.osfd, (PVOID)buf, len, - &bytes); + (PULONG)&bytes); if (rv != NO_ERROR) { - _PR_MD_MAP_WRITE_ERROR(rv); + _PR_MD_MAP_WRITE_ERROR(rv); return -1; } -#else - bytes = write(fd->secret->md.osfd, buf, len); - if (bytes == -1) - _PR_MD_MAP_WRITE_ERROR(errno); -#endif return bytes; } /* --- end _PR_MD_WRITE() --- */ @@ -718,7 +743,7 @@ _PR_MD_SET_FD_INHERITABLE(PRFileDesc *fd, PRBool inheritable) } if (inheritable) - flags &= OPEN_FLAGS_NOINHERIT; + flags &= ~OPEN_FLAGS_NOINHERIT; else flags |= OPEN_FLAGS_NOINHERIT; |