| 0 |      1 | // Copyright (c) 1996-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".
 | 
|  |      7 | //
 | 
|  |      8 | // Initial Contributors:
 | 
|  |      9 | // Nokia Corporation - initial contribution.
 | 
|  |     10 | //
 | 
|  |     11 | // Contributors:
 | 
|  |     12 | //
 | 
|  |     13 | // Description:
 | 
|  |     14 | //
 | 
|  |     15 | 
 | 
|  |     16 | #include <f32file.h>
 | 
|  |     17 | #include <e32test.h>
 | 
|  |     18 | #include "t_server.h"
 | 
|  |     19 | 
 | 
|  |     20 | GLDEF_D RTest test(_L("T_SCAN"));
 | 
|  |     21 | 
 | 
|  |     22 | LOCAL_C void BuildTestDir()
 | 
|  |     23 | //
 | 
|  |     24 | // Build up a test directory structure
 | 
|  |     25 | //
 | 
|  |     26 | 
 | 
|  |     27 | /*
 | 
|  |     28 | //               SCANTEST
 | 
|  |     29 | //                  | 
 | 
|  |     30 | //  File1 File2 Left File3 Right Empty(Directory)
 | 
|  |     31 | //             /  \        /  \
 | 
|  |     32 | //           Dir2  Dir3 File4 File5
 | 
|  |     33 | //            |      |
 | 
|  |     34 | //           File6 Dir4----Hidden---HiddenFile       
 | 
|  |     35 | //                   |      /  \
 | 
|  |     36 | //                 File7 File8 System
 | 
|  |     37 | //                              |
 | 
|  |     38 | //                             File9
 | 
|  |     39 | */
 | 
|  |     40 | 	{
 | 
|  |     41 | 
 | 
|  |     42 | 	MakeDir(_L("\\F32-TST\\SCANTEST\\Empty\\"));
 | 
|  |     43 | 
 | 
|  |     44 | 	MakeFile(_L("\\F32-TST\\SCANTEST\\File1"));
 | 
|  |     45 | 	MakeFile(_L("\\F32-TST\\SCANTEST\\File2"));
 | 
|  |     46 | 	MakeFile(_L("\\F32-TST\\SCANTEST\\File3"));
 | 
|  |     47 | 	
 | 
|  |     48 | 	MakeFile(_L("\\F32-TST\\SCANTEST\\Right\\File4"));
 | 
|  |     49 | 	MakeFile(_L("\\F32-TST\\SCANTEST\\Right\\File5"));
 | 
|  |     50 | 
 | 
|  |     51 | 	MakeFile(_L("\\F32-TST\\SCANTEST\\Left\\Dir2\\File6"));
 | 
|  |     52 | 	MakeFile(_L("\\F32-TST\\SCANTEST\\Left\\Dir3\\Dir4\\File7"));
 | 
|  |     53 | 
 | 
|  |     54 | 	MakeFile(_L("\\F32-TST\\SCANTEST\\Left\\Dir3\\Dir4\\Hidden\\File8"));
 | 
|  |     55 | 	MakeFile(_L("\\F32-TST\\SCANTEST\\Left\\Dir3\\Dir4\\Hidden\\HiddenFile"));
 | 
|  |     56 | 	MakeFile(_L("\\F32-TST\\SCANTEST\\Left\\Dir3\\Dir4\\Hidden\\System\\File9"));
 | 
|  |     57 | 
 | 
|  |     58 | 	TInt r;
 | 
|  |     59 | 	r=TheFs.SetAtt(_L("\\F32-TST\\SCANTEST\\Left\\Dir3\\Dir4\\Hidden"), KEntryAttHidden, 0);
 | 
|  |     60 | 	test(r==KErrNone);
 | 
|  |     61 | 	r=TheFs.SetAtt(_L("\\F32-TST\\SCANTEST\\Left\\Dir3\\Dir4\\Hidden\\HiddenFile"), KEntryAttHidden, 0);
 | 
|  |     62 | 	test(r==KErrNone);
 | 
|  |     63 | 	r=TheFs.SetAtt(_L("\\F32-TST\\SCANTEST\\Left\\Dir3\\Dir4\\Hidden\\System"), KEntryAttSystem, 0);
 | 
|  |     64 | 	test(r==KErrNone);
 | 
|  |     65 | 	}
 | 
|  |     66 | 
 | 
