7
7
#include < QMessageBox>
8
8
9
9
#include < QString>
10
+ #include < QFile>
10
11
#include < QStringList>
11
12
#include < QDomDocument>
12
13
#include < QDebug>
@@ -86,10 +87,10 @@ inline QString getItarzoomPlaneData(const QString& path, ZoomData& data, QJsonAr
86
87
}
87
88
88
89
inline QString deepZoom (QString inputFolder, QString output, uint32_t quality, uint32_t overlap,
89
- uint32_t tileSize, std::function<bool (QString s, int n)> progressed)
90
- {
90
+ uint32_t tileSize, std::function<bool (QString s, int n)> progressed) {
91
91
int nplanes = getNFiles (inputFolder, " jpg" );
92
92
93
+ bool remove = true ;
93
94
94
95
// Deep zoom every plane
95
96
for (int plane = 0 ; plane < nplanes; plane++)
@@ -100,6 +101,8 @@ inline QString deepZoom(QString inputFolder, QString output, uint32_t quality, u
100
101
dz.quality = quality;
101
102
dz.build (fileName, output + " /" + QString (" plane_%1" ).arg (plane), tileSize, overlap);
102
103
104
+ if (remove )
105
+ QFile::remove (fileName);
103
106
// Update progress bar
104
107
if (!progressed (" Deepzoom:" , 100 *(plane+1 )/nplanes))
105
108
break ;
@@ -108,8 +111,9 @@ inline QString deepZoom(QString inputFolder, QString output, uint32_t quality, u
108
111
return " OK" ;
109
112
}
110
113
111
- inline QString tarZoom (QString inputFolder, QString output, std::function<bool (QString s, int n)> progressed)
112
- {
114
+ inline QString tarZoom (QString inputFolder, QString output, std::function<bool (QString s, int n)> progressed) {
115
+ bool remove = true ;
116
+
113
117
// Find number of planes
114
118
int nPlanes = getNFiles (inputFolder, " dzi" );
115
119
if (nPlanes == 0 )
@@ -213,6 +217,11 @@ inline QString tarZoom(QString inputFolder, QString output, std::function<bool(Q
213
217
outIndexFile.write (QJsonDocument (index ).toJson ());
214
218
outIndexFile.close ();
215
219
220
+ if (remove ) {
221
+ QFile::remove (dziPath);
222
+ planeFolder.removeRecursively ();
223
+ }
224
+
216
225
// Update progress bar
217
226
if (!progressed (" Tarzoom:" , 100 *(i+1 )/nPlanes))
218
227
break ;
@@ -223,6 +232,8 @@ inline QString tarZoom(QString inputFolder, QString output, std::function<bool(Q
223
232
224
233
inline QString itarZoom (const QString& inputFolder, const QString& output, std::function<bool (QString s, int n)> progressed)
225
234
{
235
+ bool remove = true ;
236
+
226
237
// Find number of planes
227
238
int nPlanes = getNFiles (inputFolder, " tzb" );
228
239
if (nPlanes == 0 )
@@ -272,7 +283,8 @@ inline QString itarZoom(const QString& inputFolder, const QString& output, std::
272
283
std::deque<uint32_t > sizes;
273
284
274
285
// Get tzi data
275
- QString err = getItarzoomPlaneData (QString (" %1/plane_%2.tzi" ).arg (inputFolder).arg (i), data, offsets);
286
+ QString tzi_path = QString (" %1/plane_%2.tzi" ).arg (inputFolder).arg (i);
287
+ QString err = getItarzoomPlaneData (tzi_path, data, offsets);
276
288
if (err.compare (" OK" ) != 0 )
277
289
return err;
278
290
@@ -295,11 +307,15 @@ inline QString itarZoom(const QString& inputFolder, const QString& output, std::
295
307
}
296
308
297
309
// Append file to final tzb
298
- QString tzbPath = QString (" %1/plane_%2.tzb" ).arg (inputFolder).arg (i);
299
- files.push_back (new QFile (tzbPath ));
310
+ QString tzb_path = QString (" %1/plane_%2.tzb" ).arg (inputFolder).arg (i);
311
+ files.push_back (new QFile (tzb_path ));
300
312
if (!files[i]->open (QIODevice::ReadOnly))
301
313
return QString (" Error while opening .tzb file %1" ).arg (files[i]->fileName ());
302
314
315
+ if (remove ) {
316
+ QFile::remove (tzi_path);
317
+ }
318
+
303
319
// Update progress bar
304
320
if (!progressed (" Itarzoom:" , 50 *(i+1 )/nPlanes))
305
321
break ;
@@ -329,8 +345,11 @@ inline QString itarZoom(const QString& inputFolder, const QString& output, std::
329
345
outIndexFile.close ();
330
346
331
347
// Clean file pointers
332
- for (QFile *file: files)
348
+ for (QFile *file: files) {
349
+ file->remove ();
333
350
delete file;
351
+ }
352
+
334
353
335
354
return " OK" ;
336
355
}
0 commit comments