File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,6 +35,12 @@ __wut_fsa_open(struct _reent *r,
3535 fsMode = " w" ;
3636 } else if (((flags & O_ACCMODE) == O_RDWR) && ((flags & commonFlagMask) == (O_CREAT | O_TRUNC))) {
3737 fsMode = " w+" ;
38+ } else if (((flags & O_ACCMODE) == O_WRONLY) && ((flags & commonFlagMask) == O_CREAT) && (flags & O_EXCL) == O_EXCL) {
39+ // if O_EXCL is set, we don't need O_TRUNC
40+ fsMode = " w" ;
41+ } else if (((flags & O_ACCMODE) == O_RDWR) && ((flags & commonFlagMask) == O_CREAT) && (flags & O_EXCL) == O_EXCL) {
42+ // if O_EXCL is set, we don't need O_TRUNC
43+ fsMode = " w+" ;
3844 } else if (((flags & O_ACCMODE) == O_WRONLY) && ((flags & commonFlagMask) == (O_CREAT | O_APPEND))) {
3945 fsMode = " a" ;
4046 } else if (((flags & O_ACCMODE) == O_RDWR) && ((flags & commonFlagMask) == (O_CREAT | O_APPEND))) {
@@ -45,6 +51,10 @@ __wut_fsa_open(struct _reent *r,
4551 // It's not possible to open a file with write only mode which doesn't truncate the file
4652 // Technically we could read from the file, but our read implementation is blocking this.
4753 fsMode = " r+" ;
54+ } else if (((flags & O_ACCMODE) == O_RDWR) && ((flags & commonFlagMask) == (O_CREAT))) {
55+ // Cafe OS doesn't have a matching mode for this, so we have to be creative and create the file.
56+ createFileIfNotFound = true ;
57+ fsMode = " r+" ;
4858 } else if (((flags & O_ACCMODE) == O_WRONLY) && ((flags & commonFlagMask) == (O_APPEND))) {
4959 // Cafe OS doesn't have a matching mode for this, so we have to check if the file exists.
5060 failIfFileNotFound = true ;
You can’t perform that action at this time.
0 commit comments