|  |     67 | LOCAL_C void Test1()
 | 
|  |     68 | //
 | 
|  |     69 | // Test all methods
 | 
|  |     70 | //
 | 
|  |     71 | 	{
 | 
|  |     72 | 	
 | 
|  |     73 | 	test.Next(_L("Create scanner"));
 | 
|  |     74 | 	CDirScan* scanner=CDirScan::NewL(TheFs);
 | 
|  |     75 | 	TParse dirName;
 | 
|  |     76 | 	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\"),dirName);
 | 
|  |     77 | 	scanner->SetScanDataL(dirName.FullName(),KEntryAttDir,ESortByName);
 | 
|  |     78 | 	CDir* entryList;
 | 
|  |     79 | //
 | 
|  |     80 | 	test.Next(_L("Scan top level directory"));
 | 
|  |     81 | 	scanner->NextL(entryList);
 | 
|  |     82 | 	TInt count=entryList->Count();
 | 
|  |     83 | 	test(count==6);
 | 
|  |     84 | 	TEntry entry=(*entryList)[0];
 | 
|  |     85 | 	test(entry.iName==_L("Empty"));
 | 
|  |     86 | 	entry=(*entryList)[1];
 | 
|  |     87 | 	test(entry.iName==_L("File1"));
 | 
|  |     88 | 	entry=(*entryList)[2];
 | 
|  |     89 | 	test(entry.iName==_L("File2"));
 | 
|  |     90 | 	entry=(*entryList)[3];
 | 
|  |     91 | 	test(entry.iName==_L("File3"));
 | 
|  |     92 | 	entry=(*entryList)[4];
 | 
|  |     93 | 	test(entry.iName==_L("Left"));
 | 
|  |     94 | 	entry=(*entryList)[5];
 | 
|  |     95 | 	test(entry.iName==_L("Right"));
 | 
|  |     96 | 	delete entryList;
 | 
|  |     97 | //
 | 
|  |     98 | 	test.Next(_L("Reset scanner"));
 | 
|  |     99 | 	scanner->SetScanDataL(dirName.FullName(),KEntryAttDir,ESortByName);
 | 
|  |    100 | //
 | 
|  |    101 | 	test.Next(_L("Scan ascending: ScanTest directory"));
 | 
|  |    102 | 	scanner->NextL(entryList);
 | 
|  |    103 | 	count=entryList->Count();
 | 
|  |    104 | 	test(count==6);
 | 
|  |    105 | 	entry=(*entryList)[0];
 | 
|  |    106 | 	test(entry.iName==_L("Empty"));
 | 
|  |    107 | 	entry=(*entryList)[1];
 | 
|  |    108 | 	test(entry.iName==_L("File1"));
 | 
|  |    109 | 	entry=(*entryList)[2];
 | 
|  |    110 | 	test(entry.iName==_L("File2"));
 | 
|  |    111 | 	entry=(*entryList)[3];
 | 
|  |    112 | 	test(entry.iName==_L("File3"));
 | 
|  |    113 | 	entry=(*entryList)[4];
 | 
|  |    114 | 	test(entry.iName==_L("Left"));
 | 
|  |    115 | 	entry=(*entryList)[5];
 | 
|  |    116 | 	test(entry.iName==_L("Right"));
 | 
|  |    117 | 	delete entryList;
 | 
|  |    118 | //
 | 
|  |    119 | 	test.Next(_L("Check next directory: Empty"));
 | 
|  |    120 | 	scanner->NextL(entryList);
 | 
|  |    121 | 	count=entryList->Count();
 | 
|  |    122 | 	test(count==0);
 | 
|  |    123 | 	delete entryList;
 | 
|  |    124 | //
 | 
|  |    125 | 	test.Next(_L("Check next directory: Left"));
 | 
|  |    126 | 	scanner->NextL(entryList);
 | 
|  |    127 | 	count=entryList->Count();
 | 
|  |    128 | 	test(count==2);
 | 
|  |    129 | 	entry=(*entryList)[0];
 | 
|  |    130 | 	test(entry.iName==_L("Dir2"));
 | 
|  |    131 | 	entry=(*entryList)[1];
 | 
|  |    132 | 	test(entry.iName==_L("Dir3"));
 | 
|  |    133 | 	delete entryList;
 | 
|  |    134 | //
 | 
|  |    135 | 	test.Next(_L("Check next directory: Left\\Dir2"));
 | 
|  |    136 | 	scanner->NextL(entryList);
 | 
|  |    137 | 	count=entryList->Count();
 | 
|  |    138 | 	test(count==1);
 | 
|  |    139 | 	entry=(*entryList)[0];
 | 
|  |    140 | 	//test(entry.iName==_L("File6"));
 | 
|  |    141 | 	delete entryList;
 | 
|  |    142 | //
 | 
|  |    143 | 	test.Next(_L("Check next directory: Left\\Dir3"));
 | 
|  |    144 | 	scanner->NextL(entryList);
 | 
|  |    145 | 	count=entryList->Count();
 | 
|  |    146 | 	test(count==1);
 | 
|  |    147 | 	entry=(*entryList)[0];
 | 
|  |    148 | 	test(entry.iName==_L("Dir4"));
 | 
|  |    149 | 	delete entryList;
 | 
|  |    150 | //
 | 
|  |    151 | 	test.Next(_L("Check next directory: Left\\Dir3\\Dir4"));
 | 
|  |    152 | 	scanner->NextL(entryList);
 | 
|  |    153 | 	count=entryList->Count();
 | 
|  |    154 | 	test(count==1);
 | 
|  |    155 | 	entry=(*entryList)[0];
 | 
|  |    156 | 	test(entry.iName==_L("File7"));
 | 
|  |    157 | 	delete entryList;
 | 
|  |    158 | //
 | 
|  |    159 | 	test.Next(_L("Check next directory: Right"));
 | 
|  |    160 | 	scanner->NextL(entryList);
 | 
|  |    161 | 	count=entryList->Count();
 | 
|  |    162 | 	test(count==2);
 | 
|  |    163 | 	entry=(*entryList)[0];
 | 
|  |    164 | 	test(entry.iName==_L("File4"));
 | 
|  |    165 | 	entry=(*entryList)[1];
 | 
|  |    166 | 	test(entry.iName==_L("File5"));
 | 
|  |    167 | 	delete entryList;
 | 
|  |    168 | //
 | 
|  |    169 | 	test.Next(_L("End of scan"));
 | 
|  |    170 | 	scanner->NextL(entryList);
 | 
|  |    171 | 	test(entryList==NULL);
 | 
|  |    172 | 	delete entryList;
 | 
|  |    173 | 	delete scanner;
 | 
|  |    174 | 	}	
 | 
