From: Colin Clark Date: Fri, 6 Jul 2018 18:44:10 +0000 (+0100) Subject: Additional file info parameters X-Git-Tag: v1.5~112 X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=commitdiff_plain;h=d0881f5739d27cf544ca62c85cac2ac381003d49 Additional file info parameters Additional parameters which can be displayed in the info sidebar or overlay screen display: file owner (file.owner) file group (file.group) file class (file.class) e.g. RAW image etc. file symbolic link (file.link) --- diff --git a/src/exif-common.c b/src/exif-common.c index e07058c4..55455e08 100644 --- a/src/exif-common.c +++ b/src/exif-common.c @@ -888,6 +888,10 @@ ExifFormattedText ExifFormattedList[] = { {"file.date", N_("File date"), NULL}, {"file.mode", N_("File mode"), NULL}, {"file.ctime", N_("File ctime"), NULL}, + {"file.owner", N_("File owner"), NULL}, + {"file.group", N_("File group"), NULL}, + {"file.link", N_("File link"), NULL}, + {"file.class", N_("File class"), NULL}, { NULL, NULL, NULL } }; @@ -1152,6 +1156,22 @@ gchar *metadata_file_info(FileData *fd, const gchar *key, MetadataFormat format) { return g_strdup(text_from_time(fd->cdate)); } + if (strcmp(key, "file.class") == 0) + { + return g_strdup(format_class_list[fd->format_class]); + } + if (strcmp(key, "file.owner") == 0) + { + return g_strdup(fd->owner); + } + if (strcmp(key, "file.group") == 0) + { + return g_strdup(fd->group); + } + if (strcmp(key, "file.link") == 0) + { + return g_strdup(fd->sym_link); + } return g_strdup(""); } diff --git a/src/filedata.c b/src/filedata.c index 876cb80f..0461755b 100644 --- a/src/filedata.c +++ b/src/filedata.c @@ -32,8 +32,10 @@ #include "secure_save.h" #include "exif.h" +#include "misc.h" #include +#include #ifdef DEBUG_FILEDATA gint global_file_data_count = 0; @@ -370,6 +372,8 @@ static void file_data_set_path(FileData *fd, const gchar *path) static FileData *file_data_new(const gchar *path_utf8, struct stat *st, gboolean disable_sidecars) { FileData *fd; + struct passwd *user; + struct group *group; DEBUG_2("file_data_new: '%s' %d", path_utf8, disable_sidecars); @@ -432,6 +436,28 @@ static FileData *file_data_new(const gchar *path_utf8, struct stat *st, gboolean fd->rating = STAR_RATING_NOT_READ; fd->format_class = filter_file_get_class(path_utf8); + user = getpwuid(st->st_uid); + if (!user) + { + fd->owner = g_strdup_printf("%u", st->st_uid); + } + else + { + fd->owner = g_strdup(user->pw_name); + } + + group = getgrgid(st->st_gid); + if (!group) + { + fd->group = g_strdup_printf("%u", st->st_gid); + } + else + { + fd->group = g_strdup(group->gr_name); + } + + fd->sym_link = get_symbolic_link(path_utf8); + if (disable_sidecars) fd->disable_grouping = TRUE; file_data_set_path(fd, path_utf8); /* set path, name, collate_key_*, original_path */ @@ -681,7 +707,9 @@ static void file_data_free(FileData *fd) g_free(fd->extended_extension); if (fd->thumb_pixbuf) g_object_unref(fd->thumb_pixbuf); histmap_free(fd->histmap); - + g_free(fd->owner); + g_free(fd->group); + g_free(fd->sym_link); g_assert(fd->sidecar_files == NULL); /* sidecar files must be freed before calling this */ file_data_change_info_free(NULL, fd); diff --git a/src/misc.c b/src/misc.c index 70b01efa..d780795d 100644 --- a/src/misc.c +++ b/src/misc.c @@ -323,4 +323,37 @@ gchar *convert_rating_to_stars(gint rating) return ret; } +gchar *get_symbolic_link(const gchar *path_utf8) +{ + gchar *sl; + struct stat st; + gchar *ret = g_strdup(""); + + sl = path_from_utf8(path_utf8); + + if (lstat(sl, &st) == 0 && S_ISLNK(st.st_mode)) + { + gchar *buf; + gint l; + + buf = g_malloc(st.st_size + 1); + l = readlink(sl, buf, st.st_size); + + if (l == st.st_size) + { + buf[l] = '\0'; + + ret = buf; + } + else + { + g_free(buf); + } + } + + g_free(sl); + + return ret; +} + /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ diff --git a/src/misc.h b/src/misc.h index 103f6a6e..1071062f 100644 --- a/src/misc.h +++ b/src/misc.h @@ -30,5 +30,6 @@ gchar *decode_geo_parameters(const gchar *input_text); gint date_get_first_day_of_week(); gchar *date_get_abbreviated_day_name(gint day); gchar *convert_rating_to_stars(gint rating); +gchar *get_symbolic_link(const gchar *path_utf8); #endif /* MISC_H */ /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ diff --git a/src/typedefs.h b/src/typedefs.h index 7137f4ee..b23e5750 100644 --- a/src/typedefs.h +++ b/src/typedefs.h @@ -598,6 +598,10 @@ struct _FileData { gint rating; gboolean metadata_in_idle_loaded; + gchar *owner; + gchar *group; + gchar *sym_link; + SelectionType selected; // Used by view_file_icon. }; diff --git a/web/help/GuideSidebarsInfo.html b/web/help/GuideSidebarsInfo.html index b8d709eb..02c64b1c 100644 --- a/web/help/GuideSidebarsInfo.html +++ b/web/help/GuideSidebarsInfo.html @@ -734,8 +734,24 @@ dd.answer div.label { float: left; } file mode flags -file.ctime -refer to operating system documentation for the meaning of ctime +file.ctime +refer to operating system documentation for the meaning of ctime + + +file.owner +the file's owner. Refer to operating system documentation for the meaning of file permissions + + +file.group +the file's group. Refer to operating system documentation for the meaning of file permissions + + +file.class +the file's class e.g. Image, RAW image etc. + + +file.link +if the file is a symbolic link, shows the path of the source file