[eog/gnome-2-32] Add eog_util_file_is_persistent()
- From: Claudio Saavedra <csaavedra src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [eog/gnome-2-32] Add eog_util_file_is_persistent()
- Date: Wed, 8 Sep 2010 22:43:29 +0000 (UTC)
commit 7cf4c491f6da479a7131bdcf89d569862f2c450c
Author: Claudio Saavedra <csaavedra igalia com>
Date: Thu Sep 9 01:36:29 2010 +0300
Add eog_util_file_is_persistent()
This method checks whether a file is native and in a non-unmountable
location.
doc/reference/eog-sections.txt | 1 +
src/eog-util.c | 28 ++++++++++++++++++++++++++++
src/eog-util.h | 3 +++
3 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/doc/reference/eog-sections.txt b/doc/reference/eog-sections.txt
index 3b495df..ce16d85 100644
--- a/doc/reference/eog-sections.txt
+++ b/doc/reference/eog-sections.txt
@@ -752,5 +752,6 @@ eog_util_string_array_to_list
eog_util_string_array_make_absolute
eog_util_launch_desktop_file
eog_util_dot_dir
+eog_util_file_is_persistent
</SECTION>
diff --git a/src/eog-util.c b/src/eog-util.c
index a16e3a2..642aabf 100644
--- a/src/eog-util.c
+++ b/src/eog-util.c
@@ -318,3 +318,31 @@ eog_util_filename_get_extension (const char * filename)
return g_strdup (begin);
}
+
+
+/**
+ * eog_util_file_is_persistent:
+ * @file: a #GFile
+ *
+ * Checks whether @file is a non-removable local mount.
+ *
+ * Returns: %TRUE if @file is in a non-removable mount,
+ * %FALSE otherwise or when it is remote.
+ **/
+gboolean
+eog_util_file_is_persistent (GFile *file)
+{
+ GMount *mount;
+
+ if (!g_file_is_native (file))
+ return FALSE;
+
+ mount = g_file_find_enclosing_mount (file, NULL, NULL);
+ if (mount) {
+ if (g_mount_can_unmount (mount)) {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
diff --git a/src/eog-util.h b/src/eog-util.h
index 31f95ac..ba414c7 100644
--- a/src/eog-util.h
+++ b/src/eog-util.h
@@ -64,6 +64,9 @@ const gchar *eog_util_dot_dir (void);
G_GNUC_INTERNAL
char * eog_util_filename_get_extension (const char * filename_with_extension);
+G_GNUC_INTERNAL
+gboolean eog_util_file_is_persistent (GFile *file);
+
G_END_DECLS
#endif /* __EOG_UTIL_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]