|  |    175 | 
 | 
|  |    176 | LOCAL_C void Test2()
 | 
|  |    177 | //
 | 
|  |    178 | // Scan subset of test directory structure and test abs/rel paths
 | 
|  |    179 | //
 | 
|  |    180 | 	{
 | 
|  |    181 | 
 | 
|  |    182 | 	test.Next(_L("Scan descending: ScanTest\\Left "));
 | 
|  |    183 | 	CDirScan* scanner=CDirScan::NewL(TheFs);
 | 
|  |    184 | 	TParse dirName;
 | 
|  |    185 | 	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\LEFT\\"),dirName);
 | 
|  |    186 | 	scanner->SetScanDataL(dirName.FullName(),KEntryAttNormal,ESortByName|EDescending);
 | 
|  |    187 | //
 | 
|  |    188 | 	test.Next(_L("Check next directory: Left"));
 | 
|  |    189 | 	CDir* entryList;
 | 
|  |    190 | 	scanner->NextL(entryList);
 | 
|  |    191 | 	TInt count=entryList->Count();
 | 
|  |    192 | 	test(count==0);
 | 
|  |    193 | 	test(scanner->AbbreviatedPath()==_L("\\"));
 | 
|  |    194 | 	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\LEFT\\"),dirName);
 | 
|  |    195 | 	test(scanner->FullPath()==dirName.FullName());
 | 
|  |    196 | 	delete entryList;
 | 
|  |    197 | //
 | 
|  |    198 | 	test.Next(_L("Check next directory: Left\\Dir3"));
 | 
|  |    199 | 	scanner->NextL(entryList);
 | 
|  |    200 | 	count=entryList->Count();
 | 
|  |    201 | 	test(count==0);
 | 
|  |    202 | 	test(scanner->AbbreviatedPath()==_L("\\Dir3\\"));
 | 
|  |    203 | 	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\LEFT\\Dir3\\"),dirName);
 | 
|  |    204 | 	test(scanner->FullPath()==dirName.FullName());
 | 
|  |    205 | 	delete entryList;
 | 
|  |    206 | //
 | 
|  |    207 | 	test.Next(_L("Check next directory: Left\\Dir3\\Dir4"));
 | 
|  |    208 | 	scanner->NextL(entryList);
 | 
|  |    209 | 	count=entryList->Count();
 | 
|  |    210 | 	test(count==1);
 | 
|  |    211 | 	test((*entryList)[0].iName==_L("File7"));
 | 
|  |    212 | 	test(scanner->AbbreviatedPath()==_L("\\Dir3\\Dir4\\"));
 | 
|  |    213 | 	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\LEFT\\Dir3\\Dir4\\"),dirName);
 | 
|  |    214 | 	test(scanner->FullPath()==dirName.FullName());
 | 
|  |    215 | 	delete entryList;
 | 
|  |    216 | //
 | 
|  |    217 | 	test.Next(_L("Check next directory: Left\\Dir2"));
 | 
|  |    218 | 	scanner->NextL(entryList);
 | 
|  |    219 | 	count=entryList->Count();
 | 
|  |    220 | 	test(count==1);
 | 
|  |    221 | 	test((*entryList)[0].iName==_L("File6"));
 | 
|  |    222 | 	test(scanner->AbbreviatedPath()==_L("\\Dir2\\"));
 | 
|  |    223 | 	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\LEFT\\Dir2\\"),dirName);
 | 
|  |    224 | 	test(scanner->FullPath()==dirName.FullName());
 | 
|  |    225 | 	delete entryList;
 | 
|  |    226 | 	delete scanner;
 | 
|  |    227 | 	}
 | 
