Commit 31324ffb authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

return the "errno" of a failed stat() call.

2004-03-03  Michael Natterer  <mitch@gimp.org>

	* libgimpthumb/gimpthumb-utils.[ch] (gimp_thumb_file_test):
	return the "errno" of a failed stat() call.

	* libgimpthumb/gimpthumbnail.[ch]: added member
	"image_not_found_errno" which contains the errno as returned by
	gimp_thumb_file_test() if thumbnail->image_state is
	GIMP_THUMB_STATE_NOT_FOUND.

	* app/core/gimpimagefile.c (gimp_imagefile_get_desc_string): display
	the real error as specified by thumbnail->image_not_found_errno
	instead of just "Could not open".
parent 1b63a057
2004-03-03 Michael Natterer <mitch@gimp.org>
* libgimpthumb/gimpthumb-utils.[ch] (gimp_thumb_file_test):
return the "errno" of a failed stat() call.
* libgimpthumb/gimpthumbnail.[ch]: added member
"image_not_found_errno" which contains the errno as returned by
gimp_thumb_file_test() if thumbnail->image_state is
GIMP_THUMB_STATE_NOT_FOUND.
* app/core/gimpimagefile.c (gimp_imagefile_get_desc_string): display
the real error as specified by thumbnail->image_not_found_errno
instead of just "Could not open".
2004-03-03 Michael Natterer <mitch@gimp.org>
* app/widgets/Makefile.am
......@@ -490,7 +490,7 @@ gimp_imagefile_get_desc_string (GimpImagefile *imagefile)
break;
case GIMP_THUMB_STATE_NOT_FOUND:
imagefile->description = _("Could not open");
imagefile->description = g_strerror (thumbnail->image_not_found_errno);
imagefile->static_desc = TRUE;
break;
......
......@@ -25,6 +25,7 @@
#include "config.h"
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
......@@ -262,7 +263,7 @@ gimp_thumb_find_thumb (const gchar *uri,
{
thumb_name = g_build_filename (thumb_subdirs[i], name, NULL);
if (gimp_thumb_file_test (thumb_name, NULL, NULL) ==
if (gimp_thumb_file_test (thumb_name, NULL, NULL, NULL) ==
GIMP_THUMB_FILE_TYPE_REGULAR)
{
*size = thumb_sizes[i];
......@@ -276,7 +277,7 @@ gimp_thumb_find_thumb (const gchar *uri,
{
thumb_name = g_build_filename (thumb_subdirs[i], name, NULL);
if (gimp_thumb_file_test (thumb_name, NULL, NULL) ==
if (gimp_thumb_file_test (thumb_name, NULL, NULL, NULL) ==
GIMP_THUMB_FILE_TYPE_REGULAR)
{
*size = thumb_sizes[i];
......@@ -294,6 +295,7 @@ gimp_thumb_find_thumb (const gchar *uri,
* @filename: a filename in the encoding of the filesystem
* @mtime: return location for modification time
* @size: return location for file size
* @err_no: return location for system "errno"
*
* This is a convenience and portability wrapper around stat(). It
* checks if the given @filename exists and returns modification time
......@@ -305,7 +307,8 @@ gimp_thumb_find_thumb (const gchar *uri,
GimpThumbFileType
gimp_thumb_file_test (const gchar *filename,
gint64 *mtime,
gint64 *size)
gint64 *size,
gint *err_no)
{
struct stat s;
......@@ -313,8 +316,9 @@ gimp_thumb_file_test (const gchar *filename,
if (stat (filename, &s) == 0)
{
if (mtime) *mtime = s.st_mtime;
if (size) *size = s.st_size;
if (mtime) *mtime = s.st_mtime;
if (size) *size = s.st_size;
if (err_no) *err_no = 0;
if (S_ISREG (s.st_mode))
{
......@@ -328,8 +332,9 @@ gimp_thumb_file_test (const gchar *filename,
return GIMP_THUMB_FILE_TYPE_SPECIAL;
}
if (mtime) *mtime = 0;
if (size) *size = 0;
if (mtime) *mtime = 0;
if (size) *size = 0;
if (err_no) *err_no = errno;
return GIMP_THUMB_FILE_TYPE_NONE;
}
......
......@@ -43,7 +43,8 @@ gchar * gimp_thumb_find_thumb (const gchar *uri,
GimpThumbFileType gimp_thumb_file_test (const gchar *filename,
gint64 *mtime,
gint64 *size);
gint64 *size,
gint *err_no);
G_END_DECLS
......
......@@ -583,7 +583,8 @@ gimp_thumbnail_update_image (GimpThumbnail *thumbnail)
default:
switch (gimp_thumb_file_test (thumbnail->image_filename,
&mtime, &filesize))
&mtime, &filesize,
&thumbnail->image_not_found_errno))
{
case GIMP_THUMB_FILE_TYPE_REGULAR:
state = GIMP_THUMB_STATE_EXISTS;
......
......@@ -48,6 +48,7 @@ struct _GimpThumbnail
gchar *image_filename;
gint64 image_filesize;
gint64 image_mtime;
gint image_not_found_errno;
gint image_width;
gint image_height;
gchar *image_type;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment