4276 RFile theInFiles[FILECOUNTMAX]; |
4278 RFile theInFiles[FILECOUNTMAX]; |
4277 RFile theOutFiles[FILECOUNTMAX]; |
4279 RFile theOutFiles[FILECOUNTMAX]; |
4278 TInt inFileSize[FILECOUNTMAX]; |
4280 TInt inFileSize[FILECOUNTMAX]; |
4279 TInt inFilePos[FILECOUNTMAX]; |
4281 TInt inFilePos[FILECOUNTMAX]; |
4280 TBool fileOk[FILECOUNTMAX]; |
4282 TBool fileOk[FILECOUNTMAX]; |
4281 |
4283 |
4282 TInt index; |
4284 TInt index; |
4283 TFileName newPath; |
4285 TFileName newPath; |
4284 TFileName oldPath; |
4286 TFileName oldPath; |
4285 |
4287 |
4286 for (index = 0; index < FILECOUNTMAX; index ++) |
4288 for (index = 0; index < FILECOUNTMAX; index ++) |
4287 { |
4289 { |
4288 fileOk[index] = ETrue; |
4290 inFileSize[index] = 0; |
|
4291 inFilePos[index] = 0; |
|
4292 fileOk[index] = EFalse; |
|
4293 |
4289 if (index < PAGELDRTST_MAX_DLLS) |
4294 if (index < PAGELDRTST_MAX_DLLS) |
4290 { |
4295 { |
4291 oldPath.Format(_L("%S%S%d%S"), &KRomPath, &KDllBaseName, index, &TestPlExtNames[KTestMediaBase]); |
4296 oldPath.Format(_L("%S%S%d%S"), &KRomPath, &KDllBaseName, index, &TestPlExtNames[KTestMediaBase]); |
4292 newPath.Format(_L("%S%S%d%S"), &aPath, &KDllBaseName, index, &TestPlExtNames[aMediaType]); |
4297 newPath.Format(_L("%S%S%d%S"), &aPath, &KDllBaseName, index, &TestPlExtNames[aMediaType]); |
4293 } |
4298 } |
4303 } |
4308 } |
4304 |
4309 |
4305 retVal = theInFiles[index].Open(aFs, oldPath, EFileRead); |
4310 retVal = theInFiles[index].Open(aFs, oldPath, EFileRead); |
4306 if (retVal != KErrNone) |
4311 if (retVal != KErrNone) |
4307 { |
4312 { |
4308 fileOk[index] = EFalse; |
4313 DBGS_PRINT((_L("%S : Failed to open for read (%d)\n"), &oldPath, retVal)); |
4309 DBGS_PRINT((_L("%S : Failed to open (%d)\n"), &oldPath, retVal)); |
4314 break; |
|
4315 } |
|
4316 retVal = theInFiles[index].Size(inFileSize[index]); |
|
4317 if (retVal != KErrNone) |
|
4318 { |
|
4319 theInFiles[index].Close(); |
|
4320 DBGS_PRINT((_L("%S : Failed to get file size (%d)\n"), &newPath, retVal)); |
4310 break; |
4321 break; |
4311 } |
4322 } |
4312 retVal = theOutFiles[index].Replace(aFs, newPath, EFileWrite); |
4323 retVal = theOutFiles[index].Replace(aFs, newPath, EFileWrite); |
4313 if (retVal != KErrNone) |
4324 if (retVal != KErrNone) |
4314 { |
4325 { |
4315 fileOk[index] = EFalse; |
4326 theInFiles[index].Close(); |
4316 DBGS_PRINT((_L("%S : Failed to open (%d)\n"), &newPath, retVal)); |
4327 DBGS_PRINT((_L("%S : Failed to open for write (%d)\n"), &newPath, retVal)); |
4317 break; |
4328 break; |
4318 } |
4329 } |
4319 retVal = theInFiles[index].Size(inFileSize[index]); |
4330 |
4320 if (retVal != KErrNone) |
4331 fileOk[index] = ETrue; |
4321 { |
|
4322 fileOk[index] = EFalse; |
|
4323 DBGS_PRINT((_L("%S : Failed to get file size (%d)\n"), &newPath, retVal)); |
|
4324 break; |
|
4325 } |
|
4326 inFilePos[index] = 0; |
|
4327 } |
4332 } |
4328 |
4333 |
4329 const TInt KBufferSize = 3333; |
4334 const TInt KBufferSize = 3333; |
4330 TBuf8<KBufferSize> buffer; |
4335 TBuf8<KBufferSize> buffer; |
4331 |
4336 TBool stillGoing; |
4332 TBool stillGoing = ETrue; |
4337 |
4333 |
4338 do |
4334 while (stillGoing) |
|
4335 { |
4339 { |
4336 stillGoing = EFalse; |
4340 stillGoing = EFalse; |
4337 for (index = 0; index < FILECOUNTMAX; index ++) |
4341 for (index = 0; index < FILECOUNTMAX; index ++) |
4338 { |
4342 { |
4339 if (inFilePos[index] < inFileSize[index]) |
|
4340 { |
|
4341 if (fileOk[index]) |
|
4342 { |
|
4343 retVal = theInFiles[index].Read(buffer); |
|
4344 if (retVal != KErrNone) |
|
4345 { |
|
4346 DBGS_PRINT((_L("theInFiles[%d] read failed (%d)\n"), index, retVal)); |
|
4347 fileOk[index] = EFalse; |
|
4348 break; |
|
4349 } |
|
4350 retVal = theOutFiles[index].Write(buffer); |
|
4351 if (retVal != KErrNone) |
|
4352 { |
|
4353 DBGS_PRINT((_L("theOutFiles[%d] Write failed (%d)\n"), index, retVal)); |
|
4354 fileOk[index] = EFalse; |
|
4355 break; |
|
4356 } |
|
4357 retVal = theOutFiles[index].Flush(); |
|
4358 if (retVal != KErrNone) |
|
4359 { |
|
4360 DBGS_PRINT((_L("theOutFiles[%d] flush failed (%d)\n"), index, retVal)); |
|
4361 fileOk[index] = EFalse; |
|
4362 break; |
|
4363 } |
|
4364 inFilePos[index] += buffer.Length(); |
|
4365 } |
|
4366 else |
|
4367 break; |
|
4368 } |
|
4369 if ((inFilePos[index] < inFileSize[index]) && (fileOk[index])) |
|
4370 { |
|
4371 stillGoing = ETrue; |
|
4372 } |
|
4373 } |
|
4374 if (!fileOk[index]) |
4343 if (!fileOk[index]) |
4375 break; |
4344 break; |
4376 } |
4345 if (inFilePos[index] < inFileSize[index]) |
4377 |
4346 { |
4378 TBool allOk = ETrue; |
4347 retVal = theInFiles[index].Read(buffer); |
|
4348 if (retVal != KErrNone) |
|
4349 { |
|
4350 DBGS_PRINT((_L("theInFiles[%d] read failed (%d)\n"), index, retVal)); |
|
4351 break; |
|
4352 } |
|
4353 retVal = theOutFiles[index].Write(buffer); |
|
4354 if (retVal != KErrNone) |
|
4355 { |
|
4356 DBGS_PRINT((_L("theOutFiles[%d] Write failed (%d)\n"), index, retVal)); |
|
4357 break; |
|
4358 } |
|
4359 retVal = theOutFiles[index].Flush(); |
|
4360 if (retVal != KErrNone) |
|
4361 { |
|
4362 DBGS_PRINT((_L("theOutFiles[%d] flush failed (%d)\n"), index, retVal)); |
|
4363 break; |
|
4364 } |
|
4365 inFilePos[index] += buffer.Length(); |
|
4366 if (inFilePos[index] < inFileSize[index]) |
|
4367 stillGoing = ETrue; |
|
4368 } |
|
4369 } |
|
4370 } |
|
4371 while (stillGoing); |
|
4372 |
|
4373 TBool allOk = retVal == KErrNone; |
4379 for (index = 0; index < FILECOUNTMAX; index ++) |
4374 for (index = 0; index < FILECOUNTMAX; index ++) |
4380 { |
4375 { |
|
4376 if (!fileOk[index]) |
|
4377 { |
|
4378 allOk = EFalse; |
|
4379 break; |
|
4380 } |
4381 theInFiles[index].Close(); |
4381 theInFiles[index].Close(); |
4382 theOutFiles[index].Close(); |
4382 theOutFiles[index].Close(); |
4383 if (!fileOk[index]) |
|
4384 { |
|
4385 allOk = EFalse; |
|
4386 continue; |
|
4387 } |
|
4388 if (index < PAGELDRTST_MAX_DLLS) |
4383 if (index < PAGELDRTST_MAX_DLLS) |
4389 { |
4384 { |
4390 newPath.Format(_L("%S%S%d%S"), &aPath, &KDllBaseName, index, &TestPlExtNames[aMediaType]); |
4385 newPath.Format(_L("%S%S%d%S"), &aPath, &KDllBaseName, index, &TestPlExtNames[aMediaType]); |
4391 } |
4386 } |
4392 else if (index < (PAGELDRTST_MAX_DLLS + 1)) |
4387 else if (index < (PAGELDRTST_MAX_DLLS + 1)) |