summaryrefslogtreecommitdiff
path: root/camlibs/digita
diff options
context:
space:
mode:
authorJohannes Erdfelt <johannes@erdfelt.com>2002-04-10 06:33:58 +0000
committerJohannes Erdfelt <johannes@erdfelt.com>2002-04-10 06:33:58 +0000
commit29e1050fb2b276e28febc961a5ab22f1d4164f50 (patch)
tree87d827220d8025ae4de4cc5f5d98ed3d42170864 /camlibs/digita
parent57a4607dfae6196853d1272abe4117282c7986cc (diff)
downloadlibgphoto2-29e1050fb2b276e28febc961a5ab22f1d4164f50.tar.gz
Add proper delete support
While I rewrote much of it to match the rest of the code, the original code and legwork was done by Marr <marr@shianet.org> git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@4410 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'camlibs/digita')
-rw-r--r--camlibs/digita/commands.c3
-rw-r--r--camlibs/digita/digita.c38
-rw-r--r--camlibs/digita/digita.h2
3 files changed, 25 insertions, 18 deletions
diff --git a/camlibs/digita/commands.c b/camlibs/digita/commands.c
index 90336ce69..0a6f34040 100644
--- a/camlibs/digita/commands.c
+++ b/camlibs/digita/commands.c
@@ -192,9 +192,10 @@ int digita_delete_picture(CameraPrivateLibrary *dev, struct filename *filename)
struct digita_command response;
int ret;
- build_command(&ef.cmd, sizeof(ef) - sizeof(ef.cmd), DIGITA_ERASE_FILE);
+ build_command(&ef.cmd, sizeof(ef.fn), DIGITA_ERASE_FILE);
memcpy(&ef.fn, filename, sizeof(ef.fn));
+ ef.zero = 0;
ret = dev->send(dev, (unsigned char *)&ef, sizeof(ef));
if (ret < 0) {
diff --git a/camlibs/digita/digita.c b/camlibs/digita/digita.c
index 4b45ed709..ee0cab388 100644
--- a/camlibs/digita/digita.c
+++ b/camlibs/digita/digita.c
@@ -399,24 +399,17 @@ static int camera_about(Camera *camera, CameraText *about, GPContext *context)
return GP_OK;
}
-#if 0
-static int delete_picture(int index)
+static int digita_file_delete(Camera *camera, const char *folder,
+ const char *filename, GPContext *context)
{
struct filename fn;
- fprintf(stderr, "digita_delete_picture\n");
-
- if (index > digita_num_pictures)
- return 0;
-
- index--;
-
- fprintf(stderr, "deleting %d, %s%s\n", index, digita_file_list[index].fn.path, digita_file_list[index].fn.dosname);
-
/* Setup the filename */
- fn.driveno = digita_file_list[index].fn.driveno;
- strcpy(fn.path, digita_file_list[index].fn.path);
- strcpy(fn.dosname, digita_file_list[index].fn.dosname);
+ /* FIXME: This is kinda lame, but it's a quick hack */
+ fn.driveno = camera->pl->file_list[0].fn.driveno;
+ strcpy(fn.path, folder);
+ strcat(fn.path, "/");
+ strcpy(fn.dosname, filename);
if (digita_delete_picture(camera->pl, &fn) < 0)
return 0;
@@ -424,9 +417,19 @@ static int delete_picture(int index)
if (digita_get_file_list(camera->pl) < 0)
return 0;
- return 1;
+ return GP_OK;
+}
+
+static int delete_file_func(CameraFilesystem *fs, const char *folder,
+ const char *filename, void *user_data, GPContext *context)
+{
+ Camera *camera = user_data;
+
+ if (folder[0] == '/')
+ folder++;
+
+ return digita_file_delete(camera, folder, filename, context);
}
-#endif
int camera_init(Camera *camera, GPContext *context)
{
@@ -443,7 +446,8 @@ int camera_init(Camera *camera, GPContext *context)
/* Set up the CameraFilesystem */
gp_filesystem_set_list_funcs(camera->fs, file_list_func,
folder_list_func, camera);
- gp_filesystem_set_file_funcs(camera->fs, get_file_func, NULL, camera);
+ gp_filesystem_set_file_funcs(camera->fs, get_file_func,
+ delete_file_func, camera);
GP_DEBUG( "Initializing the camera");
diff --git a/camlibs/digita/digita.h b/camlibs/digita/digita.h
index 0a51c23b7..3e1100d18 100644
--- a/camlibs/digita/digita.h
+++ b/camlibs/digita/digita.h
@@ -130,6 +130,8 @@ struct erase_file {
struct digita_command cmd;
struct filename fn;
+
+ unsigned int zero;
};
/* gphoto2 header magic. this is also CameraPrivateLibrary */