sl@0: // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // f32test\server\t_rdsect.cpp sl@0: // sl@0: // sl@0: sl@0: #define __E32TEST_EXTENSION__ sl@0: sl@0: #include sl@0: #include sl@0: sl@0: #include "t_server.h" sl@0: #include "t_chlffs.h" sl@0: sl@0: #if defined(__WINS__) sl@0: #define WIN32_LEAN_AND_MEAN sl@0: #pragma warning (disable:4201) // warning C4201: nonstandard extension used : nameless struct/union sl@0: #pragma warning (default:4201) // warning C4201: nonstandard extension used : nameless struct/union sl@0: #endif sl@0: sl@0: #if defined(_UNICODE) sl@0: #if !defined(UNICODE) sl@0: #define UNICODE sl@0: #endif sl@0: #endif sl@0: sl@0: GLDEF_D RTest test(_L("T_RDSECT")); sl@0: sl@0: sl@0: TBuf<26> alphaBuffer=_L("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); sl@0: TBuf<10> numberBuffer=_L("0123456789"); sl@0: TBuf<14> humptyBuffer=_L("Humpty-Dumpty!"); sl@0: TPtr8 alphaPtr((TText8*)alphaBuffer.Ptr(),alphaBuffer.Size(),alphaBuffer.Size()); sl@0: TPtr8 numberPtr((TText8*)numberBuffer.Ptr(),numberBuffer.Size(),numberBuffer.Size()); sl@0: TPtr8 humptyPtr((TText8*)humptyBuffer.Ptr(),humptyBuffer.Size(),humptyBuffer.Size()); sl@0: sl@0: sl@0: /* sl@0: sl@0: What this test is for: sl@0: sl@0: Tests the implementation of RFs::ReadFileSection() which has been designed sl@0: to allow reading from a file regardless of its lock state. sl@0: Under the EPOC FAT filesystem, the function accesses the raw file data without sl@0: opening the file using a share mode. This is obviously a dangerous activity sl@0: should the file be currently open for writing by another user - but the file sl@0: server makes no guarantees as to the data it returns! The function allows the sl@0: caller to specify the starting position in the file from which to read the data sl@0: and the length of data required. sl@0: sl@0: This test creates a number of files and tests the use of the function when the sl@0: files are closed and when they are open in a number of access modes. sl@0: It also tests reading a UID from the files using this new function. sl@0: sl@0: */ sl@0: sl@0: LOCAL_C void CreateTestFiles() sl@0: // sl@0: // Create files with uids for testing sl@0: // sl@0: { sl@0: sl@0: test.Next(_L("Create test files")); sl@0: TInt r=TheFs.MkDir(_L("\\F32-TST\\")); sl@0: test(r==KErrNone || r==KErrAlreadyExists); sl@0: sl@0: RFile file; sl@0: sl@0: // Create \\gSessionPath\\UIDCHK.BLG - with uid no data sl@0: r=file.Replace(TheFs,_L("\\F32-TST\\UIDCHK.BLG"),EFileRead|EFileWrite); sl@0: test_KErrNone(r); sl@0: TUidType uidType(TUid::Uid('U'),TUid::Uid('I'),TUid::Uid('D')); sl@0: TCheckedUid checkedUid(uidType); sl@0: TPtrC8 buf((TUint8*)&checkedUid,sizeof(TCheckedUid)); sl@0: r=file.Write(buf); sl@0: test_KErrNone(r); sl@0: file.Close(); sl@0: sl@0: // Create \\gSessionPath\\UIDCHK.MSG - with uid and data sl@0: r=file.Replace(TheFs,_L("\\F32-TST\\UIDCHK.MSG"),EFileRead|EFileWrite); sl@0: test_KErrNone(r); sl@0: TUidType uidType2(TUid::Uid('X'),TUid::Uid('Y'),TUid::Uid('Z')); sl@0: checkedUid.Set(uidType2); sl@0: buf.Set((TUint8*)&checkedUid,sizeof(TCheckedUid)); sl@0: r=file.Write(buf); sl@0: test_KErrNone(r); sl@0: r=file.Write(_L8("More file data")); sl@0: test_KErrNone(r); sl@0: file.Close(); sl@0: sl@0: // Create \\gSessionPath\\UIDCHK.DAT - uid stored only in the file sl@0: r=file.Replace(TheFs,_L("\\F32-TST\\UIDCHK.DAT"),EFileRead|EFileWrite); sl@0: test_KErrNone(r); sl@0: TUidType uidType3(TUid::Uid('D'),TUid::Uid('A'),TUid::Uid('T')); sl@0: checkedUid.Set(uidType3); sl@0: buf.Set((TUint8*)&checkedUid,sizeof(TCheckedUid)); sl@0: r=file.Write(buf); sl@0: test_KErrNone(r); sl@0: r=file.Write(_L8("More file data")); sl@0: test_KErrNone(r); sl@0: file.Close(); sl@0: sl@0: // Make a few random files - these will be deleted before the test begins sl@0: // but are necessary to try to split file ReadFileSection into non-contiguous clusters sl@0: sl@0: r=file.Replace(TheFs,_L("\\F32-TST\\Temp1.txt"),EFileRead|EFileWrite); sl@0: test_KErrNone(r); sl@0: file.SetSize(550); sl@0: file.Close(); sl@0: sl@0: r=file.Replace(TheFs,_L("\\F32-TST\\Temp2.txt"),EFileRead|EFileWrite); sl@0: test_KErrNone(r); sl@0: file.SetSize(256); sl@0: file.Close(); sl@0: sl@0: r=file.Replace(TheFs,_L("\\F32-TST\\Temp3.txt"),EFileRead|EFileWrite); sl@0: test_KErrNone(r); sl@0: file.SetSize(256); sl@0: file.Close(); sl@0: sl@0: r=file.Replace(TheFs,_L("\\F32-TST\\Temp4.txt"),EFileRead|EFileWrite); sl@0: test_KErrNone(r); sl@0: file.SetSize(550); sl@0: file.Close(); sl@0: sl@0: r=file.Replace(TheFs,_L("\\F32-TST\\Temp5.txt"),EFileRead|EFileWrite); sl@0: test_KErrNone(r); sl@0: file.SetSize(256); sl@0: file.Close(); sl@0: sl@0: r=file.Replace(TheFs,_L("\\F32-TST\\Temp6.txt"),EFileRead|EFileWrite); sl@0: test_KErrNone(r); sl@0: file.SetSize(256); sl@0: file.Close(); sl@0: sl@0: r=file.Replace(TheFs,_L("\\F32-TST\\Temp7.txt"),EFileRead|EFileWrite); sl@0: test_KErrNone(r); sl@0: file.SetSize(256); sl@0: file.Close(); sl@0: sl@0: r=file.Replace(TheFs,_L("\\F32-TST\\Temp8.txt"),EFileRead|EFileWrite); sl@0: test_KErrNone(r); sl@0: file.SetSize(256); sl@0: file.Close(); sl@0: sl@0: r=file.Replace(TheFs,_L("\\F32-TST\\Temp9.txt"),EFileRead|EFileWrite); sl@0: test_KErrNone(r); sl@0: file.SetSize(256); sl@0: file.Close(); sl@0: sl@0: r=file.Replace(TheFs,_L("\\F32-TST\\Temp10.txt"),EFileRead|EFileWrite); sl@0: test_KErrNone(r); sl@0: file.SetSize(256); sl@0: file.Close(); sl@0: sl@0: TheFs.Delete(_L("\\F32-TST\\Temp2.txt")); sl@0: TheFs.Delete(_L("\\F32-TST\\Temp4.txt")); sl@0: TheFs.Delete(_L("\\F32-TST\\Temp6.txt")); sl@0: TheFs.Delete(_L("\\F32-TST\\Temp8.txt")); sl@0: TheFs.Delete(_L("\\F32-TST\\Temp10.txt")); sl@0: sl@0: r=file.Replace(TheFs,_L("\\F32-TST\\ReadFileSection1.txt"),EFileRead|EFileWrite); sl@0: test_KErrNone(r); sl@0: sl@0: // Write 5000 bytes of nonsense sl@0: sl@0: TInt i=0; sl@0: for ( ; i<100; i++) sl@0: { sl@0: r=file.Write(alphaPtr); sl@0: test_KErrNone(r); sl@0: r=file.Write(numberPtr); sl@0: test_KErrNone(r); sl@0: r=file.Write(humptyPtr); sl@0: test_KErrNone(r); sl@0: } sl@0: sl@0: file.Close(); sl@0: sl@0: TheFs.Delete(_L("\\F32-TST\\Temp1.txt")); sl@0: TheFs.Delete(_L("\\F32-TST\\Temp3.txt")); sl@0: TheFs.Delete(_L("\\F32-TST\\Temp5.txt")); sl@0: TheFs.Delete(_L("\\F32-TST\\Temp7.txt")); sl@0: TheFs.Delete(_L("\\F32-TST\\Temp9.txt")); sl@0: } sl@0: sl@0: #if !defined(_UNICODE) sl@0: sl@0: LOCAL_C void Test1() sl@0: // sl@0: // Test RFs::ReadFileSection() sl@0: // sl@0: { sl@0: sl@0: test.Next(_L("Use RFs::ReadFileSection() to read from a file")); sl@0: sl@0: // First, test for non-existant file sl@0: TBuf<256> testDes; sl@0: TInt r=TheFs.ReadFileSection(_L("\\F32-tst\\NonExistantFile.txt"),0,testDes,52); sl@0: test(r==KErrNotFound); sl@0: test(testDes.Length()==0); sl@0: sl@0: // Test with file closed sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),0,testDes,26); sl@0: test_KErrNone(r); sl@0: test(testDes.Length()==26); sl@0: test(testDes==_L("ABCDEFGHIJKLMNOPQRSTUVWXYZ")); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),26,testDes,10); sl@0: test_KErrNone(r); sl@0: test(testDes==_L("0123456789")); sl@0: test(testDes.Length()==10); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),36,testDes,14); sl@0: test_KErrNone(r); sl@0: test(testDes==_L("Humpty-Dumpty!")); sl@0: test(testDes.Length()==14); sl@0: sl@0: // Test with file open EFileShareAny|EFileRead sl@0: RFile file; sl@0: r=file.Open(TheFs,_L("\\F32-tst\\ReadFileSection1.txt"),EFileShareAny|EFileRead); sl@0: test_KErrNone(r); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),50,testDes,26); sl@0: test_KErrNone(r); sl@0: test(testDes==_L("ABCDEFGHIJKLMNOPQRSTUVWXYZ")); sl@0: test(testDes.Length()==26); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),76,testDes,10); sl@0: test_KErrNone(r); sl@0: test(testDes==_L("0123456789")); sl@0: test(testDes.Length()==10); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),86,testDes,14); sl@0: test_KErrNone(r); sl@0: test(testDes==_L("Humpty-Dumpty!")); sl@0: test(testDes.Length()==14); sl@0: sl@0: file.Close(); sl@0: sl@0: // Test with file open EFileShareExclusive|EFileRead sl@0: r=file.Open(TheFs,_L("\\F32-tst\\ReadFileSection1.txt"),EFileShareExclusive|EFileRead); sl@0: test_KErrNone(r); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),100,testDes,26); sl@0: test_KErrNone(r); sl@0: test(testDes==_L("ABCDEFGHIJKLMNOPQRSTUVWXYZ")); sl@0: test(testDes.Length()==26); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),126,testDes,10); sl@0: test_KErrNone(r); sl@0: test(testDes==_L("0123456789")); sl@0: test(testDes.Length()==10); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),136,testDes,14); sl@0: test_KErrNone(r); sl@0: test(testDes==_L("Humpty-Dumpty!")); sl@0: test(testDes.Length()==14); sl@0: sl@0: file.Close(); sl@0: sl@0: // Test with file open EFileShareExclusive|EFileWrite sl@0: r=file.Open(TheFs,_L("\\F32-tst\\ReadFileSection1.txt"),EFileShareExclusive|EFileWrite); sl@0: test_KErrNone(r); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),150,testDes,26); sl@0: test_KErrNone(r); sl@0: test(testDes==_L("ABCDEFGHIJKLMNOPQRSTUVWXYZ")); sl@0: test(testDes.Length()==26); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),176,testDes,10); sl@0: test_KErrNone(r); sl@0: test(testDes==_L("0123456789")); sl@0: test(testDes.Length()==10); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),186,testDes,14); sl@0: test_KErrNone(r); sl@0: test(testDes==_L("Humpty-Dumpty!")); sl@0: test(testDes.Length()==14); sl@0: sl@0: file.Close(); sl@0: sl@0: sl@0: // Test with file open EFileShareReadersOnly|EFileRead sl@0: r=file.Open(TheFs,_L("\\F32-tst\\ReadFileSection1.txt"),EFileShareReadersOnly|EFileRead); sl@0: test_KErrNone(r); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),200,testDes,26); sl@0: test_KErrNone(r); sl@0: test(testDes==_L("ABCDEFGHIJKLMNOPQRSTUVWXYZ")); sl@0: test(testDes.Length()==26); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),226,testDes,10); sl@0: test_KErrNone(r); sl@0: test(testDes==_L("0123456789")); sl@0: test(testDes.Length()==10); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),236,testDes,14); sl@0: test_KErrNone(r); sl@0: test(testDes==_L("Humpty-Dumpty!")); sl@0: test(testDes.Length()==14); sl@0: sl@0: file.Close(); sl@0: sl@0: // Test with several accesses to a file EFileShareAny|EFileWrite sl@0: r=file.Open(TheFs,_L("\\F32-tst\\ReadFileSection1.txt"),EFileShareAny|EFileWrite); sl@0: test_KErrNone(r); sl@0: sl@0: RFile secondFile; sl@0: r=secondFile.Open(TheFs,_L("\\F32-tst\\ReadFileSection1.txt"),EFileShareAny|EFileWrite); sl@0: test_KErrNone(r); sl@0: sl@0: RFile thirdFile; sl@0: r=thirdFile.Open(TheFs,_L("\\F32-tst\\ReadFileSection1.txt"),EFileShareAny|EFileWrite); sl@0: test_KErrNone(r); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),250,testDes,26); sl@0: test_KErrNone(r); sl@0: test(testDes==_L("ABCDEFGHIJKLMNOPQRSTUVWXYZ")); sl@0: test(testDes.Length()==26); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),276,testDes,10); sl@0: test_KErrNone(r); sl@0: test(testDes==_L("0123456789")); sl@0: test(testDes.Length()==10); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),286,testDes,14); sl@0: test_KErrNone(r); sl@0: test(testDes==_L("Humpty-Dumpty!")); sl@0: test(testDes.Length()==14); sl@0: sl@0: // Test across potential cluster boundaries sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),500,testDes,100); sl@0: test_KErrNone(r); sl@0: test(testDes.Length()==100); sl@0: test(testDes==_L("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789Humpty-Dumpty!ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789Humpty-Dumpty!")); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),1000,testDes,100); sl@0: test_KErrNone(r); sl@0: test(testDes.Length()==100); sl@0: test(testDes==_L("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789Humpty-Dumpty!ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789Humpty-Dumpty!")); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),1500,testDes,100); sl@0: test_KErrNone(r); sl@0: test(testDes.Length()==100); sl@0: test(testDes==_L("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789Humpty-Dumpty!ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789Humpty-Dumpty!")); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),2000,testDes,100); sl@0: test_KErrNone(r); sl@0: test(testDes.Length()==100); sl@0: test(testDes==_L("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789Humpty-Dumpty!ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789Humpty-Dumpty!")); sl@0: sl@0: file.Close(); sl@0: secondFile.Close(); sl@0: thirdFile.Close(); sl@0: } sl@0: sl@0: sl@0: LOCAL_C void Test2() sl@0: // sl@0: // Test RFs::ReadFileSection() on UID reads sl@0: // sl@0: { sl@0: sl@0: sl@0: test.Next(_L("Use RFs::ReadFileSection() to read UIDs from files")); sl@0: sl@0: TBuf8 uidBuf(sizeof(TCheckedUid)); sl@0: TPtr uidPtr((TText*)uidBuf.Ptr(),sizeof(TCheckedUid),sizeof(TCheckedUid)); sl@0: sl@0: TInt r=TheFs.ReadFileSection(_L("\\F32-TST\\UIDCHK.BLG"),0,uidPtr,sizeof(TCheckedUid)); sl@0: test_KErrNone(r); sl@0: TCheckedUid uid(uidBuf); sl@0: TUidType uidType=uid.UidType(); sl@0: test(uidType.IsValid()); sl@0: sl@0: test(uidType[0]==TUid::Uid('U') && uidType[1]==TUid::Uid('I') && uidType[2]==TUid::Uid('D')); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-TST\\UIDCHK.MSG"),0,uidBuf,sizeof(TCheckedUid)); sl@0: test_KErrNone(r); sl@0: uid.Set(uidBuf); sl@0: uidType=uid.UidType(); sl@0: test(uidType.IsValid()); sl@0: test(uidType[0]==TUid::Uid('X') && uidType[1]==TUid::Uid('Y') && uidType[2]==TUid::Uid('Z')); sl@0: sl@0: sl@0: // Test for Null File length sl@0: TBuf8<256> testDesN; sl@0: test.Next(_L("Check for null file name")); sl@0: r=TheFs.ReadFileSection(_L(""),0,testDesN,26); sl@0: test(r==KErrBadName); sl@0: sl@0: // Check the lentgh of descriptor. sl@0: TInt x = testDesN.Length(); sl@0: test ( x == 0); sl@0: sl@0: test.Next(_L("Check for non existing file")); sl@0: r=TheFs.ReadFileSection(_L("sdfsd.dfg"),0,testDesN,26); sl@0: test.Printf(_L("Return %d"),r); sl@0: test((r==KErrNotFound) || (r == KErrPathNotFound)); sl@0: sl@0: // Check the lentgh of descriptor. sl@0: x = testDesN.Length(); sl@0: test ( x == 0); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-TST\\UIDCHK.DAT"),0,uidBuf,sizeof(TCheckedUid)); sl@0: test_KErrNone(r); sl@0: uid.Set(uidBuf); sl@0: uidType=uid.UidType(); sl@0: test(uidType.IsValid()); sl@0: test(uidType[0]==TUid::Uid('D') && uidType[1]==TUid::Uid('A') && uidType[2]==TUid::Uid('T')); sl@0: sl@0: sl@0: } sl@0: sl@0: LOCAL_C void Test3() sl@0: // sl@0: // Test uid's can be read when the file is open sl@0: // sl@0: // EFileShareExclusive,EFileShareReadersOnly,EFileShareAny, sl@0: // EFileStream=0,EFileStreamText=0x100, sl@0: // EFileRead=0,EFileWrite=0x200 sl@0: // sl@0: { sl@0: sl@0: test.Next(_L("Test that UIDs can be read from open files")); sl@0: RFile file; sl@0: sl@0: // Test with file open EFileShareExclusive|EFileRead sl@0: TInt r=file.Open(TheFs,_L("\\F32-TST\\UIDCHK.DAT"),EFileShareExclusive|EFileRead); sl@0: test_KErrNone(r); sl@0: sl@0: TBuf8 uidBuf; sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-TST\\UIDCHK.DAT"),0,uidBuf,sizeof(TCheckedUid)); sl@0: test_KErrNone(r); sl@0: sl@0: TCheckedUid uid(uidBuf); sl@0: TUidType uidType=uid.UidType(); sl@0: test(uidType.IsValid()); sl@0: test(uidType[0]==TUid::Uid('D') && uidType[1]==TUid::Uid('A') && uidType[2]==TUid::Uid('T')); sl@0: sl@0: file.Close(); sl@0: sl@0: // Test with file open EFileShareExclusive|EFileWrite sl@0: r=file.Open(TheFs,_L("\\F32-TST\\UIDCHK.DAT"),EFileShareExclusive|EFileWrite); sl@0: test_KErrNone(r); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-TST\\UIDCHK.DAT"),0,uidBuf,sizeof(TCheckedUid)); sl@0: test_KErrNone(r); sl@0: uid.Set(uidBuf); sl@0: uidType=uid.UidType(); sl@0: test(uidType.IsValid()); sl@0: test(uidType[0]==TUid::Uid('D') && uidType[1]==TUid::Uid('A') && uidType[2]==TUid::Uid('T')); sl@0: sl@0: file.Close(); sl@0: sl@0: // Test with file open EFileShareReadersOnly|EFileRead sl@0: r=file.Open(TheFs,_L("\\F32-TST\\UIDCHK.DAT"),EFileShareReadersOnly|EFileRead); sl@0: test_KErrNone(r); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-TST\\UIDCHK.DAT"),0,uidBuf,sizeof(TCheckedUid)); sl@0: test_KErrNone(r); sl@0: uid.Set(uidBuf); sl@0: uidType=uid.UidType(); sl@0: test(uidType.IsValid()); sl@0: test(uidType[0]==TUid::Uid('D') && uidType[1]==TUid::Uid('A') && uidType[2]==TUid::Uid('T')); sl@0: sl@0: file.Close(); sl@0: sl@0: sl@0: // Test with file open EFileShareAny|EFileRead sl@0: r=file.Open(TheFs,_L("\\F32-TST\\UIDCHK.DAT"),EFileShareAny|EFileRead); sl@0: test_KErrNone(r); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-TST\\UIDCHK.DAT"),0,uidBuf,sizeof(TCheckedUid)); sl@0: test_KErrNone(r); sl@0: uid.Set(uidBuf); sl@0: uidType=uid.UidType(); sl@0: test(uidType.IsValid()); sl@0: test(uidType[0]==TUid::Uid('D') && uidType[1]==TUid::Uid('A') && uidType[2]==TUid::Uid('T')); sl@0: sl@0: file.Close(); sl@0: sl@0: // Test with several accesses to file open EFileShareAny|EFileWrite sl@0: r=file.Open(TheFs,_L("\\F32-TST\\UIDCHK.DAT"),EFileShareAny|EFileWrite); sl@0: test_KErrNone(r); sl@0: sl@0: RFile secondFile; sl@0: r=secondFile.Open(TheFs,_L("\\F32-TST\\UIDCHK.DAT"),EFileShareAny|EFileWrite); sl@0: test_KErrNone(r); sl@0: sl@0: RFile thirdFile; sl@0: r=thirdFile.Open(TheFs,_L("\\F32-TST\\UIDCHK.DAT"),EFileShareAny|EFileRead); sl@0: test_KErrNone(r); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-TST\\UIDCHK.DAT"),0,uidBuf,sizeof(TCheckedUid)); sl@0: test_KErrNone(r); sl@0: uid.Set(uidBuf); sl@0: uidType=uid.UidType(); sl@0: test(uidType.IsValid()); sl@0: test(uidType[0]==TUid::Uid('D') && uidType[1]==TUid::Uid('A') && uidType[2]==TUid::Uid('T')); sl@0: sl@0: file.Close(); sl@0: secondFile.Close(); sl@0: thirdFile.Close(); sl@0: sl@0: } sl@0: sl@0: sl@0: LOCAL_C void TestErrors() sl@0: // sl@0: // Test errors and boundary conditions sl@0: // sl@0: { sl@0: sl@0: test.Next(_L("Test Error handling")); sl@0: sl@0: // Test that specifying a zero length section returns a zero length descriptor sl@0: TBuf<30> testDes; sl@0: TInt r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),25,testDes,0); sl@0: test_KErrNone(r); sl@0: test(testDes.Length()==0); sl@0: sl@0: // Test that specifying a negative starting position causes a panic sl@0: // r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),-1,testDes,10); sl@0: // This will panic: See RFs::ReadFileSection() code - relevant lines are sl@0: // __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); sl@0: sl@0: // Test that specifying a section of greater length than the descriptor to sl@0: // hold the data will cause a panic sl@0: // r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),0,testDes,45); sl@0: // This will panic: See RFs::ReadFileSection() code - relevant lines are sl@0: // __ASSERT_ALWAYS(aDes.MaxLength()>=aLength,Panic(EBadLength)); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),2000,testDes,-20); sl@0: test(r==KErrArgument); sl@0: sl@0: // Test that specifying a position and length which extends beyond the end of sl@0: // the file returns a zero length descriptor and KErrNone sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),4993,testDes,20); sl@0: test_KErrNone(r); sl@0: test(testDes.Length()==7); sl@0: test(testDes==_L("Dumpty!")); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),4999,testDes,1); sl@0: test_KErrNone(r); sl@0: test(testDes.Length()==1); sl@0: test(testDes==_L("!")); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),5000,testDes,1); sl@0: test_KErrNone(r); sl@0: test(testDes.Length()==0); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),5550,testDes,20); sl@0: test_KErrNone(r); sl@0: test(testDes.Length()==0); sl@0: sl@0: // Test reading the whole file sl@0: HBufC* hDes=HBufC::New(5002); sl@0: if (!hDes) sl@0: User::Leave(KErrNoMemory); sl@0: TPtr pDes=hDes->Des(); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),0,pDes,5000); sl@0: test_KErrNone(r); sl@0: test(pDes.Length()==5000); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),0,pDes,5000); sl@0: test_KErrNone(r); sl@0: test(pDes.Length()==5000); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),0,pDes,5002); sl@0: test_KErrNone(r); sl@0: test(pDes.Length()==5000); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),2000,pDes,3000); sl@0: test_KErrNone(r); sl@0: test(pDes.Length()==3000); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),2000,pDes,4002); sl@0: test_KErrNone(r); sl@0: test(pDes.Length()==3000); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),5000,pDes,5002); sl@0: test_KErrNone(r); sl@0: test(pDes.Length()==0); sl@0: sl@0: delete hDes; sl@0: } sl@0: sl@0: #else sl@0: sl@0: sl@0: // BEGINNING OF UNICODE TESTS sl@0: sl@0: LOCAL_C void TestUnicode() sl@0: // sl@0: // Test RFs::ReadFileSection() sl@0: // sl@0: { sl@0: test.Next(_L("Use RFs::ReadFileSection() to read from a file")); sl@0: sl@0: // First, test for non-existant file sl@0: TBuf8<256> testDes; sl@0: TInt r=TheFs.ReadFileSection(_L("\\F32-tst\\NonExistantFile.txt"),0,testDes,52); sl@0: test(r==KErrNotFound); sl@0: test(testDes.Length()==0); sl@0: sl@0: // Test with file closed sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),0,testDes,52); sl@0: test_KErrNone(r); sl@0: test(testDes.Length()==52); sl@0: test(testDes==alphaPtr); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),52,testDes,20); sl@0: test_KErrNone(r); sl@0: test(testDes==numberPtr); sl@0: test(testDes.Length()==20); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),72,testDes,28); sl@0: test_KErrNone(r); sl@0: test(testDes==humptyPtr); sl@0: test(testDes.Length()==28); sl@0: sl@0: // Test for Null File length sl@0: TBuf8<256> testDesN; sl@0: test.Next(_L("Check for null file name")); sl@0: r=TheFs.ReadFileSection(_L(""),0,testDesN,26); sl@0: test(r==KErrBadName); sl@0: sl@0: // Check the lentgh of descriptor. sl@0: TInt x = testDesN.Length(); sl@0: test ( x == 0); sl@0: sl@0: test.Next(_L("Check for non existing file")); sl@0: r=TheFs.ReadFileSection(_L("sdfsd.dfg"),0,testDesN,26); sl@0: test.Printf(_L("Return %d"),r); sl@0: test((r==KErrNotFound) || (r == KErrPathNotFound)); sl@0: sl@0: // Check the lentgh of descriptor. sl@0: x = testDesN.Length(); sl@0: test ( x == 0); sl@0: sl@0: // Test for Empty directory sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\"),0,testDesN,52); sl@0: test(r==KErrBadName); sl@0: test(testDesN.Length()==0); sl@0: sl@0: // Test for File with wildcard name sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\*.txt"),0,testDesN,52); sl@0: test(r==KErrBadName); sl@0: test(testDesN.Length()==0); sl@0: sl@0: // Test for Folder with wildcard name sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst*\\ReadFileSection1.txt"),0,testDesN,52); sl@0: test(r==KErrBadName); sl@0: test(testDesN.Length()==0); sl@0: sl@0: // Test for Root directory sl@0: r=TheFs.ReadFileSection(_L("\\"),0,testDesN,52); sl@0: test(r==KErrBadName); sl@0: test(testDesN.Length()==0); sl@0: sl@0: // Test for no file being specified. sl@0: r=TheFs.ReadFileSection(_L(""),0,testDesN,26); sl@0: test(r==KErrBadName); sl@0: test(testDesN.Length()==0); sl@0: sl@0: sl@0: // Test with file open EFileShareAny|EFileRead sl@0: RFile file; sl@0: r=file.Open(TheFs,_L("\\F32-tst\\ReadFileSection1.txt"),EFileShareAny|EFileRead); sl@0: test_KErrNone(r); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),100,testDes,52); sl@0: test_KErrNone(r); sl@0: test(testDes==alphaPtr); sl@0: test(testDes.Length()==52); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),152,testDes,20); sl@0: test_KErrNone(r); sl@0: test(testDes==numberPtr); sl@0: test(testDes.Length()==20); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),172,testDes,28); sl@0: test_KErrNone(r); sl@0: test(testDes==humptyPtr); sl@0: test(testDes.Length()==28); sl@0: sl@0: file.Close(); sl@0: sl@0: // Test with file open EFileShareExclusive|EFileRead sl@0: r=file.Open(TheFs,_L("\\F32-tst\\ReadFileSection1.txt"),EFileShareExclusive|EFileRead); sl@0: test_KErrNone(r); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),200,testDes,52); sl@0: test_KErrNone(r); sl@0: test(testDes==alphaPtr); sl@0: test(testDes.Length()==52); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),252,testDes,20); sl@0: test_KErrNone(r); sl@0: test(testDes==numberPtr); sl@0: test(testDes.Length()==20); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),272,testDes,28); sl@0: test_KErrNone(r); sl@0: test(testDes==humptyPtr); sl@0: test(testDes.Length()==28); sl@0: sl@0: file.Close(); sl@0: sl@0: // Test with file open EFileShareExclusive|EFileWrite sl@0: r=file.Open(TheFs,_L("\\F32-tst\\ReadFileSection1.txt"),EFileShareExclusive|EFileWrite); sl@0: test_KErrNone(r); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),300,testDes,52); sl@0: test_KErrNone(r); sl@0: test(testDes==alphaPtr); sl@0: test(testDes.Length()==52); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),352,testDes,20); sl@0: test_KErrNone(r); sl@0: test(testDes==numberPtr); sl@0: test(testDes.Length()==20); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),372,testDes,28); sl@0: test_KErrNone(r); sl@0: test(testDes==humptyPtr); sl@0: test(testDes.Length()==28); sl@0: sl@0: file.Close(); sl@0: sl@0: sl@0: // Test with file open EFileShareReadersOnly|EFileRead sl@0: r=file.Open(TheFs,_L("\\F32-tst\\ReadFileSection1.txt"),EFileShareReadersOnly|EFileRead); sl@0: test_KErrNone(r); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),400,testDes,52); sl@0: test_KErrNone(r); sl@0: test(testDes==alphaPtr); sl@0: test(testDes.Length()==52); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),452,testDes,20); sl@0: test_KErrNone(r); sl@0: test(testDes==numberPtr); sl@0: test(testDes.Length()==20); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),472,testDes,28); sl@0: test_KErrNone(r); sl@0: test(testDes==humptyPtr); sl@0: test(testDes.Length()==28); sl@0: sl@0: file.Close(); sl@0: sl@0: // Test with several accesses to a file EFileShareAny|EFileWrite sl@0: r=file.Open(TheFs,_L("\\F32-tst\\ReadFileSection1.txt"),EFileShareAny|EFileWrite); sl@0: test_KErrNone(r); sl@0: sl@0: RFile secondFile; sl@0: r=secondFile.Open(TheFs,_L("\\F32-tst\\ReadFileSection1.txt"),EFileShareAny|EFileWrite); sl@0: test_KErrNone(r); sl@0: sl@0: RFile thirdFile; sl@0: r=thirdFile.Open(TheFs,_L("\\F32-tst\\ReadFileSection1.txt"),EFileShareAny|EFileWrite); sl@0: test_KErrNone(r); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),500,testDes,52); sl@0: test_KErrNone(r); sl@0: sl@0: #if defined(__WINS__) sl@0: #if defined(_DEBUG) sl@0: test(testDes==alphaPtr); sl@0: test(testDes.Length()==52); sl@0: #endif sl@0: #else sl@0: test(testDes==alphaPtr); sl@0: test(testDes.Length()==52); sl@0: #endif sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),552,testDes,20); sl@0: test_KErrNone(r); sl@0: test(testDes==numberPtr); sl@0: test(testDes.Length()==20); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),572,testDes,28); sl@0: test_KErrNone(r); sl@0: test(testDes==humptyPtr); sl@0: test(testDes.Length()==28); sl@0: sl@0: // Test across potential cluster boundaries sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),1000,testDes,200); sl@0: test_KErrNone(r); sl@0: test(testDes.Length()==200); sl@0: TBuf8<200> amalgam; sl@0: TInt i=0; sl@0: for (; i<2; i++) sl@0: { sl@0: amalgam.Append(alphaPtr); sl@0: amalgam.Append(numberPtr); sl@0: amalgam.Append(humptyPtr); sl@0: } sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),1000,testDes,200); sl@0: test_KErrNone(r); sl@0: test(testDes.Length()==200); sl@0: test(testDes==amalgam); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),3000,testDes,200); sl@0: test_KErrNone(r); sl@0: test(testDes.Length()==200); sl@0: test(testDes==amalgam); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),4000,testDes,200); sl@0: test_KErrNone(r); sl@0: test(testDes.Length()==200); sl@0: test(testDes==amalgam); sl@0: sl@0: file.Close(); sl@0: secondFile.Close(); sl@0: thirdFile.Close(); sl@0: sl@0: // Test errors and boundary conditions sl@0: test.Next(_L("Test Error handling")); sl@0: sl@0: // Test that specifying a zero length section returns a zero length descriptor sl@0: TBuf8<30> testDes2; sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),50,testDes2,0); sl@0: test_KErrNone(r); sl@0: test(testDes2.Length()==0); sl@0: sl@0: // Test that specifying a negative starting position causes a panic sl@0: // r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),-1,testDes2,10); sl@0: // This will panic: See RFs::ReadFileSection() code - relevant lines are sl@0: // __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); sl@0: sl@0: // Test that specifying a section of greater length than the descriptor to sl@0: // hold the data will cause a panic sl@0: // r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),0,testDes2,45); sl@0: // This will panic: See RFs::ReadFileSection() code - relevant lines are sl@0: // __ASSERT_ALWAYS(aDes.MaxLength()>=aLength,Panic(EBadLength)); sl@0: sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),2000,testDes2,-20); sl@0: test(r==KErrArgument); sl@0: sl@0: // Test that specifying a position and length which extends beyond the end of sl@0: // the file returns a zero length descriptor and KErrNone sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),9993,testDes2,30); sl@0: test_KErrNone(r); sl@0: test(testDes2.Length()==7); sl@0: test(testDes2==humptyPtr.Right(7)); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),9999,testDes2,1); sl@0: test_KErrNone(r); sl@0: test(testDes2.Length()==1); sl@0: test(testDes2==humptyPtr.Right(1)); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),10000,testDes2,1); sl@0: test_KErrNone(r); sl@0: test(testDes2.Length()==0); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),10550,testDes2,20); sl@0: test_KErrNone(r); sl@0: test(testDes2.Length()==0); sl@0: sl@0: // Test reading the whole file sl@0: HBufC8* hDes=HBufC8::New(10002); sl@0: if (!hDes) sl@0: User::Leave(KErrNoMemory); sl@0: TPtr8 pDes=hDes->Des(); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),0,pDes,10000); sl@0: test_KErrNone(r); sl@0: test(pDes.Length()==10000); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),0,pDes,10000); sl@0: test_KErrNone(r); sl@0: test(pDes.Length()==10000); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),0,pDes,10002); sl@0: test_KErrNone(r); sl@0: test(pDes.Length()==10000); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),4000,pDes,6000); sl@0: test_KErrNone(r); sl@0: test(pDes.Length()==6000); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),4000,pDes,8002); sl@0: test_KErrNone(r); sl@0: test(pDes.Length()==6000); sl@0: sl@0: r=TheFs.ReadFileSection(_L("\\F32-tst\\ReadFileSection1.txt"),10000,pDes,10002); sl@0: test_KErrNone(r); sl@0: test(pDes.Length()==0); sl@0: sl@0: delete hDes; sl@0: } sl@0: sl@0: #endif sl@0: sl@0: sl@0: LOCAL_C void TestZ() sl@0: // sl@0: // Test Rom filesystem sl@0: // sl@0: { sl@0: test.Next(_L("Use RFs::ReadFileSection() to read from a file on the ROM")); sl@0: #if defined (__WINS__) sl@0: // Requires a copy of t_rdsect.txt in z directory (\EPOC32\RELEASE\WINS\BUILD\Z\TEST) sl@0: // Initially, test with file closed sl@0: TBuf8<256> testDes; sl@0: TBuf8<27> temp1; sl@0: TInt r=TheFs.ReadFileSection(_L("Z:\\test\\t_rdsect.txt"),0,temp1,26); sl@0: test_KErrNone(r); sl@0: test(temp1.Length()==26); sl@0: test(temp1==_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ")); sl@0: sl@0: TBuf8<11> temp2; sl@0: r=TheFs.ReadFileSection(_L("Z:\\test\\t_rdsect.txt"),26,temp2,10); sl@0: test_KErrNone(r); sl@0: test(temp2==_L8("0123456789")); sl@0: test(temp2.Length()==10); sl@0: sl@0: r=TheFs.ReadFileSection(_L("Z:\\test\\t_rdsect.txt"),36,testDes,14); sl@0: test_KErrNone(r); sl@0: test(testDes==_L8("Humpty-Dumpty!")); sl@0: test(testDes.Length()==14); sl@0: sl@0: // Test with file open EFileShareAny|EFileRead sl@0: RFile file; sl@0: r=file.Open(TheFs,_L("Z:\\test\\t_rdsect.txt"),EFileShareAny|EFileRead); sl@0: test_KErrNone(r); sl@0: sl@0: r=TheFs.ReadFileSection(_L("Z:\\test\\t_rdsect.txt"),50,testDes,26); sl@0: test_KErrNone(r); sl@0: test(testDes==_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ")); sl@0: test(testDes.Length()==26); sl@0: sl@0: r=TheFs.ReadFileSection(_L("Z:\\test\\t_rdsect.txt"),76,testDes,10); sl@0: test_KErrNone(r); sl@0: test(testDes==_L8("0123456789")); sl@0: test(testDes.Length()==10); sl@0: sl@0: r=TheFs.ReadFileSection(_L("Z:\\test\\t_rdsect.txt"),86,testDes,14); sl@0: test_KErrNone(r); sl@0: test(testDes==_L8("Humpty-Dumpty!")); sl@0: test(testDes.Length()==14); sl@0: sl@0: file.Close(); sl@0: #else sl@0: // Test for MARM builds - oby file puts file in ROM (z:\test\) sl@0: // The file is the ASCII version sl@0: sl@0: test.Next(_L("read small descriptor\n")); sl@0: TBuf8<256> testDes; sl@0: TBuf8<27> temp1; sl@0: TInt r=TheFs.ReadFileSection(_L("Z:\\test\\T_RDSECT.txt"),0,temp1,26); sl@0: test_KErrNone(r); sl@0: test(temp1.Length()==26); sl@0: test(temp1==_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ")); sl@0: sl@0: TBuf8<11> temp2; sl@0: r=TheFs.ReadFileSection(_L("Z:\\test\\T_RDSECT.txt"),26,temp2,10); sl@0: test_KErrNone(r); sl@0: test(temp2.Length()==10); sl@0: #if !defined (UNICODE) sl@0: test(testDes==_L8("0123456789")); sl@0: #endif sl@0: r=TheFs.ReadFileSection(_L("Z:\\test\\T_RDSECT.txt"),36,testDes,14); sl@0: test_KErrNone(r); sl@0: test(testDes.Length()==14); sl@0: #if !defined (UNICODE) sl@0: test(testDes==_L8("Humpty-Dumpty!")); sl@0: #endif sl@0: r=TheFs.ReadFileSection(_L("Z:\\test\\T_RDSECT.txt"),50,testDes,26); sl@0: test_KErrNone(r); sl@0: test(testDes.Length()==26); sl@0: #if !defined (UNICODE) sl@0: test(testDes==_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ")); sl@0: #endif sl@0: r=TheFs.ReadFileSection(_L("Z:\\test\\T_RDSECT.txt"),76,testDes,10); sl@0: test_KErrNone(r); sl@0: test(testDes.Length()==10); sl@0: #if !defined (UNICODE) sl@0: test(testDes==_L8("0123456789")); sl@0: #endif sl@0: r=TheFs.ReadFileSection(_L("Z:\\test\\T_RDSECT.txt"),86,testDes,14); sl@0: test_KErrNone(r); sl@0: test(testDes.Length()==14); sl@0: #if !defined (UNICODE) sl@0: test(testDes==_L8("Humpty-Dumpty!")); sl@0: #endif sl@0: #endif sl@0: } sl@0: sl@0: LOCAL_C void DoTestsL() sl@0: // sl@0: // Do all tests sl@0: // sl@0: { sl@0: CreateTestFiles(); sl@0: #if !defined (_UNICODE) sl@0: Test1(); sl@0: Test2(); sl@0: Test3(); sl@0: TestErrors(); sl@0: #else sl@0: TestUnicode(); sl@0: #endif sl@0: TestZ(); sl@0: } sl@0: sl@0: GLDEF_C void CallTestsL(void) sl@0: // sl@0: // Test formatting sl@0: // sl@0: { sl@0: sl@0: test.Title(); sl@0: test.Start(_L("Testing filesystem on default drive")); sl@0: sl@0: TChar driveLetter; sl@0: if (IsSessionDriveLFFS(TheFs,driveLetter)) sl@0: { sl@0: test.Printf(_L("CallTestsL: Skipped: test does not run on LFFS.\n")); sl@0: return; sl@0: } sl@0: sl@0: DoTestsL(); sl@0: CheckDisk(); sl@0: sl@0: test.End(); sl@0: test.Close(); sl@0: return; sl@0: } sl@0: