changeset 1360:721ffb823d6e

Introduce is_readable_file() which test if file exists, is regular and readable.
author zas_
date Sun, 01 Mar 2009 17:10:45 +0000
parents 8f3d44564146
children 84422bb8181b
files src/ui_fileops.c src/ui_fileops.h
diffstat 2 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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;
--- 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);