Don't create and delete a file in batch mode if the document feeder is empty or

if CTRL-D is pressed in prompt mode. This change avoids deleting existing
files. For an explanation, see bug #302797.
merge-requests/1/head
Henning Geinitz 2006-01-02 23:00:23 +00:00
rodzic 7b03fc2168
commit 56ba575749
2 zmienionych plików z 29 dodań i 11 usunięć

Wyświetl plik

@ -16,6 +16,10 @@
doc/sane-test.man doc/descriptions/test.desc: doc/sane-test.man doc/descriptions/test.desc:
Added option "source" which can be used to simulate an Automatic Added option "source" which can be used to simulate an Automatic
Document Feeder (ADF). Added copyright header to test.h. Document Feeder (ADF). Added copyright header to test.h.
* frontend/scanimage.c: Don't create and delete a file in batch
mode if the document feeder is empty or if CTRL-D is pressed in
prompt mode. This change avoids deleting existing files. For an
explanation, see bug #302797.
2006-01-01 Oliver Schwartz <Oliver.Schwartz@gmx.de> 2006-01-01 Oliver Schwartz <Oliver.Schwartz@gmx.de>

Wyświetl plik

@ -1143,12 +1143,15 @@ scan_it (void)
do do
{ {
status = sane_start (device); if (!first_frame)
if (status != SANE_STATUS_GOOD)
{ {
fprintf (stderr, "%s: sane_start: %s\n", status = sane_start (device);
prog_name, sane_strstatus (status)); if (status != SANE_STATUS_GOOD)
goto cleanup; {
fprintf (stderr, "%s: sane_start: %s\n",
prog_name, sane_strstatus (status));
goto cleanup;
}
} }
status = sane_get_parameters (device, &parm); status = sane_get_parameters (device, &parm);
@ -2114,11 +2117,6 @@ List of available devices:", prog_name);
if (batch) /* format is NULL unless batch mode */ if (batch) /* format is NULL unless batch mode */
sprintf (path, format, n); /* love --(C++) */ sprintf (path, format, n); /* love --(C++) */
if (batch && NULL == freopen (path, "w", stdout))
{
fprintf (stderr, "cannot open %s\n", path);
return SANE_STATUS_ACCESS_DENIED;
}
if (batch) if (batch)
{ {
@ -2135,12 +2133,28 @@ List of available devices:", prog_name);
fprintf (stderr, "Batch terminated, %d pages scanned\n", fprintf (stderr, "Batch terminated, %d pages scanned\n",
(n - batch_increment)); (n - batch_increment));
fclose (stdout); fclose (stdout);
unlink (path);
break; /* get out of this loop */ break; /* get out of this loop */
} }
} }
fprintf (stderr, "Scanning page %d\n", n); fprintf (stderr, "Scanning page %d\n", n);
} }
status = sane_start (device);
if (status != SANE_STATUS_GOOD)
{
fprintf (stderr, "%s: sane_start: %s\n",
prog_name, sane_strstatus (status));
fclose (stdout);
break;
}
if (batch && NULL == freopen (path, "w", stdout))
{
fprintf (stderr, "cannot open %s\n", path);
sane_cancel (device);
return SANE_STATUS_ACCESS_DENIED;
}
status = scan_it (); status = scan_it ();
if (batch) if (batch)
{ {