mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-11-09 20:15:16 +00:00
Added detail about why a file couldn't be opened (thanks mgerhardy!)
Fixes https://github.com/libsdl-org/SDL/issues/10484
(cherry picked from commit 1512013320)
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#ifdef HAVE_STDIO_H
|
#ifdef HAVE_STDIO_H
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_LIMITS_H
|
#ifdef HAVE_LIMITS_H
|
||||||
@@ -565,7 +566,7 @@ SDL_IOStream *SDL_IOFromFile(const char *file, const char *mode)
|
|||||||
FILE *fp = fdopen(fd, mode);
|
FILE *fp = fdopen(fd, mode);
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
close(fd);
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -655,7 +656,7 @@ SDL_IOStream *SDL_IOFromFile(const char *file, const char *mode)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
SDL_SetError("Couldn't open %s", file);
|
SDL_SetError("Couldn't open %s: %s", file, strerror(errno));
|
||||||
} else if (!IsRegularFileOrPipe(fp)) {
|
} else if (!IsRegularFileOrPipe(fp)) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
fp = NULL;
|
fp = NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user