mirror of
https://github.com/michaelrsweet/pdfio.git
synced 2026-01-15 16:30:32 +01:00
Add some guards to make sure you don't accidentally overwrite existing PDF files with testpdfio...
This commit is contained in:
12
testpdfio.c
12
testpdfio.c
@@ -507,10 +507,15 @@ do_test_file(const char *filename, // I - PDF filename
|
||||
}
|
||||
else
|
||||
{
|
||||
testEnd(true);
|
||||
|
||||
if (outfile)
|
||||
{
|
||||
if (!access(outfile, 0))
|
||||
{
|
||||
testEndMessage(false, "output file already exists");
|
||||
pdfioFileClose(pdf);
|
||||
return (1);
|
||||
}
|
||||
|
||||
// Copy pages to the output file...
|
||||
if ((outpdf = pdfioFileCreate(outfile, pdfioFileGetVersion(pdf), /*media_box*/NULL, /*crop_box*/NULL, (pdfio_error_cb_t)error_cb, &error)) != NULL)
|
||||
{
|
||||
@@ -524,6 +529,7 @@ do_test_file(const char *filename, // I - PDF filename
|
||||
}
|
||||
|
||||
pdfioFileClose(outpdf);
|
||||
testEnd(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -532,7 +538,7 @@ do_test_file(const char *filename, // I - PDF filename
|
||||
num_objs = pdfioFileGetNumObjs(pdf);
|
||||
num_pages = pdfioFileGetNumPages(pdf);
|
||||
|
||||
printf(" PDF %s, %d pages, %d objects.\n", pdfioFileGetVersion(pdf), (int)num_pages, (int)num_objs);
|
||||
testEndMessage(true, "PDF %s, %d pages, %d objects", pdfioFileGetVersion(pdf), (int)num_pages, (int)num_objs);
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user