mirror of
https://github.com/wiiu-env/libiosuhax.git
synced 2025-01-09 00:20:43 +01:00
Use fs modes from wut
This commit is contained in:
parent
c7a40da972
commit
11852617d6
@ -121,27 +121,44 @@ static int fs_dev_open_r (struct _reent *r, void *fileStruct, const char *path,
|
|||||||
// Determine which mode the file is opened for
|
// Determine which mode the file is opened for
|
||||||
file->flags = flags;
|
file->flags = flags;
|
||||||
|
|
||||||
const char *mode_str;
|
const char *fsMode;
|
||||||
|
|
||||||
if ((flags & 0x03) == O_RDONLY) {
|
// Map flags to open modes
|
||||||
|
if (flags == 0) {
|
||||||
file->read = 1;
|
file->read = 1;
|
||||||
file->write = 0;
|
file->write = 0;
|
||||||
file->append = 0;
|
file->append = 0;
|
||||||
mode_str = "r";
|
fsMode = "r";
|
||||||
} else if ((flags & 0x03) == O_WRONLY) {
|
} else if (flags == 2) {
|
||||||
file->read = 0;
|
|
||||||
file->write = 1;
|
|
||||||
file->append = (flags & O_APPEND);
|
|
||||||
mode_str = file->append ? "a" : "w";
|
|
||||||
} else if ((flags & 0x03) == O_RDWR) {
|
|
||||||
file->read = 1;
|
file->read = 1;
|
||||||
file->write = 1;
|
file->write = 1;
|
||||||
file->append = (flags & O_APPEND);
|
file->append = 0;
|
||||||
mode_str = file->append ? "a+" : "r+";
|
fsMode = "r+";
|
||||||
|
} else if (flags == 0x601) {
|
||||||
|
file->read = 0;
|
||||||
|
file->write = 1;
|
||||||
|
file->append = 0;
|
||||||
|
fsMode = "w";
|
||||||
|
} else if(flags == 0x602) {
|
||||||
|
file->read = 1;
|
||||||
|
file->write = 1;
|
||||||
|
file->append = 0;
|
||||||
|
fsMode = "w+";
|
||||||
|
} else if(flags == 0x209) {
|
||||||
|
file->read = 0;
|
||||||
|
file->write = 1;
|
||||||
|
file->append = 1;
|
||||||
|
fsMode = "a";
|
||||||
|
} else if(flags == 0x20A) {
|
||||||
|
file->read = 1;
|
||||||
|
file->write = 1;
|
||||||
|
file->append = 1;
|
||||||
|
fsMode = "a+";
|
||||||
} else {
|
} else {
|
||||||
r->_errno = EACCES;
|
r->_errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
|
|
||||||
@ -154,7 +171,7 @@ static int fs_dev_open_r (struct _reent *r, void *fileStruct, const char *path,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int result = IOSUHAX_FSA_OpenFile(dev->fsaFd, real_path, mode_str, &fd);
|
int result = IOSUHAX_FSA_OpenFile(dev->fsaFd, real_path, fsMode, &fd);
|
||||||
|
|
||||||
free(real_path);
|
free(real_path);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user