sl@0: // Copyright (c) 1995-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: // sl@0: sl@0: #include sl@0: #include sl@0: #include "t_server.h" sl@0: sl@0: GLDEF_D RTest test(_L("T_GDIR")); sl@0: sl@0: LOCAL_D const TInt KFilesMax=9; sl@0: LOCAL_D const TInt KUidFilesMax=7; sl@0: LOCAL_D const TInt KDirsMax=4; sl@0: LOCAL_D TBool gFirstRun=ETrue; sl@0: LOCAL_D TPtrC test_dir(_L("\\F32-TST\\GDIR\\")); sl@0: LOCAL_D TPtrC test_dir_1(_L("\\F32-TST\\GDIR\\*")); sl@0: sl@0: class TUidFile sl@0: { sl@0: public: sl@0: TUidFile(const TText* aFileName,TUidType aUidType,const TText8* aContents); sl@0: public: sl@0: const TText* iFileName; sl@0: TUidType iUidType; sl@0: const TText8* iContents; sl@0: }; sl@0: sl@0: TUidFile::TUidFile(const TText* aFileName,TUidType aUidType,const TText8* aContents) sl@0: : iFileName(aFileName), iUidType(aUidType), iContents(aContents) sl@0: {} sl@0: sl@0: LOCAL_D TUidFile uidFiles[] = sl@0: { sl@0: TUidFile(_S("File1.TXT"), TUidType(TUid::Uid(1),TUid::Uid(2),TUid::Uid(731)),_S8("blarg blarg blarg")), sl@0: TUidFile(_S("asdf.asdf"), TUidType(TUid::Uid(55),TUid::Uid(2),TUid::Uid(731)),_S8("blarg")), sl@0: TUidFile(_S("another fiel"), TUidType(TUid::Uid(104),TUid::Uid(22),TUid::Uid(731)),_S8("blarg2")), sl@0: TUidFile(_S("another fiel1"), TUidType(TUid::Uid(7),TUid::Uid(23),TUid::Uid(131)),_S8("")), sl@0: TUidFile(_S("another fiel2"), TUidType(TUid::Uid(8),TUid::Uid(2),TUid::Uid(531)),_S8("asdf")), sl@0: TUidFile(_S("another fiel3"), TUidType(TUid::Uid(9),TUid::Uid(22),TUid::Uid(531)),_S8("blar")), sl@0: TUidFile(_S("another fiel4"), TUidType(TUid::Uid(10),TUid::Uid(23),TUid::Uid(231)),_S8("blarg blarg blarg asdlfjasdfasdfasdfasdfasdfadfafa")) sl@0: }; sl@0: sl@0: LOCAL_D const TText* fileNames[] = sl@0: { sl@0: _S("B1.B3"),_S("B2.B2"),_S("B3.B1"), sl@0: _S("A1.A3"),_S("A2.A2"),_S("A3.A1"), sl@0: _S("Z1.Z3"),_S("Z2.Z2"),_S("Z3.Z1") sl@0: }; sl@0: sl@0: LOCAL_D const TText* dirNames[] = sl@0: { sl@0: _S("DB1"), sl@0: _S("DA1"), sl@0: _S("DZ1"), sl@0: _S("DD1") sl@0: }; sl@0: sl@0: inline TName files(TInt anIndex) sl@0: {return(TName(fileNames[anIndex]));} sl@0: inline TName dirs(TInt anIndex) sl@0: {return(TName(dirNames[anIndex]));} sl@0: sl@0: LOCAL_C void displayDir(const CDir& aDir,TInt& aDirCount,TInt& aFileCount) sl@0: // sl@0: // Display the contents of a directory list. sl@0: // sl@0: { sl@0: sl@0: TInt count=aDir.Count(); sl@0: TInt i=0; sl@0: TInt fCount=0; sl@0: TInt dCount=0; sl@0: while (i\n"),&e.iName); sl@0: } sl@0: else sl@0: { sl@0: fCount++; sl@0: test.Printf(_L("%- 16S %+ 8d\n"),&e.iName,e.iSize); sl@0: } sl@0: } sl@0: test.Printf(_L("Dirs = %d Files = %d\n"),dCount,fCount); sl@0: aFileCount=fCount; sl@0: aDirCount=dCount; sl@0: } sl@0: sl@0: LOCAL_C void createFile(const TUidFile& aFileName) sl@0: // sl@0: // Create a file in the test directory. sl@0: // sl@0: { sl@0: sl@0: TCheckedUid checkedUid(aFileName.iUidType); sl@0: TPtrC fileName(aFileName.iFileName); sl@0: TAutoClose file; sl@0: TInt r=file.iObj.Replace(TheFs,fileName,EFileWrite); sl@0: test(r==KErrNone); sl@0: TPtrC8 uidBuf((TUint8*)&checkedUid,sizeof(TCheckedUid)); sl@0: r=file.iObj.Write(uidBuf); sl@0: test(r==KErrNone); sl@0: TPtrC8 contents(aFileName.iContents); sl@0: r=file.iObj.Write(contents); sl@0: test(r==KErrNone); sl@0: } sl@0: sl@0: LOCAL_C void createFile(TInt anIndex) sl@0: // sl@0: // Create a file in the test directory. sl@0: // sl@0: { sl@0: sl@0: TFileName fName; sl@0: TName name=files(anIndex); sl@0: fName.Format(_L("%S%S"),&test_dir,&name); sl@0: TBuf<0x80> mes; sl@0: mes.Format(_L("Create file %S"),&fName); sl@0: test.Next(mes); sl@0: // sl@0: TAutoClose file; sl@0: TInt r=file.iObj.Replace(TheFs,fName,EFileWrite); sl@0: test(r==KErrNone); sl@0: TBuf8<36> b((TUint8*)"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"); sl@0: b.SetLength(anIndex+1); sl@0: r=file.iObj.Write(b); sl@0: test(r==KErrNone); sl@0: } sl@0: sl@0: LOCAL_C void createDir(TInt anIndex) sl@0: // sl@0: // Create a dir in the test directory. sl@0: // sl@0: { sl@0: sl@0: TFileName dName; sl@0: TName name=dirs(anIndex); sl@0: dName.Format(_L("%S%S\\"),&test_dir,&name); sl@0: TBuf<0x80> mes; sl@0: mes.Format(_L("Create dir %S"),&dName); sl@0: test.Next(mes); sl@0: // sl@0: TInt r=TheFs.MkDir(dName); sl@0: test(r==KErrNone); sl@0: } sl@0: sl@0: LOCAL_C void testSetup() sl@0: // sl@0: // Setup the test environment. sl@0: // sl@0: { sl@0: sl@0: test.Next(_L("Remove test directory")); sl@0: CDir* pD; sl@0: TInt r=TheFs.GetDir(test_dir_1,KEntryAttMaskSupported,EDirsLast,pD); sl@0: test(r==KErrNone || r==KErrNotFound || r==KErrPathNotFound); sl@0: if (r==KErrNone) sl@0: { sl@0: TInt count=pD->Count(); sl@0: TInt i=0; sl@0: while (i noName=_L("asdf.idd"); sl@0: parser.Set(session.Drive(),&noName,NULL); sl@0: r=TheFs.GetDir(parser.FullName(),KEntryAttMaskSupported,EDirsFirst,pD); sl@0: test(r==KErrNone); sl@0: test(pD->Count()==0); sl@0: delete pD; sl@0: } sl@0: sl@0: LOCAL_C void MatchUidFile(TInt aUidFile,TInt anEntryNum,const CDir* aFileList) sl@0: // sl@0: // Check aUidFile matches anEntryNum sl@0: // sl@0: { sl@0: sl@0: test(aUidFileCount(); sl@0: test(anEntryNum contents; sl@0: r=f.Read(sizeof(TCheckedUid),contents); sl@0: test(r==KErrNone); sl@0: TPtrC8 uidFileContents(uidFiles[aUidFile].iContents); sl@0: test(contents==uidFileContents); sl@0: r=f.Read(contents); sl@0: test(r==KErrNone); sl@0: test(contents.Length()==0); sl@0: f.Close(); sl@0: } sl@0: sl@0: LOCAL_C TInt PrintUid(TInt anEntryNum,const CDir* aFileList) sl@0: // sl@0: // Check aUidFile matches anEntryNum sl@0: // sl@0: { sl@0: sl@0: TInt count=aFileList->Count(); sl@0: test(anEntryNum matchName=_L("*.txt"); sl@0: TUidType matchUid(TUid::Null(),TUid::Uid(2),TUid::Null()); sl@0: CDir* fileList; sl@0: TInt r=TheFs.GetDir(matchName,matchUid,EAscending,fileList); sl@0: test(r==KErrNone); sl@0: TInt count=fileList->Count(); sl@0: test(count==1); sl@0: MatchUidFile(0,0,fileList); sl@0: delete fileList; sl@0: sl@0: matchName=_L("*.*"); sl@0: matchUid=TUidType(TUid::Uid(1),TUid::Uid(2),TUid::Uid(731)); sl@0: r=TheFs.GetDir(matchName,matchUid,EAscending,fileList); sl@0: test(r==KErrNone); sl@0: count=fileList->Count(); sl@0: test(count==1); sl@0: MatchUidFile(0,0,fileList); sl@0: delete fileList; sl@0: sl@0: matchName=_L("*.*"); sl@0: matchUid=TUidType(TUid::Null(),TUid::Uid(2),TUid::Null()); sl@0: r=TheFs.GetDir(matchName,matchUid,ESortByName|EAscending,fileList); sl@0: test(r==KErrNone); sl@0: count=fileList->Count(); sl@0: test(count==3); sl@0: MatchUidFile(0,2,fileList); sl@0: MatchUidFile(1,1,fileList); sl@0: MatchUidFile(4,0,fileList); sl@0: delete fileList; sl@0: sl@0: matchName=_L("*.*"); sl@0: matchUid=TUidType(TUid::Null(),TUid::Null(),TUid::Uid(731)); sl@0: r=TheFs.GetDir(matchName,matchUid,ESortByName|EAscending,fileList); sl@0: test(r==KErrNone); sl@0: count=fileList->Count(); sl@0: test(count==3); sl@0: MatchUidFile(2,0,fileList); sl@0: MatchUidFile(1,1,fileList); sl@0: MatchUidFile(0,2,fileList); sl@0: delete fileList; sl@0: sl@0: matchName=_L("*.*"); sl@0: r=TheFs.GetDir(matchName,KEntryAttNormal,ESortByUid|EAscending,fileList); sl@0: test(r==KErrNone); sl@0: count=fileList->Count(); sl@0: MatchUidFile(4,0,fileList); sl@0: MatchUidFile(1,1,fileList); sl@0: MatchUidFile(0,2,fileList); sl@0: MatchUidFile(5,3,fileList); sl@0: MatchUidFile(2,4,fileList); sl@0: MatchUidFile(3,5,fileList); sl@0: MatchUidFile(6,6,fileList); sl@0: for (i=7;iCount(); sl@0: #if defined(__WINS__) sl@0: test(count==0); sl@0: #else sl@0: test.Printf(_L("Count=%d\n"),count); sl@0: while(count--) sl@0: PrintUid(count,fileList); sl@0: // test(count==1); sl@0: // TEntry entry; sl@0: // entry=(*fileList)[0]; sl@0: // test(entry.iName.MatchF(_L("EFILE.EXE"))!=KErrNotFound); sl@0: #endif sl@0: delete fileList; sl@0: } sl@0: sl@0: LOCAL_C void testGetFilesExcept() sl@0: // sl@0: // Get all files except read only ... sl@0: // sl@0: { sl@0: sl@0: MakeFile(_L("\\F32-TST\\GDIR\\RONLY1.CCC"),KEntryAttReadOnly); sl@0: MakeFile(_L("\\F32-TST\\GDIR\\RONLY2.CCC"),KEntryAttReadOnly); sl@0: MakeFile(_L("\\F32-TST\\GDIR\\RW1.CCC")); sl@0: MakeFile(_L("\\F32-TST\\GDIR\\RW2.CCC")); sl@0: MakeFile(_L("\\F32-TST\\GDIR\\SYSTEM1.CCC"),KEntryAttSystem); sl@0: MakeFile(_L("\\F32-TST\\GDIR\\SYSTEM2.CCC"),KEntryAttSystem); sl@0: sl@0: test.Next(_L("Can match only read only files")); sl@0: TUint onlyRO=KEntryAttReadOnly|KEntryAttMatchExclusive; sl@0: CDir* fileList; sl@0: TInt r=TheFs.GetDir(_L("\\F32-TST\\GDIR\\*.CCC"),onlyRO,EAscending,fileList); sl@0: test(r==KErrNone); sl@0: TInt count=fileList->Count(); sl@0: test(count==2); sl@0: sl@0: TEntry entry; sl@0: entry=(*fileList)[0]; sl@0: test(entry.iName.MatchF(_L("RONLY1.CCC"))!=KErrNotFound); sl@0: entry=(*fileList)[1]; sl@0: test(entry.iName.MatchF(_L("RONLY2.CCC"))!=KErrNotFound); sl@0: delete fileList; sl@0: sl@0: test.Next(_L("Can match everything except read only files")); sl@0: TUint excludeRO=KEntryAttReadOnly|KEntryAttMatchExclude; sl@0: r=TheFs.GetDir(_L("\\F32-TST\\GDIR\\*.CCC"),excludeRO,EAscending,fileList); sl@0: test(r==KErrNone); sl@0: count=fileList->Count(); sl@0: test(count==4); sl@0: sl@0: entry=(*fileList)[0]; sl@0: test(entry.iName.MatchF(_L("RW1.CCC"))!=KErrNotFound); sl@0: entry=(*fileList)[1]; sl@0: test(entry.iName.MatchF(_L("RW2.CCC"))!=KErrNotFound); sl@0: entry=(*fileList)[2]; sl@0: test(entry.iName.MatchF(_L("SYSTEM1.CCC"))!=KErrNotFound); sl@0: entry=(*fileList)[3]; sl@0: test(entry.iName.MatchF(_L("SYSTEM2.CCC"))!=KErrNotFound); sl@0: delete fileList; sl@0: sl@0: test.Next(_L("Can match everything except system and readonly files")); sl@0: TUint excludeSystemAndRO=KEntryAttReadOnly|KEntryAttSystem|KEntryAttMatchExclude; sl@0: r=TheFs.GetDir(_L("\\F32-TST\\GDIR\\*.CCC"),excludeSystemAndRO,EAscending,fileList); sl@0: test(r==KErrNone); sl@0: count=fileList->Count(); sl@0: test(count==2); sl@0: sl@0: entry=(*fileList)[0]; sl@0: test(entry.iName.MatchF(_L("RW1.CCC"))!=KErrNotFound); sl@0: entry=(*fileList)[1]; sl@0: test(entry.iName.MatchF(_L("RW2.CCC"))!=KErrNotFound); sl@0: delete fileList; sl@0: sl@0: r=TheFs.SetAtt(_L("\\F32-TST\\GDIR\\RONLY1.CCC"),0,KEntryAttReadOnly); sl@0: test(r==KErrNone); sl@0: r=TheFs.SetAtt(_L("\\F32-TST\\GDIR\\RONLY2.CCC"),0,KEntryAttReadOnly); sl@0: test(r==KErrNone); sl@0: } sl@0: sl@0: LOCAL_C void testGetHidden() sl@0: // sl@0: // Match hidden files and directories sl@0: // sl@0: { sl@0: sl@0: test.Next(_L("Match hidden files and directories")); sl@0: MakeFile(_L("File.qqq")); sl@0: MakeFile(_L("FileHidden.qqq")); sl@0: MakeFile(_L("FileSystem.qqq")); sl@0: MakeFile(_L("FileHiddenSystem.qqq")); sl@0: MakeDir(_L("\\F32-TST\\GDIR\\Dir.qqq\\")); sl@0: MakeDir(_L("\\F32-TST\\GDIR\\Dirhidden.qqq\\")); sl@0: MakeDir(_L("\\F32-TST\\GDIR\\Dirsystem.qqq\\")); sl@0: MakeDir(_L("\\F32-TST\\GDIR\\Dirhiddensystem.qqq\\")); sl@0: sl@0: TInt r=TheFs.SetAtt(_L("FileHidden.qqq"),KEntryAttHidden,0); sl@0: test(r==KErrNone); sl@0: r=TheFs.SetAtt(_L("Filesystem.qqq"),KEntryAttSystem,0); sl@0: test(r==KErrNone); sl@0: r=TheFs.SetAtt(_L("FilehiddenSystem.qqq"),KEntryAttSystem|KEntryAttHidden,0); sl@0: test(r==KErrNone); sl@0: r=TheFs.SetAtt(_L("dirhidden.qqq"),KEntryAttHidden,0); sl@0: test(r==KErrNone); sl@0: r=TheFs.SetAtt(_L("dirsystem.qqq"),KEntryAttSystem,0); sl@0: test(r==KErrNone); sl@0: r=TheFs.SetAtt(_L("dirhiddensystem.qqq"),KEntryAttSystem|KEntryAttHidden,0); sl@0: test(r==KErrNone); sl@0: sl@0: // Files and directories not hidden or system sl@0: CDir* dir; sl@0: r=TheFs.GetDir(_L("*.qqq"),KEntryAttDir,ESortByName,dir); sl@0: test(r==KErrNone); sl@0: TInt count=dir->Count(); sl@0: test(count==2); sl@0: TEntry entry; sl@0: entry=(*dir)[0]; sl@0: test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound); sl@0: entry=(*dir)[1]; sl@0: test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound); sl@0: delete dir; sl@0: sl@0: // Files only sl@0: r=TheFs.GetDir(_L("*.qqq"),KEntryAttNormal,ESortByName,dir); sl@0: test(r==KErrNone); sl@0: count=dir->Count(); sl@0: test(count==1); sl@0: entry=(*dir)[0]; sl@0: test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound); sl@0: delete dir; sl@0: sl@0: // Directories only sl@0: r=TheFs.GetDir(_L("*.qqq"),KEntryAttDir|KEntryAttMatchExclusive,ESortByName,dir); sl@0: test(r==KErrNone); sl@0: count=dir->Count(); sl@0: test(count==1); sl@0: entry=(*dir)[0]; sl@0: test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound); sl@0: delete dir; sl@0: sl@0: // Files + hidden sl@0: r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden,ESortByName,dir); sl@0: test(r==KErrNone); sl@0: count=dir->Count(); sl@0: test(count==2); sl@0: entry=(*dir)[0]; sl@0: test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound); sl@0: entry=(*dir)[1]; sl@0: test(entry.iName.MatchF(_L("filehidden.qqq"))!=KErrNotFound); sl@0: delete dir; sl@0: sl@0: // Files + system sl@0: r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden,ESortByName,dir); sl@0: test(r==KErrNone); sl@0: count=dir->Count(); sl@0: test(count==2); sl@0: entry=(*dir)[0]; sl@0: test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound); sl@0: entry=(*dir)[1]; sl@0: test(entry.iName.MatchF(_L("filehidden.qqq"))!=KErrNotFound); sl@0: delete dir; sl@0: sl@0: // Files + hidden + system sl@0: r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden|KEntryAttSystem,ESortByName,dir); sl@0: test(r==KErrNone); sl@0: count=dir->Count(); sl@0: test(count==4); sl@0: entry=(*dir)[0]; sl@0: test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound); sl@0: entry=(*dir)[1]; sl@0: test(entry.iName.MatchF(_L("filehidden.qqq"))!=KErrNotFound); sl@0: entry=(*dir)[2]; sl@0: test(entry.iName.MatchF(_L("filehiddensystem.qqq"))!=KErrNotFound); sl@0: entry=(*dir)[3]; sl@0: test(entry.iName.MatchF(_L("filesystem.qqq"))!=KErrNotFound); sl@0: delete dir; sl@0: sl@0: // Dirs + hidden sl@0: r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden|KEntryAttDir|KEntryAttMatchExclusive,ESortByName,dir); sl@0: test(r==KErrNone); sl@0: count=dir->Count(); sl@0: test(count==2); sl@0: entry=(*dir)[0]; sl@0: test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound); sl@0: entry=(*dir)[1]; sl@0: test(entry.iName.MatchF(_L("dirhidden.qqq"))!=KErrNotFound); sl@0: delete dir; sl@0: sl@0: // Dirs + system sl@0: r=TheFs.GetDir(_L("*.qqq"),KEntryAttSystem|KEntryAttDir|KEntryAttMatchExclusive,ESortByName,dir); sl@0: test(r==KErrNone); sl@0: count=dir->Count(); sl@0: test(count==2); sl@0: entry=(*dir)[0]; sl@0: test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound); sl@0: entry=(*dir)[1]; sl@0: test(entry.iName.MatchF(_L("dirsystem.qqq"))!=KErrNotFound); sl@0: delete dir; sl@0: sl@0: // Dirs + hidden + system sl@0: r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden|KEntryAttSystem|KEntryAttDir|KEntryAttMatchExclusive,ESortByName,dir); sl@0: test(r==KErrNone); sl@0: count=dir->Count(); sl@0: test(count==4); sl@0: entry=(*dir)[0]; sl@0: test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound); sl@0: entry=(*dir)[1]; sl@0: test(entry.iName.MatchF(_L("dirhidden.qqq"))!=KErrNotFound); sl@0: entry=(*dir)[2]; sl@0: test(entry.iName.MatchF(_L("dirhiddensystem.qqq"))!=KErrNotFound); sl@0: entry=(*dir)[3]; sl@0: test(entry.iName.MatchF(_L("dirsystem.qqq"))!=KErrNotFound); sl@0: sl@0: delete dir; sl@0: sl@0: // Files + Dirs + hidden sl@0: r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden|KEntryAttDir,ESortByName,dir); sl@0: test(r==KErrNone); sl@0: count=dir->Count(); sl@0: test(count==4); sl@0: entry=(*dir)[0]; sl@0: test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound); sl@0: entry=(*dir)[1]; sl@0: test(entry.iName.MatchF(_L("dirhidden.qqq"))!=KErrNotFound); sl@0: entry=(*dir)[2]; sl@0: test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound); sl@0: entry=(*dir)[3]; sl@0: test(entry.iName.MatchF(_L("filehidden.qqq"))!=KErrNotFound); sl@0: delete dir; sl@0: sl@0: // Files + Dirs + system sl@0: r=TheFs.GetDir(_L("*.qqq"),KEntryAttSystem|KEntryAttDir,ESortByName,dir); sl@0: test(r==KErrNone); sl@0: count=dir->Count(); sl@0: test(count==4); sl@0: entry=(*dir)[0]; sl@0: test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound); sl@0: entry=(*dir)[1]; sl@0: test(entry.iName.MatchF(_L("dirsystem.qqq"))!=KErrNotFound); sl@0: entry=(*dir)[2]; sl@0: test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound); sl@0: entry=(*dir)[3]; sl@0: test(entry.iName.MatchF(_L("filesystem.qqq"))!=KErrNotFound); sl@0: delete dir; sl@0: sl@0: // Files + Dirs + hidden + system sl@0: r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden|KEntryAttSystem|KEntryAttDir,ESortByName,dir); sl@0: test(r==KErrNone); sl@0: count=dir->Count(); sl@0: test(count==8); sl@0: entry=(*dir)[0]; sl@0: test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound); sl@0: entry=(*dir)[1]; sl@0: test(entry.iName.MatchF(_L("dirhidden.qqq"))!=KErrNotFound); sl@0: entry=(*dir)[2]; sl@0: test(entry.iName.MatchF(_L("dirhiddensystem.qqq"))!=KErrNotFound); sl@0: entry=(*dir)[3]; sl@0: test(entry.iName.MatchF(_L("dirsystem.qqq"))!=KErrNotFound); sl@0: entry=(*dir)[4]; sl@0: test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound); sl@0: entry=(*dir)[5]; sl@0: test(entry.iName.MatchF(_L("filehidden.qqq"))!=KErrNotFound); sl@0: entry=(*dir)[6]; sl@0: test(entry.iName.MatchF(_L("filehiddensystem.qqq"))!=KErrNotFound); sl@0: entry=(*dir)[7]; sl@0: test(entry.iName.MatchF(_L("filesystem.qqq"))!=KErrNotFound); sl@0: delete dir; sl@0: } sl@0: sl@0: LOCAL_D TFileName gDirDescendingBaseName=_L("\\F32-TST\\GDIR\\TDIRDESCENDING\\"); sl@0: LOCAL_D TFileName gDirDescendingEntryName[6]= sl@0: { sl@0: _L("\\F32-TST\\GDIR\\TDIRDESCENDING\\aaaa"), sl@0: _L("\\F32-TST\\GDIR\\TDIRDESCENDING\\ssss"), sl@0: _L("\\F32-TST\\GDIR\\TDIRDESCENDING\\ZZZZ"), sl@0: _L("\\F32-TST\\GDIR\\TDIRDESCENDING\\aaaa.directory\\"), sl@0: _L("\\F32-TST\\GDIR\\TDIRDESCENDING\\SSSS.dir\\"), sl@0: _L("\\F32-TST\\GDIR\\TDIRDESCENDING\\ZZZZDirectory\\") sl@0: }; sl@0: sl@0: LOCAL_C void TestDirDescendingOrder(const TDesC& aResult,const CDir& aDirList) sl@0: // sl@0: // Test aDirList against aResult sl@0: // sl@0: { sl@0: sl@0: TLex lex(aResult); sl@0: TInt count=0; sl@0: while (!lex.Eos()) sl@0: { sl@0: lex.Mark(); sl@0: while(lex.Get().IsDigit()) {}; sl@0: TLex temp(lex.MarkedToken()); sl@0: TInt result; sl@0: temp.Val(result); sl@0: TFileName base=gDirDescendingBaseName; sl@0: TEntry entry=aDirList[count]; sl@0: base+=entry.iName; sl@0: if (entry.IsDir()) sl@0: base+=_L("\\"); sl@0: test(base==gDirDescendingEntryName[result]); sl@0: count++; sl@0: } sl@0: } sl@0: sl@0: LOCAL_C void testDirDescending() sl@0: // sl@0: // Test EDirDescending sl@0: // sl@0: { sl@0: sl@0: test.Next(_L("Test EDirDescending")); sl@0: MakeDir(gDirDescendingBaseName); sl@0: MakeFile(gDirDescendingEntryName[0]); sl@0: MakeFile(gDirDescendingEntryName[1]); sl@0: MakeFile(gDirDescendingEntryName[2]); sl@0: MakeDir(gDirDescendingEntryName[3]); sl@0: MakeDir(gDirDescendingEntryName[4]); sl@0: MakeDir(gDirDescendingEntryName[5]); sl@0: sl@0: // Test DirFirst - EDescending sl@0: CDir* dir; sl@0: TUint sortOrder=ESortByName|EDirsFirst|EDescending; sl@0: TInt r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir); sl@0: test(r==KErrNone); sl@0: // TBuf8<16> result=_L("2,1,0,3,4,5"); sl@0: TBuf<16> result=_L("2,1,0,3,4,5"); sl@0: sl@0: TestDirDescendingOrder(result,*dir); sl@0: delete dir; sl@0: // Test DirFirst - EAscending sl@0: sortOrder=ESortByName|EDirsFirst; sl@0: r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir); sl@0: test(r==KErrNone); sl@0: result=_L("3,4,5,0,1,2"); sl@0: TestDirDescendingOrder(result,*dir); sl@0: delete dir; sl@0: sl@0: // Test DirLast - EDescending sl@0: sortOrder=ESortByName|EDirsLast|EDescending; sl@0: r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir); sl@0: test(r==KErrNone); sl@0: result=_L("3,4,5,2,1,0"); sl@0: TestDirDescendingOrder(result,*dir); sl@0: delete dir; sl@0: // Test DirLast - EAscending sl@0: sortOrder=ESortByName|EDirsLast; sl@0: r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir); sl@0: test(r==KErrNone); sl@0: result=_L("0,1,2,3,4,5"); sl@0: TestDirDescendingOrder(result,*dir); sl@0: delete dir; sl@0: sl@0: // Test DirFirst - EDirDescending sl@0: sortOrder=ESortByName|EDirsFirst|EDirDescending; sl@0: r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir); sl@0: test(r==KErrNone); sl@0: result=_L("5,4,3,0,1,2"); sl@0: TestDirDescendingOrder(result,*dir); sl@0: delete dir; sl@0: // Test DirLast - EDirDescending sl@0: sortOrder=ESortByName|EDirsLast|EDirDescending; sl@0: r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir); sl@0: test(r==KErrNone); sl@0: result=_L("0,1,2,5,4,3"); sl@0: TestDirDescendingOrder(result,*dir); sl@0: delete dir; sl@0: sl@0: // Test DirFirst - EDescending|EDirDescending sl@0: sortOrder=ESortByName|EDirsFirst|EDescending|EDirDescending; sl@0: r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir); sl@0: test(r==KErrNone); sl@0: result=_L("2,1,0,5,4,3"); sl@0: TestDirDescendingOrder(result,*dir); sl@0: delete dir; sl@0: // Test DirLast - EDescending|EDirDescending sl@0: sortOrder=ESortByName|EDirsLast|EDirDescending|EDescending; sl@0: r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir); sl@0: test(r==KErrNone); sl@0: result=_L("5,4,3,2,1,0"); sl@0: TestDirDescendingOrder(result,*dir); sl@0: delete dir; sl@0: sl@0: // Test DirNoOrder - EDescending|EDirDescending sl@0: sortOrder=ESortByName|EDescending|EDirDescending; sl@0: r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir); sl@0: test(r==KErrNone); sl@0: result=_L("5,2,4,1,3,0"); sl@0: TestDirDescendingOrder(result,*dir); sl@0: delete dir; sl@0: // Test DirNoOrder - EDescending sl@0: sortOrder=ESortByName|EDescending; sl@0: r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir); sl@0: test(r==KErrNone); sl@0: result=_L("5,2,4,1,3,0"); sl@0: TestDirDescendingOrder(result,*dir); sl@0: delete dir; sl@0: // Test DirNoOrder - EAscending sl@0: sortOrder=ESortByName; sl@0: r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir); sl@0: test(r==KErrNone); sl@0: result=_L("0,3,1,4,2,5"); sl@0: TestDirDescendingOrder(result,*dir); sl@0: delete dir; sl@0: } sl@0: sl@0: //--------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_GDIR-0815 sl@0: //! @SYMTestType UT sl@0: //! @SYMREQ DEF122894 sl@0: //! @SYMTestCaseDesc This testcase tests the boundary condition of file name collation (8 characters). sl@0: //! @SYMTestActions Creates file "xxxxxxxx2.dat" and "Xxxxxxxx1.dat" under same directory, sl@0: //! retrieves dir list via GetDir(), sort list by name, check order of the file listed. sl@0: //! @SYMTestExpectedResults File "Xxxxxxxx1.dat" should be listed before "xxxxxxxx2.dat". sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //--------------------------------------------- sl@0: void TestDEF122894() sl@0: { sl@0: test.Next(_L("Test \"DEF122894: Defect in RFs GetDir() API\"")); sl@0: MakeFile(_L("\\F32-TST\\GDIR\\DEF122894\\xxxxxxxx2.dat")); sl@0: MakeFile(_L("\\F32-TST\\GDIR\\DEF122894\\Xxxxxxxx1.dat")); sl@0: CDir* dir; sl@0: TInt r=TheFs.GetDir(_L("\\F32-TST\\GDIR\\DEF122894\\"),KEntryAttMaskSupported,ESortByName|EAscending,dir); sl@0: test(r==KErrNone); sl@0: test(dir->Count() == 2); sl@0: TEntry entry1, entry2; sl@0: entry1 = (*dir)[0]; sl@0: entry2 = (*dir)[1]; sl@0: test(entry1.iName.Compare(_L("Xxxxxxxx1.dat")) == 0); sl@0: test(entry2.iName.Compare(_L("xxxxxxxx2.dat")) == 0); sl@0: delete dir; sl@0: } sl@0: sl@0: GLDEF_C void CallTestsL() sl@0: // sl@0: // Test directory handling. sl@0: // sl@0: { sl@0: sl@0: CreateTestDirectory(_L("\\F32-TST\\GDIR\\")); sl@0: if (gFirstRun) sl@0: { sl@0: gFirstRun=EFalse; sl@0: testZDirectory(); sl@0: testZGetDirByUid(); sl@0: } sl@0: sl@0: testSetup(); sl@0: testDir(); sl@0: testDisplayFiles(); sl@0: testGetDirByUid(); sl@0: testGetFilesExcept(); sl@0: testGetHidden(); sl@0: testDirDescending(); sl@0: TestDEF122894(); sl@0: DeleteTestDirectory(); sl@0: } sl@0: