Skip to content

Commit

Permalink
Added detail about why a file couldn't be opened (thanks mgerhardy!)
Browse files Browse the repository at this point in the history
Fixes #10484

(cherry picked from commit 1512013)
  • Loading branch information
slouken committed Aug 6, 2024
1 parent a1998d1 commit 44927fe
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/file/SDL_iostream.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#ifdef HAVE_STDIO_H
#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
#endif
#ifdef HAVE_LIMITS_H
Expand Down Expand Up @@ -565,7 +566,7 @@ SDL_IOStream *SDL_IOFromFile(const char *file, const char *mode)
FILE *fp = fdopen(fd, mode);
if (!fp) {
close(fd);
SDL_SetError("Unable to open file descriptor (%d) from URI %s", fd, file);
SDL_SetError("Unable to open file descriptor (%d) from URI %s: %s", fd, file, strerror(errno));
return NULL;
}

Expand Down Expand Up @@ -655,7 +656,7 @@ SDL_IOStream *SDL_IOFromFile(const char *file, const char *mode)
#endif

if (!fp) {
SDL_SetError("Couldn't open %s", file);
SDL_SetError("Couldn't open %s: %s", file, strerror(errno));
} else if (!IsRegularFileOrPipe(fp)) {
fclose(fp);
fp = NULL;
Expand Down

0 comments on commit 44927fe

Please sign in to comment.