Chameleon

Chameleon Svn Source Tree

Root/branches/xZenu/src/modules/klibc/fopen.c

Source at commit 1308 created 12 years 8 months ago.
By meklort, Add a few placeholders for file io
1/*
2 * fopen.c
3 */
4
5#include <stdio.h>
6#include <unistd.h>
7//#include <fcntl.h>
8
9/* This depends on O_RDONLY == 0, O_WRONLY == 1, O_RDWR == 2 */
10
11FILE *fopen(const char *file, const char *mode)
12{
13printf("WARNING: fopen unimplimented.\n");
14return NULL;
15#if 0
16int flags = O_RDONLY;
17int plus = 0;
18
19while (*mode) {
20switch (*mode++) {
21case 'r':
22flags = O_RDONLY;
23break;
24case 'w':
25flags = O_WRONLY | O_CREAT | O_TRUNC;
26break;
27case 'a':
28flags = O_WRONLY | O_CREAT | O_APPEND;
29break;
30case '+':
31plus = 1;
32break;
33}
34}
35
36if (plus) {
37flags = (flags & ~(O_RDONLY | O_WRONLY)) | O_RDWR;
38}
39
40/* Note: __create_file(-1) == NULL, so this is safe */
41return __create_file(open(file, flags, 0666));
42#endif
43}
44

Archive Download this file

Revision: 1308