2002-02-26 Lutz M�ller <lutz@users.sourceforge.net>

* frontends/command-line/foreach.c (for_each_file_in_range): If
          deleting files not recursively, adjust the image ID for subsequent
          images.
        * frontends/commane-line/main.c (main): If deleting files, do
          it in reverse order such that above case does never occur. Fixes
          #522796.


git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@4225 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
Lutz Mueller
2002-02-26 10:09:17 +00:00
parent 4feddd7a49
commit 2e0c520799
3 changed files with 38 additions and 5 deletions

View File

@@ -1,3 +1,12 @@
2002-02-26 Lutz Müller <lutz@users.sourceforge.net>
* frontends/command-line/foreach.c (for_each_file_in_range): If
deleting files not recursively, adjust the image ID for subsequent
images.
* frontends/commane-line/main.c (main): If deleting files, do
it in reverse order such that above case does never occur. Fixes
#522796.
2002-02-26 Lutz Müller <lutz@users.sourceforge.net>
* frontends/command-line/shell.c: Patch from Rob Hillis

View File

@@ -273,14 +273,27 @@ for_each_file_in_range (const char *folder, FileAction action,
(unsigned int) i, ffolder, ffile));
CR (action (ffolder, ffile));
}
} else
for (i = 0; i <= max; i++)
} else {
unsigned int count;
/*
* File deletion modifies the CameraFilesystem. Therefore
* the IDs of subsequent images change. This only affects us
* if not deleting reversely. This is the case here and we need
* to adjust the image IDs after a successful deletion.
*/
for (count = i = 0; i <= max; i++)
if (index[i]) {
GP_DEBUG ("Now processing ID %i...", i);
GP_DEBUG ("Now processing ID %i "
"(originally %i)...", i - count, i);
CR (get_path_for_id (folder, flags,
(unsigned int) i, ffolder, ffile));
(unsigned int) i - count,
ffolder, ffile));
CR (action (ffolder, ffile));
if (action == delete_file_action)
count++;
}
}
return (GP_OK);
}

View File

@@ -978,7 +978,7 @@ OPTION_CALLBACK (delete_file)
return (delete_file_action (glob_folder, arg));
return for_each_file_in_range (glob_folder, delete_file_action,
glob_flags, arg);
glob_flags, arg);
}
OPTION_CALLBACK (delete_all_files)
@@ -1666,6 +1666,17 @@ e.g. SET IOLIBS=C:\\GPHOTO2\\IOLIB\n"));
glob_flags &= ~FOR_EACH_FLAGS_RECURSE;
}
/*
* If we delete single files, do it in the reverse order. It should
* work the other way, too, but one never knows...
*/
if ((option_is_present ("delete-file", argc, argv) == GP_OK) ||
(option_is_present ("d", argc, argv) == GP_OK))
glob_flags |= FOR_EACH_FLAGS_REVERSE;
else
glob_flags &= ~FOR_EACH_FLAGS_REVERSE;
/* Now actually do something. */
result = execute_options (argc, argv);
if (result < 0) {
switch (result) {