[evince] [libdocument] Add ev_file_is_temp()



commit 68c2072c87f150690e443de656b31746ac9383ad
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Tue May 4 13:44:31 2010 +0200

    [libdocument] Add ev_file_is_temp()

 libdocument/ev-file-helpers.c |   19 +++++++++++++++++++
 libdocument/ev-file-helpers.h |    2 +-
 2 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/libdocument/ev-file-helpers.c b/libdocument/ev-file-helpers.c
index e0392f4..6483e2d 100644
--- a/libdocument/ev-file-helpers.c
+++ b/libdocument/ev-file-helpers.c
@@ -369,6 +369,25 @@ ev_tmp_uri_unlink (const gchar *uri)
 	g_object_unref (file);
 }
 
+gboolean
+ev_file_is_temp (GFile *file)
+{
+	gchar   *path;
+	gboolean retval;
+
+	if (!g_file_is_native (file))
+		return FALSE;
+
+	path = g_file_get_path (file);
+	if (!path)
+		return FALSE;
+
+	retval = g_str_has_prefix (path, g_get_tmp_dir ());
+	g_free (path);
+
+	return retval;
+}
+
 /**
  * ev_xfer_uri_simple:
  * @from: the source URI
diff --git a/libdocument/ev-file-helpers.h b/libdocument/ev-file-helpers.h
index d863caa..fffae03 100644
--- a/libdocument/ev-file-helpers.h
+++ b/libdocument/ev-file-helpers.h
@@ -49,7 +49,7 @@ gchar       *ev_mkdtemp               (const char        *template,
 void         ev_tmp_filename_unlink   (const gchar       *filename);
 void         ev_tmp_file_unlink       (GFile             *file);
 void         ev_tmp_uri_unlink        (const gchar       *uri);
-
+gboolean     ev_file_is_temp          (GFile             *file);
 gboolean     ev_xfer_uri_simple       (const char        *from,
 				       const char        *to,
 				       GError           **error);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]