[glib/filechooserentry: 9/10] localfileinfo: Split out attributes that don't need a stat
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/filechooserentry: 9/10] localfileinfo: Split out attributes that don't need a stat
- Date: Tue, 8 Nov 2011 12:34:42 +0000 (UTC)
commit 8bb63f9cd2533c458b76a2b13ccf232115571555
Author: Benjamin Otte <otte redhat com>
Date: Tue Nov 1 23:37:35 2011 +0100
localfileinfo: Split out attributes that don't need a stat
This will be used in the next commit.
gio/glocalfileinfo.c | 80 +++++++++++++++++++++++++++----------------------
gio/glocalfileinfo.h | 10 ++++++
2 files changed, 54 insertions(+), 36 deletions(-)
---
diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c
index f3cefe4..583d962 100644
--- a/gio/glocalfileinfo.c
+++ b/gio/glocalfileinfo.c
@@ -1406,6 +1406,49 @@ win32_get_file_user_info (const gchar *filename,
}
#endif /* G_OS_WIN32 */
+void
+_g_local_file_info_get_nostat (GFileInfo *info,
+ const char *basename,
+ const char *path,
+ GFileAttributeMatcher *attribute_matcher)
+{
+ g_file_info_set_name (info, basename);
+
+ if (_g_file_attribute_matcher_matches_id (attribute_matcher,
+ G_FILE_ATTRIBUTE_ID_STANDARD_DISPLAY_NAME))
+ {
+ char *display_name = g_filename_display_basename (path);
+
+ /* look for U+FFFD REPLACEMENT CHARACTER */
+ if (strstr (display_name, "\357\277\275") != NULL)
+ {
+ char *p = display_name;
+ display_name = g_strconcat (display_name, _(" (invalid encoding)"), NULL);
+ g_free (p);
+ }
+ g_file_info_set_display_name (info, display_name);
+ g_free (display_name);
+ }
+
+ if (_g_file_attribute_matcher_matches_id (attribute_matcher,
+ G_FILE_ATTRIBUTE_ID_STANDARD_EDIT_NAME))
+ {
+ char *edit_name = g_filename_display_basename (path);
+ g_file_info_set_edit_name (info, edit_name);
+ g_free (edit_name);
+ }
+
+
+ if (_g_file_attribute_matcher_matches_id (attribute_matcher,
+ G_FILE_ATTRIBUTE_ID_STANDARD_COPY_NAME))
+ {
+ char *copy_name = g_filename_to_utf8 (basename, -1, NULL, NULL, NULL);
+ if (copy_name)
+ _g_file_info_set_attribute_string_by_id (info, G_FILE_ATTRIBUTE_ID_STANDARD_COPY_NAME, copy_name);
+ g_free (copy_name);
+ }
+}
+
GFileInfo *
_g_local_file_info_get (const char *basename,
const char *path,
@@ -1435,9 +1478,8 @@ _g_local_file_info_get (const char *basename,
/* Make sure we don't set any unwanted attributes */
g_file_info_set_attribute_mask (info, attribute_matcher);
- g_file_info_set_name (info, basename);
+ _g_local_file_info_get_nostat (info, basename, path, attribute_matcher);
- /* Avoid stat in trivial case */
if (attribute_matcher == NULL)
{
g_file_info_unset_attribute_mask (info);
@@ -1558,40 +1600,6 @@ _g_local_file_info_get (const char *basename,
}
#endif
if (_g_file_attribute_matcher_matches_id (attribute_matcher,
- G_FILE_ATTRIBUTE_ID_STANDARD_DISPLAY_NAME))
- {
- char *display_name = g_filename_display_basename (path);
-
- /* look for U+FFFD REPLACEMENT CHARACTER */
- if (strstr (display_name, "\357\277\275") != NULL)
- {
- char *p = display_name;
- display_name = g_strconcat (display_name, _(" (invalid encoding)"), NULL);
- g_free (p);
- }
- g_file_info_set_display_name (info, display_name);
- g_free (display_name);
- }
-
- if (_g_file_attribute_matcher_matches_id (attribute_matcher,
- G_FILE_ATTRIBUTE_ID_STANDARD_EDIT_NAME))
- {
- char *edit_name = g_filename_display_basename (path);
- g_file_info_set_edit_name (info, edit_name);
- g_free (edit_name);
- }
-
-
- if (_g_file_attribute_matcher_matches_id (attribute_matcher,
- G_FILE_ATTRIBUTE_ID_STANDARD_COPY_NAME))
- {
- char *copy_name = g_filename_to_utf8 (basename, -1, NULL, NULL, NULL);
- if (copy_name)
- _g_file_info_set_attribute_string_by_id (info, G_FILE_ATTRIBUTE_ID_STANDARD_COPY_NAME, copy_name);
- g_free (copy_name);
- }
-
- if (_g_file_attribute_matcher_matches_id (attribute_matcher,
G_FILE_ATTRIBUTE_ID_STANDARD_CONTENT_TYPE) ||
_g_file_attribute_matcher_matches_id (attribute_matcher,
G_FILE_ATTRIBUTE_ID_STANDARD_ICON))
diff --git a/gio/glocalfileinfo.h b/gio/glocalfileinfo.h
index 82ad746..bb711a2 100644
--- a/gio/glocalfileinfo.h
+++ b/gio/glocalfileinfo.h
@@ -50,12 +50,22 @@ typedef struct
#define GLocalFileStat struct stat
#endif
+#define G_LOCAL_FILE_INFO_NOSTAT_ATTRIBUTES \
+ G_FILE_ATTRIBUTE_STANDARD_NAME "," \
+ G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME "," \
+ G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME "," \
+ G_FILE_ATTRIBUTE_STANDARD_COPY_NAME
+
gboolean _g_local_file_has_trash_dir (const char *dirname,
dev_t dir_dev);
void _g_local_file_info_get_parent_info (const char *dir,
GFileAttributeMatcher *attribute_matcher,
GLocalParentFileInfo *parent_info);
void _g_local_file_info_free_parent_info (GLocalParentFileInfo *parent_info);
+void _g_local_file_info_get_nostat (GFileInfo *info,
+ const char *basename,
+ const char *path,
+ GFileAttributeMatcher *attribute_matcher);
GFileInfo *_g_local_file_info_get (const char *basename,
const char *path,
GFileAttributeMatcher *attribute_matcher,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]