{
int flags = O_RDONLY;
int plus = 0;
- int fd;
while ( *mode ) {
- switch ( *mode ) {
+ switch ( *mode++ ) {
case 'r':
flags = O_RDONLY;
break;
plus = 1;
break;
}
- mode++;
}
if ( plus ) {
flags = (flags & ~(O_RDONLY|O_WRONLY)) | O_RDWR;
}
- fd = open(file, flags, 0666);
-
- if ( fd < 0 )
- return NULL;
- else
- return fdopen(fd, mode);
+ /* Note: __create_file(-1) == NULL, so this is safe */
+ return __create_file(open(file, flags, 0666));
}