|
@@ -94,10 +94,12 @@ static HANDLE SDLCALL windows_file_open(const char *filename, const char *mode)
|
|
|
|
|
|
// "r" = reading, file must exist
|
|
|
// "w" = writing, truncate existing, file may not exist
|
|
|
+ // "wx"= writing, file must not exist
|
|
|
// "r+"= reading or writing, file must exist
|
|
|
// "a" = writing, append file may not exist
|
|
|
// "a+"= append + read, file may not exist
|
|
|
// "w+" = read, write, truncate. file may not exist
|
|
|
+ // "w+x"= read, write, file must not exist
|
|
|
|
|
|
must_exist = (SDL_strchr(mode, 'r') != NULL) ? OPEN_EXISTING : 0;
|
|
|
truncate = (SDL_strchr(mode, 'w') != NULL) ? CREATE_ALWAYS : 0;
|
|
@@ -105,6 +107,10 @@ static HANDLE SDLCALL windows_file_open(const char *filename, const char *mode)
|
|
|
a_mode = (SDL_strchr(mode, 'a') != NULL) ? OPEN_ALWAYS : 0;
|
|
|
w_right = (a_mode || SDL_strchr(mode, '+') || truncate) ? GENERIC_WRITE : 0;
|
|
|
|
|
|
+ if (truncate && (SDL_strchr(mode, 'x') != NULL)) {
|
|
|
+ truncate = CREATE_NEW;
|
|
|
+ }
|
|
|
+
|
|
|
if (!r_right && !w_right) {
|
|
|
return INVALID_HANDLE_VALUE; // inconsistent mode
|
|
|
}
|