@@ -83,9 +83,9 @@ int BlockDecompressor::decompress(uint64& inputSize)
8383 int nbFiles = 1 ;
8484 Printer log (cout);
8585 stringstream ss;
86- string str = _inputName;
87- transform (str .begin (), str .end (), str .begin (), ::toupper);
88- bool isStdIn = str == " STDIN" ;
86+ string upperInputName = _inputName;
87+ transform (upperInputName .begin (), upperInputName .end (), upperInputName .begin (), ::toupper);
88+ bool isStdIn = upperInputName == " STDIN" ;
8989
9090 if (isStdIn == false ) {
9191 vector<string> errors;
@@ -204,40 +204,7 @@ int BlockDecompressor::decompress(uint64& inputSize)
204204 _ctx.putInt (" verbosity" , _verbosity);
205205
206206 // Run the task(s)
207- if (nbFiles == 1 ) {
208- string oName = formattedOutName;
209- string iName = " STDIN" ;
210-
211-
212- if (isStdIn == true ) {
213- if (oName.length () == 0 ) {
214- oName = " STDOUT" ;
215- }
216- }
217- else {
218- iName = files[0 ].fullPath ();
219- _ctx.putLong (" fileSize" , files[0 ]._size );
220-
221- if (oName.length () == 0 ) {
222- oName = iName + " .bak" ;
223- }
224- else if ((inputIsDir == true ) && (specialOutput == false )) {
225- oName = formattedOutName + iName.substr (formattedInName.size ()) + " .bak" ;
226- }
227- }
228-
229- _ctx.putString (" inputName" , iName);
230- _ctx.putString (" outputName" , oName);
231- FileDecompressTask<FileDecompressResult> task (_ctx, _listeners);
232- FileDecompressResult fdr = task.run ();
233- res = fdr._code ;
234- read = fdr._read ;
235-
236- if (res != 0 ) {
237- cerr << fdr._errMsg << endl;
238- }
239- }
240- else {
207+ {
241208 vector<FileDecompressTask<FileDecompressResult>*> tasks;
242209 vector<int > jobsPerTask (nbFiles);
243210 Global::computeJobsPerTask (jobsPerTask.data (), _jobs, nbFiles);
@@ -247,12 +214,24 @@ int BlockDecompressor::decompress(uint64& inputSize)
247214 for (int i = 0 ; i < nbFiles; i++) {
248215 string oName = formattedOutName;
249216 string iName = files[i].fullPath ();
217+ upperInputName = iName;
218+ transform (upperInputName.begin (), upperInputName.end (), upperInputName.begin (), ::toupper);
250219
251220 if (oName.length () == 0 ) {
252- oName = iName + " .bak" ;
221+ oName = iName;
222+
223+ if ((upperInputName.length () >= 4 ) && (upperInputName.substr (upperInputName.length () - 4 ) == " .KNZ" ))
224+ oName.resize (oName.length () - 4 );
225+ else
226+ oName = oName + " .bak" ;
253227 }
254228 else if ((inputIsDir == true ) && (specialOutput == false )) {
255- oName = formattedOutName + iName.substr (formattedInName.size ()) + " .bak" ;
229+ oName = formattedOutName + iName.substr (formattedInName.size ());
230+
231+ if ((upperInputName.length () >= 4 ) && (upperInputName.substr (upperInputName.length () - 4 ) == " .KNZ" ))
232+ oName.resize (oName.length () - 4 );
233+ else
234+ oName = oName + " .bak" ;
256235 }
257236
258237 Context taskCtx (_ctx);
0 commit comments