Skip to content
Snippets Groups Projects
Commit fe13d2fa authored by rswindell's avatar rswindell
Browse files

Another attempt at fixing the fdopen mode conversion in fnopen().

parent 60717527
Branches
Tags
No related merge requests found
......@@ -69,11 +69,12 @@ FILE* DLLCALL fnopen(int *fd, char *str, int access)
char mode[128];
int file;
FILE * stream;
#if 0
if(access&O_CREAT && access&O_WRONLY) { /* not compatible with fdopen */
access&=~O_WRONLY;
access|=O_RDWR;
}
#endif
if((file=nopen(str,access))==-1)
return(NULL);
......@@ -81,17 +82,17 @@ FILE* DLLCALL fnopen(int *fd, char *str, int access)
*fd=file;
if(access&O_APPEND) {
if(access&O_RDONLY)
if(access&O_RDWR)
strcpy(mode,"a+");
else
strcpy(mode,"a");
} else if(access&O_CREAT) {
if(access&O_TRUNC)
strcpy(mode,"w");
else
} else if(access&O_TRUNC) {
if(access&O_RDWR)
strcpy(mode,"w+");
else
strcpy(mode,"w");
} else {
if(access&O_WRONLY || (access&O_RDWR)==O_RDWR)
if(access&(O_RDWR|O_WRONLY))
strcpy(mode,"r+");
else
strcpy(mode,"r");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment