# HG changeset patch # User zas_ # Date 1235927445 0 # Node ID 721ffb823d6e2c7d6541ea19b3096986a9dd1587 # Parent 8f3d44564146cdf3dcd59f49078bc45afb260f87 Introduce is_readable_file() which test if file exists, is regular and readable. diff -r 8f3d44564146 -r 721ffb823d6e src/ui_fileops.c --- a/src/ui_fileops.c Sun Mar 01 16:46:40 2009 +0000 +++ b/src/ui_fileops.c Sun Mar 01 17:10:45 2009 +0000 @@ -419,6 +419,12 @@ 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; diff -r 8f3d44564146 -r 721ffb823d6e src/ui_fileops.h --- a/src/ui_fileops.h Sun Mar 01 16:46:40 2009 +0000 +++ b/src/ui_fileops.h Sun Mar 01 17:10:45 2009 +0000 @@ -54,6 +54,7 @@ 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);