|  |    228 | 
 | 
|  |    229 | LOCAL_C void Test3()
 | 
|  |    230 | //
 | 
|  |    231 | // Print directory structure
 | 
|  |    232 | //
 | 
|  |    233 | 	{
 | 
|  |    234 | 
 | 
|  |    235 | 	test.Next(_L("List directory structure"));
 | 
|  |    236 | 	TheFs.SetAllocFailure(gAllocFailOff);
 | 
|  |    237 | 	TFileName sessionPath;
 | 
|  |    238 | 	TInt r=TheFs.SessionPath(sessionPath);
 | 
|  |    239 | 	test(r==KErrNone);
 | 
|  |    240 | 	r=TheFs.SetSessionPath(_L("N:\\"));
 | 
|  |    241 | 	test(r==KErrNone);
 | 
|  |    242 | 	TAutoClose<RFs> fs;
 | 
|  |    243 | 	r=fs.iObj.Connect();
 | 
|  |    244 | 	test(r==KErrNone);
 | 
|  |    245 | 	CDirScan* scanner=CDirScan::NewL(fs.iObj);
 | 
|  |    246 | 	TParse dirName;
 | 
|  |    247 | 	TheFs.Parse(sessionPath,dirName);
 | 
|  |    248 | 	scanner->SetScanDataL(dirName.FullName(),KEntryAttDir,ESortByName);
 | 
|  |    249 | 	CDir* entryList;
 | 
|  |    250 | 	FOREVER
 | 
|  |    251 | 		{
 | 
|  |    252 | 		scanner->NextL(entryList);
 | 
|  |    253 | 		if (entryList==NULL)
 | 
|  |    254 | 			break;
 | 
|  |    255 | 		TInt count=entryList->Count();
 | 
|  |    256 | 		while (count--)
 | 
|  |    257 | 			{
 | 
|  |    258 | 			TEntry data=(*entryList)[count];
 | 
|  |    259 | 			TBuf<KMaxFileName> path=scanner->AbbreviatedPath();
 | 
|  |    260 | 			test.Printf(_L("%S%S\n"),&path,&data.iName);
 | 
|  |    261 | 			}
 | 
|  |    262 | 		delete entryList;
 | 
|  |    263 | 		entryList=NULL;
 | 
|  |    264 | 		}
 | 
|  |    265 | 	delete scanner;
 | 
|  |    266 | 	r=TheFs.SetSessionPath(sessionPath);
 | 
|  |    267 | 	test(r==KErrNone);
 | 
|  |    268 | 	TheFs.SetAllocFailure(gAllocFailOn);
 | 
|  |    269 | 	}
 | 
|  |    270 | 
 | 
|  |    271 | LOCAL_C void Test4()
 | 
