Add g_file_query_file_type convenience function to query the type of a
authorMatthias Clasen <mclasen@redhat.com>
Mon, 31 Mar 2008 04:46:22 +0000 (04:46 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 31 Mar 2008 04:46:22 +0000 (04:46 +0000)
2008-03-30  Matthias Clasen  <mclasen@redhat.com>

        * gio.symbols:
        * gfile.c:
        * gfile.h: Add g_file_query_file_type convenience function
        to query the type of a file.  (#520715, Mikkel Kamstrup Erlandsen)

svn path=/trunk/; revision=6784

docs/reference/ChangeLog
docs/reference/gio/gio-sections.txt
gio/ChangeLog
gio/gfile.c
gio/gfile.h
gio/gio.symbols

index e0030fb..b932bdd 100644 (file)
@@ -1,4 +1,8 @@
 2008-03-30  Matthias Clasen  <mclasen@redhat.com>
+       
+       * gio/gio-sections.txt: Add g_file_query_file_type.
+
+2008-03-30  Matthias Clasen  <mclasen@redhat.com>
 
        * glib/glib-sections.txt:
        * glib/tmpl/macros-misc.sgml: Document G_GNUC_ALLOC_SIZE
index 6e111ed..abce363 100644 (file)
@@ -70,6 +70,7 @@ g_file_query_info
 g_file_query_info_async
 g_file_query_info_finish
 g_file_query_exists
+g_file_query_file_type
 g_file_query_filesystem_info
 g_file_query_filesystem_info_async
 g_file_query_filesystem_info_finish
index 2cdebd2..52e0bc7 100644 (file)
@@ -1,5 +1,12 @@
 2008-03-30  Matthias Clasen  <mclasen@redhat.com>
 
+       * gio.symbols:
+       * gfile.c:
+       * gfile.h: Add g_file_query_file_type convenience function
+       to query the type of a file.  (#520715, Mikkel Kamstrup Erlandsen)
+
+2008-03-30  Matthias Clasen  <mclasen@redhat.com>
+
        * gfileenumerator.c:
        * gfile.c: Fix some documentation typos.  (#524950, Rob Bradford)
 
index b15167d..e881554 100644 (file)
@@ -931,8 +931,7 @@ g_file_query_exists (GFile *file,
   g_return_val_if_fail (G_IS_FILE(file), FALSE);
   
   info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_TYPE,
-                           G_FILE_QUERY_INFO_NONE,
-                           cancellable, NULL);
+                           G_FILE_QUERY_INFO_NONE, cancellable, NULL);
   if (info != NULL)
     {
       g_object_unref (info);
@@ -943,6 +942,45 @@ g_file_query_exists (GFile *file,
 }
 
 /**
+ * g_file_query_file_type:
+ * @file: input #GFile.
+ * @flags: a set of #GFileQueryInfoFlags passed to g_file_query_info().
+ * @cancellable: optional #GCancellable object, %NULL to ignore.
+ *
+ * Utility function to inspect the #GFileType of a file. This is
+ * implemented using g_file_query_info() and as such does blocking I/O.
+ *
+ * The primary use case of this method is to check if a file is a regular file,
+ * directory, or symlink.
+ * 
+ * Returns: The #GFileType of the file and #G_FILE_TYPE_UNKNOWN if the file
+ *          does not exist
+ *
+ * Since: 2.18
+ */
+GFileType
+g_file_query_file_type (GFile *file,
+                        GFileQueryInfoFlags   flags,
+                       GCancellable *cancellable)
+{
+  GFileInfo *info;
+  GFileType file_type;
+  
+  g_return_val_if_fail (G_IS_FILE(file), FALSE);
+  info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_TYPE, flags,
+                           cancellable, NULL);
+  if (info != NULL)
+    {
+      file_type = g_file_info_get_file_type (info);
+      g_object_unref (info);
+    }
+  else
+    file_type = G_FILE_TYPE_UNKNOWN;
+  
+  return file_type;
+}
+
+/**
  * g_file_query_info:
  * @file: input #GFile.
  * @attributes: an attribute query string.
index a67b72e..d93fe67 100644 (file)
@@ -646,6 +646,9 @@ GFileOutputStream *     g_file_replace_finish             (GFile
                                                           GError                    **error);
 gboolean                g_file_query_exists               (GFile                      *file,
                                                           GCancellable               *cancellable);
+GFileType               g_file_query_file_type            (GFile                      *file,
+                                                           GFileQueryInfoFlags         flags,
+                                                           GCancellable               *cancellable);
 GFileInfo *             g_file_query_info                 (GFile                      *file,
                                                           const char                 *attributes,
                                                           GFileQueryInfoFlags         flags,
index 9f8de2f..618f94e 100644 (file)
@@ -252,6 +252,7 @@ g_file_query_exists
 g_file_query_info
 g_file_query_info_async
 g_file_query_info_finish
+g_file_query_file_type
 g_file_query_filesystem_info
 g_file_query_filesystem_info_async
 g_file_query_filesystem_info_finish