395 test(r==KErrNone); |
396 test(r==KErrNone); |
396 |
397 |
397 } |
398 } |
398 |
399 |
399 |
400 |
|
401 //------------------------------------------------------------------- |
|
402 /** |
|
403 Create a directory; create many files in it (the directory will become more that 1 cluster) |
|
404 Then rename every file in this directory to a new name. |
|
405 */ |
|
406 void TestRenameManyFilesInTheSameDir() |
|
407 { |
|
408 test.Next(_L("TestRenameManyFilesInTheSameDir")); |
|
409 |
|
410 if(Is_Win32(TheFs, gDriveNum)) |
|
411 { |
|
412 test.Printf(_L("Skipping on WINS drive\n")); |
|
413 return; |
|
414 } |
|
415 |
|
416 _LIT(KDir, "\\dir1\\"); |
|
417 _LIT(KFile, "filename_long-"); |
|
418 |
|
419 //-- the number of files is chosen the way to have the directory file at least 2 clusters long (on FAT) |
|
420 //-- "filename_long-XXX" will correspond to 2 VFAT entries in the directory; max. cluster size of FAT is 32K |
|
421 //-- 2*32*600 = 38400 > 32K |
|
422 const TInt KNumFiles = 600; |
|
423 |
|
424 TName fName; |
|
425 TInt i; |
|
426 TInt nRes; |
|
427 |
|
428 //-- quick format the drive |
|
429 nRes = FormatDrive(TheFs, gDriveNum, ETrue); |
|
430 test_KErrNone(nRes); |
|
431 |
|
432 MakeDir(KDir); |
|
433 |
|
434 //-- create a number of files in a single directory, it shall be larger than 1 cluster. |
|
435 for(i=0; i<KNumFiles; ++i) |
|
436 { |
|
437 fName.Format(_L("%S%S%03d"), &KDir, &KFile, i); |
|
438 nRes = CreateEmptyFile(TheFs, fName, 0); |
|
439 test_KErrNone(nRes); |
|
440 } |
|
441 |
|
442 //-- rename all files in the same directory |
|
443 TName fNameNew; |
|
444 for(i=0; i<KNumFiles; ++i) |
|
445 { |
|
446 fName.Format(_L("%S%S%03d"), &KDir, &KFile, i); |
|
447 fNameNew.Format(_L("%S%S%03d_new"), &KDir, &KFile, i); |
|
448 |
|
449 nRes = TheFs.Rename(fName, fNameNew); |
|
450 test_KErrNone(nRes); |
|
451 |
|
452 } |
|
453 |
|
454 fName.Format(_L("%c:"), gDriveNum+'A'); |
|
455 nRes = TheFs.CheckDisk(fName); |
|
456 test(nRes == KErrNone || nRes == KErrNotSupported); |
|
457 |
|
458 //-- clean up |
|
459 for(i=0; i<KNumFiles; ++i) |
|
460 { |
|
461 fNameNew.Format(_L("%S%S%03d_new"), &KDir, &KFile, i); |
|
462 nRes = TheFs.Delete(fNameNew); |
|
463 test_KErrNone(nRes); |
|
464 } |
|
465 |
|
466 fName.Format(_L("%c:"), gDriveNum+'A'); |
|
467 nRes = TheFs.CheckDisk(fName); |
|
468 test(nRes == KErrNone || nRes == KErrNotSupported); |
|
469 |
|
470 |
|
471 nRes = TheFs.RmDir(KDir); |
|
472 test(nRes == KErrNone); |
|
473 |
|
474 |
|
475 } |
|
476 |
|
477 |
400 void CallTestsL(void) |
478 void CallTestsL(void) |
401 { |
479 { |
402 |
480 |
403 test.Title(); |
481 test.Title(); |
404 test.Start(_L("Testing rename")); |
482 test.Start(_L("Testing rename")); |
422 CreateTestFiles(); |
500 CreateTestFiles(); |
423 TestRFsRename(); |
501 TestRFsRename(); |
424 TestRFileRename(); |
502 TestRFileRename(); |
425 TestEikonRename(); |
503 TestEikonRename(); |
426 TestReplaceAndRename(); |
504 TestReplaceAndRename(); |
|
505 TestRenameManyFilesInTheSameDir(); |
427 |
506 |
428 if(!Is_Win32(TheFs, gDriveNum)) |
507 if(!Is_Win32(TheFs, gDriveNum)) |
429 { |
508 { |
430 nRes = FormatDrive(TheFs, gDriveNum, ETrue); |
509 nRes = FormatDrive(TheFs, gDriveNum, ETrue); |
431 test(nRes==KErrNone); |
510 test(nRes==KErrNone); |