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