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