diff --git a/core/file.c b/core/file.c index cf37f621..76c8e3d0 100644 --- a/core/file.c +++ b/core/file.c @@ -7,8 +7,9 @@ #include #include -#define REPORT_ERROR(fname) \ - printf("%s (%s:%d): %s: %s\n", __func__, __FILE__, __LINE__, fname, strerror(errno)) +#define REPORT_ERROR(fname, error) \ + g_printerr("%s (%s:%d): %s: %s\n", __func__, __FILE__, __LINE__, fname, error) +#define REPORT_ERRNO(fname) REPORT_ERROR(fname, strerror(errno)) static gchar *__file_path(const gchar *name) { @@ -20,7 +21,7 @@ static FILE *__file_open(gchar *path, const gchar *mode) FILE *ret = g_fopen(path, mode); if (!ret) - REPORT_ERROR(path); + REPORT_ERRNO(path); g_free(path); return ret; } @@ -31,7 +32,7 @@ static bool __file_mkdir() int ret = g_mkdir_with_parents(dir, 0755); if (ret != 0) - REPORT_ERROR(dir); + REPORT_ERRNO(dir); g_free(dir); return ret == 0; } @@ -187,6 +188,6 @@ int file_writef(struct file *file, const char *fmt, ...) va_end(argp); if (ret < 0) - REPORT_ERROR(file->f_name); + REPORT_ERRNO(file->f_name); return ret; }