mirror of
https://github.com/devkitPro/wut.git
synced 2026-03-21 17:34:47 -05:00
wutdevoptab: Add support for opening files with more flag combinations (#322)
This commit is contained in:
parent
071345feb2
commit
8df8e18e76
|
|
@ -35,6 +35,12 @@ __wut_fsa_open(struct _reent *r,
|
|||
fsMode = "w";
|
||||
} else if (((flags & O_ACCMODE) == O_RDWR) && ((flags & commonFlagMask) == (O_CREAT | O_TRUNC))) {
|
||||
fsMode = "w+";
|
||||
} else if (((flags & O_ACCMODE) == O_WRONLY) && ((flags & commonFlagMask) == O_CREAT) && (flags & O_EXCL) == O_EXCL) {
|
||||
// if O_EXCL is set, we don't need O_TRUNC
|
||||
fsMode = "w";
|
||||
} else if (((flags & O_ACCMODE) == O_RDWR) && ((flags & commonFlagMask) == O_CREAT) && (flags & O_EXCL) == O_EXCL) {
|
||||
// if O_EXCL is set, we don't need O_TRUNC
|
||||
fsMode = "w+";
|
||||
} else if (((flags & O_ACCMODE) == O_WRONLY) && ((flags & commonFlagMask) == (O_CREAT | O_APPEND))) {
|
||||
fsMode = "a";
|
||||
} else if (((flags & O_ACCMODE) == O_RDWR) && ((flags & commonFlagMask) == (O_CREAT | O_APPEND))) {
|
||||
|
|
@ -45,6 +51,10 @@ __wut_fsa_open(struct _reent *r,
|
|||
// It's not possible to open a file with write only mode which doesn't truncate the file
|
||||
// Technically we could read from the file, but our read implementation is blocking this.
|
||||
fsMode = "r+";
|
||||
} else if (((flags & O_ACCMODE) == O_RDWR) && ((flags & commonFlagMask) == (O_CREAT))) {
|
||||
// Cafe OS doesn't have a matching mode for this, so we have to be creative and create the file.
|
||||
createFileIfNotFound = true;
|
||||
fsMode = "r+";
|
||||
} else if (((flags & O_ACCMODE) == O_WRONLY) && ((flags & commonFlagMask) == (O_APPEND))) {
|
||||
// Cafe OS doesn't have a matching mode for this, so we have to check if the file exists.
|
||||
failIfFileNotFound = true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user