From: Matthias Clasen Date: Mon, 31 Mar 2008 04:46:22 +0000 (+0000) Subject: Add g_file_query_file_type convenience function to query the type of a X-Git-Tag: GLIB_2_17_0~116 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a07b747200e1b6ffad8a9cadf1d6dce5d89d6eac;p=platform%2Fupstream%2Fglib.git Add g_file_query_file_type convenience function to query the type of a 2008-03-30 Matthias Clasen * 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 --- diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index e0030fb..b932bdd 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,4 +1,8 @@ 2008-03-30 Matthias Clasen + + * gio/gio-sections.txt: Add g_file_query_file_type. + +2008-03-30 Matthias Clasen * glib/glib-sections.txt: * glib/tmpl/macros-misc.sgml: Document G_GNUC_ALLOC_SIZE diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt index 6e111ed..abce363 100644 --- a/docs/reference/gio/gio-sections.txt +++ b/docs/reference/gio/gio-sections.txt @@ -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 diff --git a/gio/ChangeLog b/gio/ChangeLog index 2cdebd2..52e0bc7 100644 --- a/gio/ChangeLog +++ b/gio/ChangeLog @@ -1,5 +1,12 @@ 2008-03-30 Matthias Clasen + * 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 + * gfileenumerator.c: * gfile.c: Fix some documentation typos. (#524950, Rob Bradford) diff --git a/gio/gfile.c b/gio/gfile.c index b15167d..e881554 100644 --- a/gio/gfile.c +++ b/gio/gfile.c @@ -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. diff --git a/gio/gfile.h b/gio/gfile.h index a67b72e..d93fe67 100644 --- a/gio/gfile.h +++ b/gio/gfile.h @@ -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, diff --git a/gio/gio.symbols b/gio/gio.symbols index 9f8de2f..618f94e 100644 --- a/gio/gio.symbols +++ b/gio/gio.symbols @@ -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