blob: 60ca3f811d74cf3d774e34d51c30e5a519de6a8f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/*
** mwfopenrf - Open resource fork as stdio file for CodeWarrior.
**
** Jack Jansen, CWI, August 1995.
*/
#if defined(__MWERKS__) && !defined(USE_GUSI)
#include <stdio.h>
#include <unix.h>
#include <errno.h>
#include "errno_unix.h"
FILE *
fopenRF(name, mode)
char *name;
char *mode;
{
int fd;
int modebits = -1;
int extramodebits = 0;
char *modep;
for(modep=mode; *modep; modep++) {
switch(*modep) {
case 'r': modebits = O_RDONLY; break;
case 'w': modebits = O_WRONLY; extramodebits |= O_CREAT|O_TRUNC; break;
case 'a': modebits = O_RDONLY;
extramodebits |= O_CREAT|O_APPEND;
extramodebits &= ~O_TRUNC;
break;
case '+': modebits = O_RDWR;
extramodebits &= ~O_TRUNC;
break;
case 'b': extramodebits |= O_BINARY;
break;
default:
errno = EINVAL;
return NULL;
}
}
if ( modebits == -1 ) {
errno = EINVAL;
return NULL;
}
fd = open(name, modebits|extramodebits|O_RSRC);
if ( fd < 0 )
return NULL;
return fdopen(fd, mode);
}
#endif /* __MWERKS__ */
|