From 4eae6dfbc59d0a0062e3c31fd11e2ed353bc9974 Mon Sep 17 00:00:00 2001 From: Lutz Mueller Date: Sun, 10 Feb 2002 13:48:14 +0000 Subject: [PATCH] =?UTF-8?q?2002-02-10=20=20Lutz=20M=EF=BF=BDller=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * frontends/command-line/actions.[c,h]: * frontends/command-line/main.c: Implement --show-info. git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@4123 67ed7778-7388-44ab-90cf-0a291f65f57c --- ChangeLog | 5 +++ frontends/command-line/actions.c | 76 ++++++++++++++++++++++++++++++++ frontends/command-line/actions.h | 1 + frontends/command-line/main.c | 17 +++++++ 4 files changed, 99 insertions(+) diff --git a/ChangeLog b/ChangeLog index 695e0e7b5..e3fcda755 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-02-10 Lutz Müller + + * frontends/command-line/actions.[c,h]: + * frontends/command-line/main.c: Implement --show-info. + 2002-02-09 Fredrik * frontends/command-line/foreach.c: Fix bug where new diff --git a/frontends/command-line/actions.c b/frontends/command-line/actions.c index 56e8a2633..668aef62c 100644 --- a/frontends/command-line/actions.c +++ b/frontends/command-line/actions.c @@ -128,6 +128,82 @@ list_files_action (const char *folder) return (GP_OK); } +int +print_info_action (const char *folder, const char *filename) +{ + CameraFileInfo info; + + CR (gp_camera_file_get_info (glob_camera, folder, filename, &info, + glob_context)); + + printf (_("Information on file '%s' (folder '%s'):\n"), + filename, folder); + printf (_("File:\n")); + if (info.file.fields == GP_FILE_INFO_NONE) + printf (_(" None available.\n")); + else { + if (info.file.fields & GP_FILE_INFO_NAME) + printf (_(" Name: '%s'\n"), info.file.name); + if (info.file.fields & GP_FILE_INFO_TYPE) + printf (_(" Mime type: '%s'\n"), info.file.type); + if (info.file.fields & GP_FILE_INFO_SIZE) + printf (_(" Size: %i byte(s)\n"), info.file.size); + if (info.file.fields & GP_FILE_INFO_WIDTH) + printf (_(" Width: %i pixel(s)\n"), info.file.width); + if (info.file.fields & GP_FILE_INFO_HEIGHT) + printf (_(" Height: %i pixel(s)\n"), info.file.height); + if (info.file.fields & GP_FILE_INFO_STATUS) + printf (_(" Downloaded: %s\n"), + (info.file.status == GP_FILE_STATUS_DOWNLOADED) ? _("yes") : _("no")); + if (info.file.fields & GP_FILE_INFO_PERMISSIONS) { + printf (_(" Permissions: ")); + if ((info.file.permissions & GP_FILE_PERM_READ) && + (info.file.permissions & GP_FILE_PERM_DELETE)) + printf (_("read/delete")); + else if (info.file.permissions & GP_FILE_PERM_READ) + printf (_("read")); + else if (info.file.permissions & GP_FILE_PERM_DELETE) + printf (_("delete")); + else + printf (_("none")); + printf ("\n"); + } + if (info.file.fields & GP_FILE_INFO_MTIME) + printf (_(" Time: %s"), + asctime (localtime (&info.file.mtime))); + } + printf (_("Thumbnail:\n")); + if (info.preview.fields == GP_FILE_INFO_NONE) + printf (_(" None available.\n")); + else { + if (info.preview.fields & GP_FILE_INFO_TYPE) + printf (_(" Mime type: '%s'\n"), info.preview.type); + if (info.preview.fields & GP_FILE_INFO_SIZE) + printf (_(" Size: %i byte(s)\n"), info.preview.size); + if (info.preview.fields & GP_FILE_INFO_WIDTH) + printf (_(" Width: %i pixel(s)\n"), info.preview.width); + if (info.preview.fields & GP_FILE_INFO_HEIGHT) + printf (_(" Height: %i pixel(s)\n"), info.preview.height); + if (info.preview.fields & GP_FILE_INFO_STATUS) + printf (_(" Downloaded: %s\n"), + (info.preview.status == GP_FILE_STATUS_DOWNLOADED) ? _("yes") : _("no")); + } + printf (_("Audio data:\n")); + if (info.audio.fields == GP_FILE_INFO_NONE) + printf (_(" None available.\n")); + else { + if (info.audio.fields & GP_FILE_INFO_TYPE) + printf (_(" Mime type: '%s'\n"), info.audio.type); + if (info.audio.fields & GP_FILE_INFO_SIZE) + printf (_(" Size: %i byte(s)\n"), info.audio.size); + if (info.audio.fields & GP_FILE_INFO_STATUS) + printf (_(" Downloaded: %s\n"), + (info.audio.status == GP_FILE_STATUS_DOWNLOADED) ? _("yes") : _("no")); + } + + return (GP_OK); +} + int print_file_action (const char *folder, const char *filename) { diff --git a/frontends/command-line/actions.h b/frontends/command-line/actions.h index e515de463..0cfbcb07c 100644 --- a/frontends/command-line/actions.h +++ b/frontends/command-line/actions.h @@ -25,6 +25,7 @@ typedef int FileAction (const char *folder, const char *filename); int print_file_action (const char *folder, const char *filename); int print_exif_action (const char *folder, const char *filename); +int print_info_action (const char *folder, const char *filename); int save_file_action (const char *folder, const char *filename); int save_thumbnail_action (const char *folder, const char *filename); int save_raw_action (const char *folder, const char *filename); diff --git a/frontends/command-line/main.c b/frontends/command-line/main.c index 7d8c4e647..1f82d087f 100644 --- a/frontends/command-line/main.c +++ b/frontends/command-line/main.c @@ -109,6 +109,7 @@ OPTION_CALLBACK(config); #ifdef HAVE_EXIF OPTION_CALLBACK(show_exif); #endif +OPTION_CALLBACK(show_info); OPTION_CALLBACK(help); OPTION_CALLBACK(version); OPTION_CALLBACK(shell); @@ -218,6 +219,7 @@ Option option[] = { #ifdef HAVE_EXIF {"", "show-exif", "range", N_("Show EXIF information"), show_exif, 0}, #endif +{"", "show-info", "range", N_("Show info"), show_info, 0}, {"", "summary", "", N_("Summary of camera status"), summary, 0}, {"", "manual", "", N_("Camera driver manual"), manual, 0}, {"", "about", "", N_("About the camera driver"), about, 0}, @@ -676,6 +678,21 @@ OPTION_CALLBACK(config) } #endif +OPTION_CALLBACK(show_info) +{ + CR (set_globals ()); + + /* + * If the user specified the file directly (and not a range), + * directly dump info. + */ + if (strchr (arg, '.')) + return (print_info_action (glob_folder, arg)); + + return (for_each_file_in_range (glob_folder, print_info_action, + glob_flags, arg)); +} + #ifdef HAVE_EXIF OPTION_CALLBACK(show_exif) {