Introduce is_readable_file() which test if file exists, is regular and readable.
authorLaurent Monin <geeqie@norz.org>
Sun, 1 Mar 2009 17:10:45 +0000 (17:10 +0000)
committerLaurent Monin <geeqie@norz.org>
Sun, 1 Mar 2009 17:10:45 +0000 (17:10 +0000)
src/ui_fileops.c
src/ui_fileops.h

index 9815198..c30e372 100644 (file)
@@ -419,6 +419,12 @@ gint filetime_set(const gchar *s, time_t tval)
        return ret;
 }
 
+gboolean is_readable_file(const gchar *s)
+{
+       if (!s || !s[0] || !isfile(s)) return FALSE;
+       return access_file(s, R_OK);
+}
+
 gint access_file(const gchar *s, gint mode)
 {
        gchar *sl;
index 3033b43..c00b335 100644 (file)
@@ -54,6 +54,7 @@ gint islink(const gchar *s);
 gint64 filesize(const gchar *s);
 time_t filetime(const gchar *s);
 gint filetime_set(const gchar *s, time_t tval);
+gboolean is_readable_file(const gchar *s);
 gint access_file(const gchar *s, gint mode);
 gint unlink_file(const gchar *s);
 gint symlink_utf8(const gchar *source, const gchar *target);