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