fopen(...,"a") should create?

This commit is contained in:
K. Lange 2018-05-08 22:39:30 +09:00
parent d96a913574
commit 5860f11968

View File

@ -3,6 +3,7 @@
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h>
#include <_xlog.h> #include <_xlog.h>
@ -128,18 +129,19 @@ FILE * fopen(const char *path, const char *mode) {
while (*x) { while (*x) {
if (*x == 'a') { if (*x == 'a') {
flags |= 0x08; flags |= O_WRONLY;
flags |= 0x01; flags |= O_APPEND;
flags |= O_CREAT;
} }
if (*x == 'w') { if (*x == 'w') {
flags |= 0x01; flags |= O_WRONLY;
} }
if (*x == '+') { if (*x == '+') {
if (flags & 0x01) { if (flags & O_WRONLY) {
flags |= 0x200; flags |= O_CREAT;
mask = 0666; mask = 0666;
} else { } else {
flags |= 0x01; flags |= O_WRONLY;
} }
} }
++x; ++x;