Update contrib.
1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
20 GLDEF_D RTest test(_L("T_GDIR"));
22 LOCAL_D const TInt KFilesMax=9;
23 LOCAL_D const TInt KUidFilesMax=7;
24 LOCAL_D const TInt KDirsMax=4;
25 LOCAL_D TBool gFirstRun=ETrue;
26 LOCAL_D TPtrC test_dir(_L("\\F32-TST\\GDIR\\"));
27 LOCAL_D TPtrC test_dir_1(_L("\\F32-TST\\GDIR\\*"));
32 TUidFile(const TText* aFileName,TUidType aUidType,const TText8* aContents);
34 const TText* iFileName;
36 const TText8* iContents;
39 TUidFile::TUidFile(const TText* aFileName,TUidType aUidType,const TText8* aContents)
40 : iFileName(aFileName), iUidType(aUidType), iContents(aContents)
43 LOCAL_D TUidFile uidFiles[] =
45 TUidFile(_S("File1.TXT"), TUidType(TUid::Uid(1),TUid::Uid(2),TUid::Uid(731)),_S8("blarg blarg blarg")),
46 TUidFile(_S("asdf.asdf"), TUidType(TUid::Uid(55),TUid::Uid(2),TUid::Uid(731)),_S8("blarg")),
47 TUidFile(_S("another fiel"), TUidType(TUid::Uid(104),TUid::Uid(22),TUid::Uid(731)),_S8("blarg2")),
48 TUidFile(_S("another fiel1"), TUidType(TUid::Uid(7),TUid::Uid(23),TUid::Uid(131)),_S8("")),
49 TUidFile(_S("another fiel2"), TUidType(TUid::Uid(8),TUid::Uid(2),TUid::Uid(531)),_S8("asdf")),
50 TUidFile(_S("another fiel3"), TUidType(TUid::Uid(9),TUid::Uid(22),TUid::Uid(531)),_S8("blar")),
51 TUidFile(_S("another fiel4"), TUidType(TUid::Uid(10),TUid::Uid(23),TUid::Uid(231)),_S8("blarg blarg blarg asdlfjasdfasdfasdfasdfasdfadfafa"))
54 LOCAL_D const TText* fileNames[] =
56 _S("B1.B3"),_S("B2.B2"),_S("B3.B1"),
57 _S("A1.A3"),_S("A2.A2"),_S("A3.A1"),
58 _S("Z1.Z3"),_S("Z2.Z2"),_S("Z3.Z1")
61 LOCAL_D const TText* dirNames[] =
69 inline TName files(TInt anIndex)
70 {return(TName(fileNames[anIndex]));}
71 inline TName dirs(TInt anIndex)
72 {return(TName(dirNames[anIndex]));}
74 LOCAL_C void displayDir(const CDir& aDir,TInt& aDirCount,TInt& aFileCount)
76 // Display the contents of a directory list.
80 TInt count=aDir.Count();
86 const TEntry& e=aDir[i++];
90 test.Printf(_L("%- 16S <DIR>\n"),&e.iName);
95 test.Printf(_L("%- 16S %+ 8d\n"),&e.iName,e.iSize);
98 test.Printf(_L("Dirs = %d Files = %d\n"),dCount,fCount);
103 LOCAL_C void createFile(const TUidFile& aFileName)
105 // Create a file in the test directory.
109 TCheckedUid checkedUid(aFileName.iUidType);
110 TPtrC fileName(aFileName.iFileName);
111 TAutoClose<RFile> file;
112 TInt r=file.iObj.Replace(TheFs,fileName,EFileWrite);
114 TPtrC8 uidBuf((TUint8*)&checkedUid,sizeof(TCheckedUid));
115 r=file.iObj.Write(uidBuf);
117 TPtrC8 contents(aFileName.iContents);
118 r=file.iObj.Write(contents);
122 LOCAL_C void createFile(TInt anIndex)
124 // Create a file in the test directory.
129 TName name=files(anIndex);
130 fName.Format(_L("%S%S"),&test_dir,&name);
132 mes.Format(_L("Create file %S"),&fName);
135 TAutoClose<RFile> file;
136 TInt r=file.iObj.Replace(TheFs,fName,EFileWrite);
138 TBuf8<36> b((TUint8*)"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
139 b.SetLength(anIndex+1);
140 r=file.iObj.Write(b);
144 LOCAL_C void createDir(TInt anIndex)
146 // Create a dir in the test directory.
151 TName name=dirs(anIndex);
152 dName.Format(_L("%S%S\\"),&test_dir,&name);
154 mes.Format(_L("Create dir %S"),&dName);
157 TInt r=TheFs.MkDir(dName);
161 LOCAL_C void testSetup()
163 // Setup the test environment.
167 test.Next(_L("Remove test directory"));
169 TInt r=TheFs.GetDir(test_dir_1,KEntryAttMaskSupported,EDirsLast,pD);
170 test(r==KErrNone || r==KErrNotFound || r==KErrPathNotFound);
173 TInt count=pD->Count();
177 const TEntry& e=(*pD)[i++];
181 name.Format(_L("%S%S\\"),&test_dir,&e.iName);
188 name.Format(_L("%S%S"),&test_dir,&e.iName);
189 r=TheFs.Delete(name);
197 test.Next(_L("Create test files"));
202 test.Next(_L("Create test directories"));
208 LOCAL_C void testDir()
210 // Setup the test environment.
216 test.Next(_L("Test directory handling"));
218 TInt r=TheFs.GetDir(test_dir_1,KEntryAttMaskSupported,EDirsLast,pD);
220 displayDir(*pD,dCount,fCount);
221 test(dCount==4 && fCount==9);
224 test.Next(_L("Attributes: NULL"));
225 r=TheFs.GetDir(test_dir_1,NULL,EDirsLast,pD);
227 displayDir(*pD,dCount,fCount);
228 test(dCount==0 && fCount==9);
231 test.Next(_L("Attributes: KEntryAttDir & EDescending sort"));
232 r=TheFs.GetDir(test_dir_1,KEntryAttDir,ESortByName|EDescending,pD);
234 displayDir(*pD,dCount,fCount);
235 test(dCount==4 && fCount==9);
238 test.Next(_L("Attributes: Excl,Dir"));
239 r=TheFs.GetDir(test_dir_1,KEntryAttMatchExclusive|KEntryAttDir,ESortByName|EDescending,pD);
241 displayDir(*pD,dCount,fCount);
242 test(dCount==4 && fCount==0);
247 test.Next(_L("Test split directories and files"));
248 r=TheFs.GetDir(test_dir_1,KEntryAttMaskSupported,ESortByName,pD,pD2);
250 test.Printf(_L("FileList:\n"));
251 displayDir(*pD,dCount,fCount);
252 test(dCount==4 && fCount==9);
253 test.Printf(_L("DirList:\n"));
254 displayDir(*pD2,dCount,fCount);
255 test(dCount==4 && fCount==0);
259 test.Next(_L("Attributes: NULL"));
260 r=TheFs.GetDir(test_dir_1,NULL,ESortByName,pD,pD2);
262 test.Printf(_L("FileList:\n"));
263 displayDir(*pD,dCount,fCount);
264 test(dCount==0 && fCount==9);
265 test.Printf(_L("DirList:\n"));
266 displayDir(*pD2,dCount,fCount);
267 test(dCount==4 && fCount==0);
271 test.Next(_L("Attributes: KEntryAttDir"));
272 r=TheFs.GetDir(test_dir_1,KEntryAttDir,ESortByName,pD,pD2);
274 test.Printf(_L("FileList:\n"));
275 displayDir(*pD,dCount,fCount);
276 test(dCount==4 && fCount==9);
277 test.Printf(_L("DirList:\n"));
278 displayDir(*pD2,dCount,fCount);
279 test(dCount==4 && fCount==0);
283 test.Next(_L("Attributes: Excl,Dir"));
284 r=TheFs.GetDir(test_dir_1,KEntryAttMatchExclusive|KEntryAttDir,ESortByName,pD,pD2);
286 test.Printf(_L("FileList:\n"));
287 displayDir(*pD,dCount,fCount);
288 test(dCount==4 && fCount==0);
289 test.Printf(_L("DirList:\n"));
290 displayDir(*pD2,dCount,fCount);
291 test(dCount==4 && fCount==0);
296 LOCAL_C void testZDirectory()
298 // Display Z directory
302 test.Next(_L("Test Z:"));
305 TInt r=TheFs.GetDir(_L("Z:\\*"),KEntryAttMaskSupported,EDirsFirst,pD);
307 displayDir(*pD,dCount,fCount);
311 LOCAL_C void testDisplayFiles()
313 // Display some files
317 test.Next(_L("Display contents of current directory"));
319 TInt r=TheFs.GetDir(gSessionPath,KEntryAttMaskSupported,EDirsFirst,pD);
322 displayDir(*pD,dCount,fCount);
325 TParsePtrC session(gSessionPath);
327 TBuf<16> noName=_L("asdf.idd");
328 parser.Set(session.Drive(),&noName,NULL);
329 r=TheFs.GetDir(parser.FullName(),KEntryAttMaskSupported,EDirsFirst,pD);
331 test(pD->Count()==0);
335 LOCAL_C void MatchUidFile(TInt aUidFile,TInt anEntryNum,const CDir* aFileList)
337 // Check aUidFile matches anEntryNum
341 test(aUidFile<KUidFilesMax);
342 TInt count=aFileList->Count();
343 test(anEntryNum<count);
344 TEntry entry=(*aFileList)[anEntryNum];
346 TPtrC uidFileName(uidFiles[aUidFile].iFileName);
347 test(entry.iName==uidFileName);
348 test(entry.iType==uidFiles[aUidFile].iUidType);
351 TInt r=f.Open(TheFs,entry.iName,EFileRead);
354 r=f.Read(sizeof(TCheckedUid),contents);
356 TPtrC8 uidFileContents(uidFiles[aUidFile].iContents);
357 test(contents==uidFileContents);
360 test(contents.Length()==0);
364 LOCAL_C TInt PrintUid(TInt anEntryNum,const CDir* aFileList)
366 // Check aUidFile matches anEntryNum
370 TInt count=aFileList->Count();
371 test(anEntryNum<count);
372 TEntry entry=(*aFileList)[anEntryNum];
373 test.Printf(_L("Entry name = %S UID=%d\n"),&entry.iName,entry.iType[2]);
374 return(entry.iType[2].iUid);
377 LOCAL_C void testGetDirByUid()
379 // Get directory contents by matching UIDs
383 test.Next(_L("Get directory contents by matching UIDs"));
386 createFile(uidFiles[i]);
388 TBuf<16> matchName=_L("*.txt");
389 TUidType matchUid(TUid::Null(),TUid::Uid(2),TUid::Null());
391 TInt r=TheFs.GetDir(matchName,matchUid,EAscending,fileList);
393 TInt count=fileList->Count();
395 MatchUidFile(0,0,fileList);
399 matchUid=TUidType(TUid::Uid(1),TUid::Uid(2),TUid::Uid(731));
400 r=TheFs.GetDir(matchName,matchUid,EAscending,fileList);
402 count=fileList->Count();
404 MatchUidFile(0,0,fileList);
408 matchUid=TUidType(TUid::Null(),TUid::Uid(2),TUid::Null());
409 r=TheFs.GetDir(matchName,matchUid,ESortByName|EAscending,fileList);
411 count=fileList->Count();
413 MatchUidFile(0,2,fileList);
414 MatchUidFile(1,1,fileList);
415 MatchUidFile(4,0,fileList);
419 matchUid=TUidType(TUid::Null(),TUid::Null(),TUid::Uid(731));
420 r=TheFs.GetDir(matchName,matchUid,ESortByName|EAscending,fileList);
422 count=fileList->Count();
424 MatchUidFile(2,0,fileList);
425 MatchUidFile(1,1,fileList);
426 MatchUidFile(0,2,fileList);
430 r=TheFs.GetDir(matchName,KEntryAttNormal,ESortByUid|EAscending,fileList);
432 count=fileList->Count();
433 MatchUidFile(4,0,fileList);
434 MatchUidFile(1,1,fileList);
435 MatchUidFile(0,2,fileList);
436 MatchUidFile(5,3,fileList);
437 MatchUidFile(2,4,fileList);
438 MatchUidFile(3,5,fileList);
439 MatchUidFile(6,6,fileList);
440 for (i=7;i<count;i++)
443 entry=(*fileList)[i];
444 test(entry.iType[2].iUid==0);
445 PrintUid(i,fileList);
451 LOCAL_C void testZGetDirByUid()
453 // Get directory contents by matching UIDs from Z:
457 TUidType matchUid(TUid::Null(),TUid::Uid(0x1000008c),TUid::Null());
459 TInt r=TheFs.GetDir(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)?_L("Z:\\SYS\\BIN\\"):_L("Z:\\SYSTEM\\BIN\\"),matchUid,EAscending,fileList);
461 TInt count=fileList->Count();
462 #if defined(__WINS__)
465 test.Printf(_L("Count=%d\n"),count);
467 PrintUid(count,fileList);
470 // entry=(*fileList)[0];
471 // test(entry.iName.MatchF(_L("EFILE.EXE"))!=KErrNotFound);
476 LOCAL_C void testGetFilesExcept()
478 // Get all files except read only ...
482 MakeFile(_L("\\F32-TST\\GDIR\\RONLY1.CCC"),KEntryAttReadOnly);
483 MakeFile(_L("\\F32-TST\\GDIR\\RONLY2.CCC"),KEntryAttReadOnly);
484 MakeFile(_L("\\F32-TST\\GDIR\\RW1.CCC"));
485 MakeFile(_L("\\F32-TST\\GDIR\\RW2.CCC"));
486 MakeFile(_L("\\F32-TST\\GDIR\\SYSTEM1.CCC"),KEntryAttSystem);
487 MakeFile(_L("\\F32-TST\\GDIR\\SYSTEM2.CCC"),KEntryAttSystem);
489 test.Next(_L("Can match only read only files"));
490 TUint onlyRO=KEntryAttReadOnly|KEntryAttMatchExclusive;
492 TInt r=TheFs.GetDir(_L("\\F32-TST\\GDIR\\*.CCC"),onlyRO,EAscending,fileList);
494 TInt count=fileList->Count();
498 entry=(*fileList)[0];
499 test(entry.iName.MatchF(_L("RONLY1.CCC"))!=KErrNotFound);
500 entry=(*fileList)[1];
501 test(entry.iName.MatchF(_L("RONLY2.CCC"))!=KErrNotFound);
504 test.Next(_L("Can match everything except read only files"));
505 TUint excludeRO=KEntryAttReadOnly|KEntryAttMatchExclude;
506 r=TheFs.GetDir(_L("\\F32-TST\\GDIR\\*.CCC"),excludeRO,EAscending,fileList);
508 count=fileList->Count();
511 entry=(*fileList)[0];
512 test(entry.iName.MatchF(_L("RW1.CCC"))!=KErrNotFound);
513 entry=(*fileList)[1];
514 test(entry.iName.MatchF(_L("RW2.CCC"))!=KErrNotFound);
515 entry=(*fileList)[2];
516 test(entry.iName.MatchF(_L("SYSTEM1.CCC"))!=KErrNotFound);
517 entry=(*fileList)[3];
518 test(entry.iName.MatchF(_L("SYSTEM2.CCC"))!=KErrNotFound);
521 test.Next(_L("Can match everything except system and readonly files"));
522 TUint excludeSystemAndRO=KEntryAttReadOnly|KEntryAttSystem|KEntryAttMatchExclude;
523 r=TheFs.GetDir(_L("\\F32-TST\\GDIR\\*.CCC"),excludeSystemAndRO,EAscending,fileList);
525 count=fileList->Count();
528 entry=(*fileList)[0];
529 test(entry.iName.MatchF(_L("RW1.CCC"))!=KErrNotFound);
530 entry=(*fileList)[1];
531 test(entry.iName.MatchF(_L("RW2.CCC"))!=KErrNotFound);
534 r=TheFs.SetAtt(_L("\\F32-TST\\GDIR\\RONLY1.CCC"),0,KEntryAttReadOnly);
536 r=TheFs.SetAtt(_L("\\F32-TST\\GDIR\\RONLY2.CCC"),0,KEntryAttReadOnly);
540 LOCAL_C void testGetHidden()
542 // Match hidden files and directories
546 test.Next(_L("Match hidden files and directories"));
547 MakeFile(_L("File.qqq"));
548 MakeFile(_L("FileHidden.qqq"));
549 MakeFile(_L("FileSystem.qqq"));
550 MakeFile(_L("FileHiddenSystem.qqq"));
551 MakeDir(_L("\\F32-TST\\GDIR\\Dir.qqq\\"));
552 MakeDir(_L("\\F32-TST\\GDIR\\Dirhidden.qqq\\"));
553 MakeDir(_L("\\F32-TST\\GDIR\\Dirsystem.qqq\\"));
554 MakeDir(_L("\\F32-TST\\GDIR\\Dirhiddensystem.qqq\\"));
556 TInt r=TheFs.SetAtt(_L("FileHidden.qqq"),KEntryAttHidden,0);
558 r=TheFs.SetAtt(_L("Filesystem.qqq"),KEntryAttSystem,0);
560 r=TheFs.SetAtt(_L("FilehiddenSystem.qqq"),KEntryAttSystem|KEntryAttHidden,0);
562 r=TheFs.SetAtt(_L("dirhidden.qqq"),KEntryAttHidden,0);
564 r=TheFs.SetAtt(_L("dirsystem.qqq"),KEntryAttSystem,0);
566 r=TheFs.SetAtt(_L("dirhiddensystem.qqq"),KEntryAttSystem|KEntryAttHidden,0);
569 // Files and directories not hidden or system
571 r=TheFs.GetDir(_L("*.qqq"),KEntryAttDir,ESortByName,dir);
573 TInt count=dir->Count();
577 test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound);
579 test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound);
583 r=TheFs.GetDir(_L("*.qqq"),KEntryAttNormal,ESortByName,dir);
588 test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound);
592 r=TheFs.GetDir(_L("*.qqq"),KEntryAttDir|KEntryAttMatchExclusive,ESortByName,dir);
597 test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound);
601 r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden,ESortByName,dir);
606 test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound);
608 test(entry.iName.MatchF(_L("filehidden.qqq"))!=KErrNotFound);
612 r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden,ESortByName,dir);
617 test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound);
619 test(entry.iName.MatchF(_L("filehidden.qqq"))!=KErrNotFound);
622 // Files + hidden + system
623 r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden|KEntryAttSystem,ESortByName,dir);
628 test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound);
630 test(entry.iName.MatchF(_L("filehidden.qqq"))!=KErrNotFound);
632 test(entry.iName.MatchF(_L("filehiddensystem.qqq"))!=KErrNotFound);
634 test(entry.iName.MatchF(_L("filesystem.qqq"))!=KErrNotFound);
638 r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden|KEntryAttDir|KEntryAttMatchExclusive,ESortByName,dir);
643 test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound);
645 test(entry.iName.MatchF(_L("dirhidden.qqq"))!=KErrNotFound);
649 r=TheFs.GetDir(_L("*.qqq"),KEntryAttSystem|KEntryAttDir|KEntryAttMatchExclusive,ESortByName,dir);
654 test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound);
656 test(entry.iName.MatchF(_L("dirsystem.qqq"))!=KErrNotFound);
659 // Dirs + hidden + system
660 r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden|KEntryAttSystem|KEntryAttDir|KEntryAttMatchExclusive,ESortByName,dir);
665 test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound);
667 test(entry.iName.MatchF(_L("dirhidden.qqq"))!=KErrNotFound);
669 test(entry.iName.MatchF(_L("dirhiddensystem.qqq"))!=KErrNotFound);
671 test(entry.iName.MatchF(_L("dirsystem.qqq"))!=KErrNotFound);
675 // Files + Dirs + hidden
676 r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden|KEntryAttDir,ESortByName,dir);
681 test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound);
683 test(entry.iName.MatchF(_L("dirhidden.qqq"))!=KErrNotFound);
685 test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound);
687 test(entry.iName.MatchF(_L("filehidden.qqq"))!=KErrNotFound);
690 // Files + Dirs + system
691 r=TheFs.GetDir(_L("*.qqq"),KEntryAttSystem|KEntryAttDir,ESortByName,dir);
696 test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound);
698 test(entry.iName.MatchF(_L("dirsystem.qqq"))!=KErrNotFound);
700 test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound);
702 test(entry.iName.MatchF(_L("filesystem.qqq"))!=KErrNotFound);
705 // Files + Dirs + hidden + system
706 r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden|KEntryAttSystem|KEntryAttDir,ESortByName,dir);
711 test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound);
713 test(entry.iName.MatchF(_L("dirhidden.qqq"))!=KErrNotFound);
715 test(entry.iName.MatchF(_L("dirhiddensystem.qqq"))!=KErrNotFound);
717 test(entry.iName.MatchF(_L("dirsystem.qqq"))!=KErrNotFound);
719 test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound);
721 test(entry.iName.MatchF(_L("filehidden.qqq"))!=KErrNotFound);
723 test(entry.iName.MatchF(_L("filehiddensystem.qqq"))!=KErrNotFound);
725 test(entry.iName.MatchF(_L("filesystem.qqq"))!=KErrNotFound);
729 LOCAL_D TFileName gDirDescendingBaseName=_L("\\F32-TST\\GDIR\\TDIRDESCENDING\\");
730 LOCAL_D TFileName gDirDescendingEntryName[6]=
732 _L("\\F32-TST\\GDIR\\TDIRDESCENDING\\aaaa"),
733 _L("\\F32-TST\\GDIR\\TDIRDESCENDING\\ssss"),
734 _L("\\F32-TST\\GDIR\\TDIRDESCENDING\\ZZZZ"),
735 _L("\\F32-TST\\GDIR\\TDIRDESCENDING\\aaaa.directory\\"),
736 _L("\\F32-TST\\GDIR\\TDIRDESCENDING\\SSSS.dir\\"),
737 _L("\\F32-TST\\GDIR\\TDIRDESCENDING\\ZZZZDirectory\\")
740 LOCAL_C void TestDirDescendingOrder(const TDesC& aResult,const CDir& aDirList)
742 // Test aDirList against aResult
751 while(lex.Get().IsDigit()) {};
752 TLex temp(lex.MarkedToken());
755 TFileName base=gDirDescendingBaseName;
756 TEntry entry=aDirList[count];
760 test(base==gDirDescendingEntryName[result]);
765 LOCAL_C void testDirDescending()
767 // Test EDirDescending
771 test.Next(_L("Test EDirDescending"));
772 MakeDir(gDirDescendingBaseName);
773 MakeFile(gDirDescendingEntryName[0]);
774 MakeFile(gDirDescendingEntryName[1]);
775 MakeFile(gDirDescendingEntryName[2]);
776 MakeDir(gDirDescendingEntryName[3]);
777 MakeDir(gDirDescendingEntryName[4]);
778 MakeDir(gDirDescendingEntryName[5]);
780 // Test DirFirst - EDescending
782 TUint sortOrder=ESortByName|EDirsFirst|EDescending;
783 TInt r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir);
785 // TBuf8<16> result=_L("2,1,0,3,4,5");
786 TBuf<16> result=_L("2,1,0,3,4,5");
788 TestDirDescendingOrder(result,*dir);
790 // Test DirFirst - EAscending
791 sortOrder=ESortByName|EDirsFirst;
792 r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir);
794 result=_L("3,4,5,0,1,2");
795 TestDirDescendingOrder(result,*dir);
798 // Test DirLast - EDescending
799 sortOrder=ESortByName|EDirsLast|EDescending;
800 r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir);
802 result=_L("3,4,5,2,1,0");
803 TestDirDescendingOrder(result,*dir);
805 // Test DirLast - EAscending
806 sortOrder=ESortByName|EDirsLast;
807 r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir);
809 result=_L("0,1,2,3,4,5");
810 TestDirDescendingOrder(result,*dir);
813 // Test DirFirst - EDirDescending
814 sortOrder=ESortByName|EDirsFirst|EDirDescending;
815 r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir);
817 result=_L("5,4,3,0,1,2");
818 TestDirDescendingOrder(result,*dir);
820 // Test DirLast - EDirDescending
821 sortOrder=ESortByName|EDirsLast|EDirDescending;
822 r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir);
824 result=_L("0,1,2,5,4,3");
825 TestDirDescendingOrder(result,*dir);
828 // Test DirFirst - EDescending|EDirDescending
829 sortOrder=ESortByName|EDirsFirst|EDescending|EDirDescending;
830 r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir);
832 result=_L("2,1,0,5,4,3");
833 TestDirDescendingOrder(result,*dir);
835 // Test DirLast - EDescending|EDirDescending
836 sortOrder=ESortByName|EDirsLast|EDirDescending|EDescending;
837 r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir);
839 result=_L("5,4,3,2,1,0");
840 TestDirDescendingOrder(result,*dir);
843 // Test DirNoOrder - EDescending|EDirDescending
844 sortOrder=ESortByName|EDescending|EDirDescending;
845 r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir);
847 result=_L("5,2,4,1,3,0");
848 TestDirDescendingOrder(result,*dir);
850 // Test DirNoOrder - EDescending
851 sortOrder=ESortByName|EDescending;
852 r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir);
854 result=_L("5,2,4,1,3,0");
855 TestDirDescendingOrder(result,*dir);
857 // Test DirNoOrder - EAscending
858 sortOrder=ESortByName;
859 r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir);
861 result=_L("0,3,1,4,2,5");
862 TestDirDescendingOrder(result,*dir);
866 //---------------------------------------------
867 //! @SYMTestCaseID PBASE-T_GDIR-0815
869 //! @SYMREQ DEF122894
870 //! @SYMTestCaseDesc This testcase tests the boundary condition of file name collation (8 characters).
871 //! @SYMTestActions Creates file "xxxxxxxx2.dat" and "Xxxxxxxx1.dat" under same directory,
872 //! retrieves dir list via GetDir(), sort list by name, check order of the file listed.
873 //! @SYMTestExpectedResults File "Xxxxxxxx1.dat" should be listed before "xxxxxxxx2.dat".
874 //! @SYMTestPriority High
875 //! @SYMTestStatus Implemented
876 //---------------------------------------------
879 test.Next(_L("Test \"DEF122894: Defect in RFs GetDir() API\""));
880 MakeFile(_L("\\F32-TST\\GDIR\\DEF122894\\xxxxxxxx2.dat"));
881 MakeFile(_L("\\F32-TST\\GDIR\\DEF122894\\Xxxxxxxx1.dat"));
883 TInt r=TheFs.GetDir(_L("\\F32-TST\\GDIR\\DEF122894\\"),KEntryAttMaskSupported,ESortByName|EAscending,dir);
885 test(dir->Count() == 2);
886 TEntry entry1, entry2;
889 test(entry1.iName.Compare(_L("Xxxxxxxx1.dat")) == 0);
890 test(entry2.iName.Compare(_L("xxxxxxxx2.dat")) == 0);
894 GLDEF_C void CallTestsL()
896 // Test directory handling.
900 CreateTestDirectory(_L("\\F32-TST\\GDIR\\"));
912 testGetFilesExcept();
916 DeleteTestDirectory();