1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
Description: Sfftobmp does not append page index to output filenames anymore
When converting a multipage fax, sfftobmp does not append the expected
numerical page index to the output filename:
File /var/spool/capisuite/received/fax.sff seems to
have 2 page(s).
- Destination File /tmp/buschfaxtmp/fax.jpg :
Converting page 1 (1728x1140px / 203x98dpi), LowRes ...
- Destination File /tmp/buschfaxtmp/fax.jpg :
Converting page 2 (1728x1140px / 203x98dpi), LowRes ...
It ought to be (and was in prior versions):
- Destination File /tmp/buschfaxtmp/fax_001.jpg :
Converting page 1 (1728x1140px / 203x98dpi), LowRes ...
- Destination File /tmp/buschfaxtmp/fax_002.jpg :
Converting page 2 (1728x1140px / 203x98dpi), LowRes ...
The problem was identified to be associated with new behaviour introduced by
boost::filesystem V3 (version 1.49 in Wheezy and up)
Author: Peter Schaefer <peter.schaefer@gmx.de>
Debian-Bug: https://bugs.debian.org/734805
Last-Update: 2014-06-04
@@ -38,6 +38,8 @@
#include <cassert>
#include <vector>
#include <iostream>
+#include <sstream>
+#include <iomanip>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
@@ -71,6 +73,7 @@
fs::path pathInFileName;
fs::path pathOutFileName;
fs::path pathOutDirectory;
+ stringstream ssFilename;
CCmdLineProcessor proc(argv, argc);
@@ -116,7 +119,6 @@
{
COutputFilter *pOut = NULL;
CSffFile *pInfile = NULL;
- char acNumber[10];
try
{
@@ -172,32 +174,32 @@
if (pathOutFileName.string().length()) {
// A fixed name was given, so use it as a base name
outPath = pathOutFileName;
- std::string orgExt = fs::extension(outPath);
+ std::string orgExt = outPath.extension().generic_string();
if (nFileCountOut > 1) {
- sprintf(acNumber, "_%03d", nPage+1);
- outPath = fs::change_extension(outPath, acNumber);
- if (orgExt.length()) {
- std::string strTemp = outPath.string();
- strTemp += orgExt;
- outPath = fs::path(strTemp);
- }
+ outPath.replace_extension("");
+ ssFilename << outPath.generic_string();
+ ssFilename << "_" << setw(3) << setfill('0') << nPage+1;
+ ssFilename << orgExt;
+ outPath = fs::path(ssFilename.str());
}
} else {
// Otherwise construct output filename from input filename
- outPath = pathOutDirectory / pathInFileName.leaf();
+ outPath = pathOutDirectory / pathInFileName.filename();
if (nFileCountOut > 1) {
- sprintf(acNumber, "_%03d", nPage+1);
- outPath = fs::change_extension(outPath, acNumber);
- std::string strTemp = outPath.string();
- strTemp += pOut->GetExtension();
- outPath = fs::path(strTemp);
+ outPath.replace_extension("");
+ ssFilename << outPath.generic_string();
+ ssFilename << "_" << setw(3) << setfill('0') << nPage+1;
+ ssFilename << pOut->GetExtension();
+ outPath = fs::path(ssFilename.str());
} else {
- outPath = fs::change_extension(outPath, pOut->GetExtension());
+ outPath.replace_extension(pOut->GetExtension());
}
}
if (!proc.doOverwrite() && !((nPage > 0) && (nFileCountOut == 1)) && fs::exists(outPath)) {
throw CSimpleException(CSimpleException::err_outfileexists);
}
+ ssFilename.str("");
+ ssFilename.clear();
}
bool bIsLowRes = pInfile->IsLowRes(nPage);
|