206 test.Next(_L("Use RFs::ReadFileSection() to read from a file")); |
206 test.Next(_L("Use RFs::ReadFileSection() to read from a file")); |
207 |
207 |
208 // First, test for non-existant file |
208 // First, test for non-existant file |
209 TBuf<256> testDes; |
209 TBuf<256> testDes; |
210 TInt r=TheFs.ReadFileSection(_L("\\F32-tst\\NonExistantFile.txt"),0,testDes,52); |
210 TInt r=TheFs.ReadFileSection(_L("\\F32-tst\\NonExistantFile.txt"),0,testDes,52); |
211 test_Value(r, r == KErrNotFound); |
211 test(r==KErrNotFound); |
212 test(testDes.Length()==0); |
212 test(testDes.Length()==0); |
213 |
213 |
214 // Test with file closed |
214 // Test with file closed |
215 r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),0,testDes,26); |
215 r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),0,testDes,26); |
216 test_KErrNone(r); |
216 test_KErrNone(r); |
398 |
398 |
399 // Test for Null File length |
399 // Test for Null File length |
400 TBuf8<256> testDesN; |
400 TBuf8<256> testDesN; |
401 test.Next(_L("Check for null file name")); |
401 test.Next(_L("Check for null file name")); |
402 r=TheFs.ReadFileSection(_L(""),0,testDesN,26); |
402 r=TheFs.ReadFileSection(_L(""),0,testDesN,26); |
403 test_Value(r, r == KErrBadName); |
403 test(r==KErrBadName); |
404 |
404 |
405 // Check the lentgh of descriptor. |
405 // Check the lentgh of descriptor. |
406 TInt x = testDesN.Length(); |
406 TInt x = testDesN.Length(); |
407 test ( x == 0); |
407 test ( x == 0); |
408 |
408 |
409 test.Next(_L("Check for non existing file")); |
409 test.Next(_L("Check for non existing file")); |
410 r=TheFs.ReadFileSection(_L("sdfsd.dfg"),0,testDesN,26); |
410 r=TheFs.ReadFileSection(_L("sdfsd.dfg"),0,testDesN,26); |
411 test.Printf(_L("Return %d"),r); |
411 test.Printf(_L("Return %d"),r); |
412 test_Value(r, (r == KErrNotFound) || (r == KErrPathNotFound)); |
412 test((r==KErrNotFound) || (r == KErrPathNotFound)); |
413 |
413 |
414 // Check the lentgh of descriptor. |
414 // Check the lentgh of descriptor. |
415 x = testDesN.Length(); |
415 x = testDesN.Length(); |
416 test ( x == 0); |
416 test ( x == 0); |
417 |
417 |
544 // r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),0,testDes,45); |
544 // r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),0,testDes,45); |
545 // This will panic: See RFs::ReadFileSection() code - relevant lines are |
545 // This will panic: See RFs::ReadFileSection() code - relevant lines are |
546 // __ASSERT_ALWAYS(aDes.MaxLength()>=aLength,Panic(EBadLength)); |
546 // __ASSERT_ALWAYS(aDes.MaxLength()>=aLength,Panic(EBadLength)); |
547 |
547 |
548 r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),2000,testDes,-20); |
548 r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),2000,testDes,-20); |
549 test_Value(r, r == KErrArgument); |
549 test(r==KErrArgument); |
550 |
550 |
551 // Test that specifying a position and length which extends beyond the end of |
551 // Test that specifying a position and length which extends beyond the end of |
552 // the file returns a zero length descriptor and KErrNone |
552 // the file returns a zero length descriptor and KErrNone |
553 |
553 |
554 r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),4993,testDes,20); |
554 r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),4993,testDes,20); |
615 test.Next(_L("Use RFs::ReadFileSection() to read from a file")); |
615 test.Next(_L("Use RFs::ReadFileSection() to read from a file")); |
616 |
616 |
617 // First, test for non-existant file |
617 // First, test for non-existant file |
618 TBuf8<256> testDes; |
618 TBuf8<256> testDes; |
619 TInt r=TheFs.ReadFileSection(_L("\\F32-tst\\NonExistantFile.txt"),0,testDes,52); |
619 TInt r=TheFs.ReadFileSection(_L("\\F32-tst\\NonExistantFile.txt"),0,testDes,52); |
620 test_Value(r, r == KErrNotFound); |
620 test(r==KErrNotFound); |
621 test(testDes.Length()==0); |
621 test(testDes.Length()==0); |
622 |
622 |
623 // Test with file closed |
623 // Test with file closed |
624 r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),0,testDes,52); |
624 r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),0,testDes,52); |
625 test_KErrNone(r); |
625 test_KErrNone(r); |
638 |
638 |
639 // Test for Null File length |
639 // Test for Null File length |
640 TBuf8<256> testDesN; |
640 TBuf8<256> testDesN; |
641 test.Next(_L("Check for null file name")); |
641 test.Next(_L("Check for null file name")); |
642 r=TheFs.ReadFileSection(_L(""),0,testDesN,26); |
642 r=TheFs.ReadFileSection(_L(""),0,testDesN,26); |
643 test_Value(r, r == KErrBadName); |
643 test(r==KErrBadName); |
644 |
644 |
645 // Check the lentgh of descriptor. |
645 // Check the lentgh of descriptor. |
646 TInt x = testDesN.Length(); |
646 TInt x = testDesN.Length(); |
647 test ( x == 0); |
647 test ( x == 0); |
648 |
648 |
649 test.Next(_L("Check for non existing file")); |
649 test.Next(_L("Check for non existing file")); |
650 r=TheFs.ReadFileSection(_L("sdfsd.dfg"),0,testDesN,26); |
650 r=TheFs.ReadFileSection(_L("sdfsd.dfg"),0,testDesN,26); |
651 test.Printf(_L("Return %d"),r); |
651 test.Printf(_L("Return %d"),r); |
652 test_Value(r, (r == KErrNotFound) || (r == KErrPathNotFound)); |
652 test((r==KErrNotFound) || (r == KErrPathNotFound)); |
653 |
653 |
654 // Check the lentgh of descriptor. |
654 // Check the lentgh of descriptor. |
655 x = testDesN.Length(); |
655 x = testDesN.Length(); |
656 test ( x == 0); |
656 test ( x == 0); |
657 |
657 |
658 // Test for Empty directory |
658 // Test for Empty directory |
659 r=TheFs.ReadFileSection(_L("\\F32-tst\\"),0,testDesN,52); |
659 r=TheFs.ReadFileSection(_L("\\F32-tst\\"),0,testDesN,52); |
660 test_Value(r, r == KErrBadName); |
660 test(r==KErrBadName); |
661 test(testDesN.Length()==0); |
661 test(testDesN.Length()==0); |
662 |
662 |
663 // Test for File with wildcard name |
663 // Test for File with wildcard name |
664 r=TheFs.ReadFileSection(_L("\\F32-tst\\*.txt"),0,testDesN,52); |
664 r=TheFs.ReadFileSection(_L("\\F32-tst\\*.txt"),0,testDesN,52); |
665 test_Value(r, r == KErrBadName); |
665 test(r==KErrBadName); |
666 test(testDesN.Length()==0); |
666 test(testDesN.Length()==0); |
667 |
667 |
668 // Test for Folder with wildcard name |
668 // Test for Folder with wildcard name |
669 r=TheFs.ReadFileSection(_L("\\F32-tst*\\ReadFileSection1.txt"),0,testDesN,52); |
669 r=TheFs.ReadFileSection(_L("\\F32-tst*\\ReadFileSection1.txt"),0,testDesN,52); |
670 test_Value(r, r == KErrBadName); |
670 test(r==KErrBadName); |
671 test(testDesN.Length()==0); |
671 test(testDesN.Length()==0); |
672 |
672 |
673 // Test for Root directory |
673 // Test for Root directory |
674 r=TheFs.ReadFileSection(_L("\\"),0,testDesN,52); |
674 r=TheFs.ReadFileSection(_L("\\"),0,testDesN,52); |
675 test_Value(r, r == KErrBadName); |
675 test(r==KErrBadName); |
676 test(testDesN.Length()==0); |
676 test(testDesN.Length()==0); |
677 |
677 |
678 // Test for no file being specified. |
678 // Test for no file being specified. |
679 r=TheFs.ReadFileSection(_L(""),0,testDesN,26); |
679 r=TheFs.ReadFileSection(_L(""),0,testDesN,26); |
680 test_Value(r, r == KErrBadName); |
680 test(r==KErrBadName); |
681 test(testDesN.Length()==0); |
681 test(testDesN.Length()==0); |
682 |
682 |
683 |
683 |
684 // Test with file open EFileShareAny|EFileRead |
684 // Test with file open EFileShareAny|EFileRead |
685 RFile file; |
685 RFile file; |
855 // This will panic: See RFs::ReadFileSection() code - relevant lines are |
855 // This will panic: See RFs::ReadFileSection() code - relevant lines are |
856 // __ASSERT_ALWAYS(aDes.MaxLength()>=aLength,Panic(EBadLength)); |
856 // __ASSERT_ALWAYS(aDes.MaxLength()>=aLength,Panic(EBadLength)); |
857 |
857 |
858 |
858 |
859 r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),2000,testDes2,-20); |
859 r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),2000,testDes2,-20); |
860 test_Value(r, r == KErrArgument); |
860 test(r==KErrArgument); |
861 |
861 |
862 // Test that specifying a position and length which extends beyond the end of |
862 // Test that specifying a position and length which extends beyond the end of |
863 // the file returns a zero length descriptor and KErrNone |
863 // the file returns a zero length descriptor and KErrNone |
864 |
864 |
865 r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),9993,testDes2,30); |
865 r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),9993,testDes2,30); |