|  |    272 | //
 | 
|  |    273 | // Scan for a matching filename
 | 
|  |    274 | //
 | 
|  |    275 | 	{
 | 
|  |    276 | 
 | 
|  |    277 | 	test.Start(_L("Scan for a matching filename"));
 | 
|  |    278 | 	MakeFile(_L("\\F32-TST\\SCANTEST\\MaTCHteST.EXTENSION"));
 | 
|  |    279 | 	MakeFile(_L("\\F32-TST\\SCANTEST\\MATCH.EXT"));
 | 
|  |    280 | 	MakeFile(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\ANOTherteST.EXTENSION"));
 | 
|  |    281 | 	MakeFile(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\APPDLL.DLL"));
 | 
|  |    282 | 	MakeFile(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\TEST.EXTENSION"));
 | 
|  |    283 | 	MakeFile(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\DIR4\\MaTCHteST.EXTENSION"));
 | 
|  |    284 | 
 | 
|  |    285 | 	CDir* entryList;
 | 
|  |    286 | 	CDirScan* scanner=CDirScan::NewL(TheFs);
 | 
|  |    287 | 	TParse dirName;
 | 
|  |    288 | 
 | 
|  |    289 | 	test.Next(_L("Scan for MAT??.EXT")); // can't test for MAT*.EXT because shortname of MaTCHteST.EXTENSION
 | 
|  |    290 | 	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\MAT??.EXT"),dirName); // is MATCHT~1.EXT !!!
 | 
|  |    291 | 	scanner->SetScanDataL(dirName.FullName(),KEntryAttNormal,ESortByName);
 | 
|  |    292 | 	scanner->NextL(entryList);
 | 
|  |    293 | 	test((TInt)entryList);
 | 
|  |    294 | 	test(entryList->Count()==1);
 | 
|  |    295 | 	test((*entryList)[0].iName.MatchF(_L("MATCH.EXT"))!=KErrNotFound);
 | 
|  |    296 | 	test(scanner->AbbreviatedPath()==_L("\\"));
 | 
|  |    297 | 	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\"),dirName);
 | 
|  |    298 | 	test(scanner->FullPath()==dirName.FullName());
 | 
|  |    299 | 	delete entryList;
 | 
|  |    300 | 	FOREVER
 | 
|  |    301 | 		{
 | 
|  |    302 | 		scanner->NextL(entryList);
 | 
|  |    303 | 		if (entryList==NULL)
 | 
|  |    304 | 			break;
 | 
|  |    305 | 		test(entryList->Count()==0);
 | 
|  |    306 | 		delete entryList;
 | 
|  |    307 | 		}
 | 
|  |    308 | 
 | 
|  |    309 | 	test.Next(_L("Scan for *.EXTENSION"));
 | 
|  |    310 | 	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\*.EXTENSION"),dirName);
 | 
|  |    311 | 	scanner->SetScanDataL(dirName.FullName(),KEntryAttNormal,ESortByName);
 | 
|  |    312 | 	scanner->NextL(entryList);
 | 
|  |    313 | 	test((TInt)entryList);
 | 
|  |    314 | 	test(entryList->Count()==1);
 | 
|  |    315 | 	test((*entryList)[0].iName.MatchF(_L("MATCHTEST.EXTENSION"))!=KErrNotFound);
 | 
|  |    316 | 	test(scanner->AbbreviatedPath()==_L("\\"));
 | 
|  |    317 | 	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\"),dirName);
 | 
|  |    318 | 	test(scanner->FullPath()==dirName.FullName());
 | 
|  |    319 | 	do {
 | 
|  |    320 | 		delete entryList;
 | 
|  |    321 | 		scanner->NextL(entryList);
 | 
|  |    322 | 		test((TInt)entryList);
 | 
|  |    323 | 		} while (entryList->Count()==0);
 | 
|  |    324 | 	test(entryList->Count()==2);
 | 
|  |    325 | 	test((*entryList)[0].iName.MatchF(_L("ANOTHERTEST.EXTENSION"))!=KErrNotFound);
 | 
|  |    326 | 	test((*entryList)[1].iName.MatchF(_L("test.EXTENSION"))!=KErrNotFound);
 | 
|  |    327 | 	test(scanner->AbbreviatedPath().MatchF(_L("\\LEFT\\DIR3\\"))!=KErrNotFound);
 | 
|  |    328 | 	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\"),dirName);
 | 
|  |    329 | 	test(scanner->FullPath().MatchF(dirName.FullName())!=KErrNotFound);
 | 
|  |    330 | 	do {
 | 
|  |    331 | 		delete entryList;
 | 
|  |    332 | 		scanner->NextL(entryList);
 | 
|  |    333 | 		test((TInt)entryList);
 | 
|  |    334 | 		} while (entryList->Count()==0);
 | 
|  |    335 | 	test(entryList->Count()==1);
 | 
|  |    336 | 	test((*entryList)[0].iName.MatchF(_L("MATCHTEST.EXTENSION"))!=KErrNotFound);
 | 
|  |    337 | 	test(scanner->AbbreviatedPath().MatchF(_L("\\LEFT\\DIR3\\DIR4\\"))!=KErrNotFound);
 | 
|  |    338 | 	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\DIR4\\"),dirName);
 | 
|  |    339 | 	test(scanner->FullPath().MatchF(dirName.FullName())!=KErrNotFound);
 | 
|  |    340 | 	delete entryList;
 | 
|  |    341 | 	FOREVER
 | 
|  |    342 | 		{
 | 
|  |    343 | 		scanner->NextL(entryList);
 | 
|  |    344 | 		if (entryList==NULL)
 | 
|  |    345 | 			break;
 | 
|  |    346 | 		test(entryList->Count()==0);
 | 
|  |    347 | 		delete entryList;
 | 
|  |    348 | 		}
 | 
|  |    349 | 
 | 
|  |    350 | 	test.Next(_L("Scan for APPDLL.DLL"));
 | 
|  |    351 | 	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\APPDLL.DLL"),dirName);
 | 
|  |    352 | 	scanner->SetScanDataL(dirName.FullName(),KEntryAttNormal,ESortByName);
 | 
|  |    353 | 	FOREVER
 | 
|  |    354 | 		{
 | 
|  |    355 | 		scanner->NextL(entryList);
 | 
|  |    356 | 		if (entryList->Count()!=0)
 | 
|  |    357 | 			break;
 | 
|  |    358 | 		test((TInt)entryList);
 | 
|  |    359 | 		delete entryList;
 | 
|  |    360 | 		}
 | 
|  |    361 | 	test(entryList->Count()==1);
 | 
|  |    362 | 	test((*entryList)[0].iName==_L("APPDLL.DLL"));
 | 
|  |    363 | 	test(scanner->AbbreviatedPath().MatchF(_L("\\LEFT\\DIR3\\"))!=KErrNotFound);
 | 
|  |    364 | 	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\"),dirName);
 | 
|  |    365 | 	test(scanner->FullPath().MatchF(dirName.FullName())!=KErrNotFound);
 | 
|  |    366 | 	delete entryList;
 | 
|  |    367 | 	FOREVER
 | 
|  |    368 | 		{
 | 
|  |    369 | 		scanner->NextL(entryList);
 | 
|  |    370 | 		if (entryList==NULL)
 | 
|  |    371 | 			break;
 | 
|  |    372 | 		test(entryList->Count()==0);
 | 
|  |    373 | 		delete entryList;
 | 
|  |    374 | 		}
 | 
|  |    375 | 	delete scanner;
 | 
|  |    376 | 	test.End();
 | 
|  |    377 | 	}		
 | 
|  |    378 | 
 | 
|  |    379 | LOCAL_C void Test5()
 | 
|  |    380 | //
 | 
|  |    381 | // Do a scan of Z:
 | 
|  |    382 | //
 | 
|  |    383 | 	{
 | 
|  |    384 | 
 | 
|  |    385 | 	test.Next(_L("List Z: directory structure"));
 | 
|  |    386 | 	CDirScan* scanner=CDirScan::NewLC(TheFs);
 | 
|  |    387 | 	TPtrC romPath(_L("Z:\\"));
 | 
|  |    388 | 	TParse dirName;
 | 
|  |    389 | 	TInt r=TheFs.Parse(romPath,dirName);
 | 
|  |    390 | 	test(r==KErrNone);
 | 
|  |    391 | 	scanner->SetScanDataL(dirName.FullName(),KEntryAttDir,ESortByName);
 | 
|  |    392 | 	CDir* entryList;
 | 
|  |    393 | 	FOREVER
 | 
|  |    394 | 		{
 | 
|  |    395 | 		scanner->NextL(entryList);
 | 
|  |    396 | 		if (entryList==NULL)
 | 
|  |    397 | 			break;
 | 
|  |    398 | 		TInt count=entryList->Count();
 | 
|  |    399 | 		while (count--)
 | 
|  |    400 | 			{
 | 
|  |    401 | 			TEntry data=(*entryList)[count];
 | 
|  |    402 | 			TBuf<KMaxFileName> path=scanner->AbbreviatedPath();
 | 
|  |    403 | 			test.Printf(_L("%S%S\n"),&path,&data.iName);
 | 
|  |    404 | 			}
 | 
|  |    405 | 		delete entryList;
 | 
|  |    406 | 		entryList=NULL;
 | 
|  |    407 | 		}
 | 
|  |    408 | 	CleanupStack::PopAndDestroy();
 | 
|  |    409 | 	}
 | 
|  |    410 | 
 | 
|  |    411 | LOCAL_C void Test6()
 | 
|  |    412 | //
 | 
|  |    413 | // Scan up a directory tree
 | 
|  |    414 | //
 | 
|  |    415 | 	{
 | 
|  |    416 | 
 | 
|  |    417 | 	test.Next(_L("Test ascending scan"));
 | 
|  |    418 | 	MakeFile(_L("\\F32-TST\\SCANTEST\\MaTCHteST.EXTENSION"));
 | 
|  |    419 | 	MakeFile(_L("\\F32-TST\\SCANTEST\\MATCH.EXT"));
 | 
|  |    420 | 	MakeFile(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\ANOTherteST.EXTENSION"));
 | 
|  |    421 | 	MakeFile(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\APPDLL.DLL"));
 | 
|  |    422 | 	MakeFile(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\TEST.EXTENSION"));
 | 
|  |    423 | 	MakeFile(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\DIR4\\MaTCHteST.EXTENSION"));
 | 
|  |    424 | 	
 | 
|  |    425 | 	CDir* entryList;
 | 
|  |    426 | 	CDirScan* scanner=CDirScan::NewL(TheFs);
 | 
|  |    427 | 	TParse dirName;
 | 
|  |    428 | 
 | 
|  |    429 | 	test.Next(_L("Scan for MAT*.EXT"));
 | 
|  |    430 | 	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\"),dirName);
 | 
|  |    431 | //	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\DIR4\\MaTCHteST.EXTENSION"),dirName);
 | 
|  |    432 | //	scanner->SetScanDataL(dirName.FullName(),KEntryAttNormal,ESortByName,CDirScan::EScanUpTree);
 | 
|  |    433 | 	scanner->SetScanDataL(dirName.FullName(),KEntryAttDir,ESortByName,CDirScan::EScanUpTree);
 | 
|  |    434 | 	
 | 
|  |    435 | 	FOREVER
 | 
|  |    436 | 		{
 | 
|  |    437 | 		scanner->NextL(entryList);
 | 
|  |    438 | 		if (entryList==NULL)
 | 
|  |    439 | 			break;
 | 
|  |    440 | 		TInt count=entryList->Count();
 | 
|  |    441 | 		while(count--)
 | 
|  |    442 | 			{
 | 
|  |    443 | 			TEntry entry=(*entryList)[count];
 | 
|  |    444 | 			test.Printf(_L("entry.iName = %S\n"),&entry.iName);
 | 
|  |    445 | 		//	test(entry.iName==_L("MATCH.EXT"));
 | 
|  |    446 | 			}
 | 
|  |    447 | 		delete entryList;
 | 
|  |    448 | 		}
 | 
|  |    449 | 	
 | 
|  |    450 | 	delete scanner;
 | 
|  |    451 | 	}
 | 
|  |    452 | 
 | 
|  |    453 | 
 | 
|  |    454 | LOCAL_C void Test7()
 | 
|  |    455 | //
 | 
|  |    456 | // Test scanning hidden directories
 | 
|  |    457 | //
 | 
|  |    458 | 	{
 | 
|  |    459 | 
 | 
|  |    460 | 	CDir* entryList;
 | 
|  |    461 | 	CDirScan* scanner=CDirScan::NewL(TheFs);
 | 
|  |    462 | 	TParse dirName;
 | 
|  |    463 | 
 | 
|  |    464 | 	test.Next(_L("Scan in hidden directories for files"));
 | 
|  |    465 | 	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\*"),dirName);
 | 
|  |    466 | 	scanner->SetScanDataL(dirName.FullName(),KEntryAttHidden,ESortByName,CDirScan::EScanDownTree);
 | 
|  |    467 | 	
 | 
|  |    468 | 	TInt hiddenCount=0;
 | 
|  |    469 | 	FOREVER
 | 
|  |    470 | 		{
 | 
|  |    471 | 		scanner->NextL(entryList);
 | 
|  |    472 | 		if (entryList==NULL)
 | 
|  |    473 | 			break;
 | 
|  |    474 | 		TInt count=entryList->Count();
 | 
|  |    475 | 		while(count--)
 | 
|  |    476 | 			{
 | 
|  |    477 | 			TEntry entry=(*entryList)[count];
 | 
|  |    478 | 			test.Printf(_L("entry.iName = %S\n"),&entry.iName);
 | 
|  |    479 | 			if (entry.IsHidden())
 | 
|  |    480 | 				hiddenCount++;
 | 
|  |    481 | 			if (entry.iName==_L("File8"))
 | 
|  |    482 | 				hiddenCount++;
 | 
|  |    483 | 			}
 | 
|  |    484 | 		delete entryList;
 | 
|  |    485 | 		}
 | 
|  |    486 | 	test(hiddenCount==2);
 | 
|  |    487 | 
 | 
|  |    488 | 	test.Next(_L("Scan for system and hidden directories and files"));
 | 
|  |    489 | 	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\*"),dirName);
 | 
|  |    490 | 	scanner->SetScanDataL(dirName.FullName(),KEntryAttSystem|KEntryAttHidden|KEntryAttDir,ESortByName,CDirScan::EScanDownTree);
 | 
|  |    491 | 
 | 
|  |    492 | 	hiddenCount=0;
 | 
|  |    493 | 	FOREVER
 | 
|  |    494 | 		{
 | 
|  |    495 | 		scanner->NextL(entryList);
 | 
|  |    496 | 		if (entryList==NULL)
 | 
|  |    497 | 			break;
 | 
|  |    498 | 		TInt count=entryList->Count();
 | 
|  |    499 | 		while(count--)
 | 
|  |    500 | 			{
 | 
|  |    501 | 			TEntry entry=(*entryList)[count];
 | 
|  |    502 | 			test.Printf(_L("entry.iName = %S\n"),&entry.iName);
 | 
|  |    503 | 			if (entry.IsHidden())
 | 
|  |    504 | 				hiddenCount++;
 | 
|  |    505 | 			if (entry.iName==_L("File8"))
 | 
|  |    506 | 				hiddenCount++;
 | 
|  |    507 | 			if (entry.IsSystem())
 | 
|  |    508 | 				hiddenCount++;
 | 
|  |    509 | 			if (entry.iName==_L("File9"))
 | 
|  |    510 | 				hiddenCount++;
 | 
|  |    511 | 			}
 | 
|  |    512 | 		delete entryList;
 | 
|  |    513 | 		}
 | 
|  |    514 | 	test(hiddenCount==5);
 | 
|  |    515 | 	
 | 
|  |    516 | 	delete scanner;
 | 
|  |    517 | 	}
 | 
|  |    518 | 
 | 
|  |    519 | GLDEF_C void CallTestsL()
 | 
|  |    520 | //
 | 
|  |    521 | // Call all tests
 | 
|  |    522 | //
 | 
|  |    523 | 	{
 | 
|  |    524 | 
 | 
|  |    525 | 	CreateTestDirectory(_L("\\F32-TST\\SCANTEST\\"));
 | 
|  |    526 | 	DeleteTestDirectory();
 | 
|  |    527 | 	BuildTestDir();
 | 
|  |    528 | 	Test1();
 | 
|  |    529 | 	Test2();
 | 
|  |    530 | 	Test3();
 | 
|  |    531 | 	Test4();
 | 
|  |    532 | 	Test5();
 | 
|  |    533 | 	DeleteTestDirectory();
 | 
|  |    534 | 	Test6();
 | 
|  |    535 | 	DeleteTestDirectory();
 | 
|  |    536 | 
 | 
|  |    537 | 	BuildTestDir();
 | 
|  |    538 | 	Test7();
 | 
|  |    539 | 	DeleteTestDirectory();
 | 
|  |    540 | 	}
 |