Files
libgphoto2/frontends/command-line/actions.c
Lutz Mueller 3d950c6be6 2001-08-25 Lutz M�ller <urc8@rz.uni-karlsruhe.de>
* include/gphoto2-file.h:
        * include/gphoto2-library.h:
        * include/gphoto2-camera.h: Support for raw data.
        * libpghoto2/file.c: Adjust to above changes.
        * libgphoto2/frontend.c: Kill a warning.
        * libgphoto2/libgphoto-2.0.pc.in: CFlags -> Cflags
        * libgphoto2/widget.c: Include gphoto2-result.h instead of gphoto2.h
        * camlibs/*: Prepare support for download of raw data. Remove lots of
        redundant code (people just copied & pasted the code for file_get
        and file_get_preview...). I hope everything works as it did before.
        * frontend/command-line/*: Prepare support for download of raw data


git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@2072 67ed7778-7388-44ab-90cf-0a291f65f57c
2001-08-25 18:14:25 +00:00

88 lines
2.3 KiB
C

#include <string.h>
#include <stdio.h>
#include "main.h"
#include "actions.h"
#include "globals.h"
/* Folder actions */
/* ------------------------------------------------------------ */
int print_folder(char *subfolder, image_action action, int reverse) {
/* print paths relative to glob_folder */
char *c;
c = subfolder + strlen(glob_folder);
if (*c == '/')
c++;
printf("\"%s\"\n", c);
return (GP_OK);
}
int print_files(char *subfolder, image_action iaction, int reverse) {
CameraList filelist;
int x, res;
res = gp_camera_folder_list_files (glob_camera, subfolder, &filelist);
if (res != GP_OK)
return (res);
if (glob_quiet)
printf ("%i\n", gp_list_count (&filelist));
else
printf ("Files in %s:\n", subfolder);
for (x = 0; x < gp_list_count (&filelist); x++) {
const char *name;
gp_list_get_name (&filelist, x, &name);
if (glob_quiet)
printf ("\"%s\"\n", name);
else {
CameraFileInfo info;
if (gp_camera_file_get_info(glob_camera, subfolder, name, &info) == GP_OK) {
printf("#%-5i %-27s", x+1, name);
if (info.file.fields & GP_FILE_INFO_PERMISSIONS) {
printf("%s%s",
(info.file.permissions & GP_FILE_PERM_READ) ? "r" : "-",
(info.file.permissions & GP_FILE_PERM_DELETE) ? "d" : "-");
}
if (info.file.fields & GP_FILE_INFO_SIZE)
printf(" %5d KB", (info.file.size+1023) / 1024);
if ((info.file.fields & GP_FILE_INFO_WIDTH) && + (info.file.fields & GP_FILE_INFO_HEIGHT))
printf(" %4dx%-4d", info.file.width, info.file.height);
if (info.file.fields & GP_FILE_INFO_TYPE)
printf(" %s", info.file.type);
printf("\n");
} else {
printf("#%-5i %s\n", x+1, name);
}
}
}
return (GP_OK);
}
/* File actions */
/* ------------------------------------------------------------ */
int save_picture_action(char *folder, char *filename) {
return (save_picture_to_file(folder, filename, GP_FILE_TYPE_NORMAL));
}
int save_thumbnail_action(char *folder, char *filename) {
return (save_picture_to_file(folder, filename, GP_FILE_TYPE_PREVIEW));
}
int save_raw_action(char *folder, char *filename) {
return (save_picture_to_file(folder, filename, GP_FILE_TYPE_RAW));
}
int delete_picture_action(char *folder, char *filename) {
return (gp_camera_file_delete(glob_camera, folder, filename));
}