From 8402cd9683545436bd4690af6be8408f19052014 Mon Sep 17 00:00:00 2001 From: Philipp Stehle Date: Mon, 30 Sep 2024 20:11:19 +0200 Subject: [PATCH] print fopen errors --- src/fs_ext.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/fs_ext.c b/src/fs_ext.c index e39d7cca..e9c55cfb 100644 --- a/src/fs_ext.c +++ b/src/fs_ext.c @@ -1,11 +1,13 @@ #include "fs_ext.h" +#include // for errno #include // for uint8_t #include // for fopen, FILE #include // for NULL, free -#include // for strdup, strlen, strrchr +#include // for strdup, strlen, strrchr, strerror #include "error.h" // for NO_ERROR, ERROR_END_OF_FILE, ERROR_FILE_... +#include "debug.h" // for TRACE_INFO, TRACE_ERROR, TRACE_LEVEL_INFO #include "fs_port_config.h" // for PATH_SEPARATOR #include "os_port.h" // for osStrlen @@ -37,6 +39,10 @@ FsFile *fsOpenFileEx(const char_t *path, char *mode) // Open the specified file fp = fopen(path, mode); + if (fp == NULL) { + TRACE_ERROR("Could not open file %s: %s\n", path, strerror(errno)); + } + // Return a handle to the file return fp; }