|
1 // Copyright (c) 2000-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 // Test traversal of directories and locating files in directories |
|
15 // |
|
16 // |
|
17 |
|
18 #include <e32std.h> |
|
19 #include <e32std_private.h> |
|
20 #define __E32TEST_EXTENSION__ |
|
21 #include <e32test.h> |
|
22 #include <f32file.h> |
|
23 #include "utl.h" |
|
24 |
|
25 GLREF_D RFs TheFs; |
|
26 |
|
27 RTest test( _L("T_ROFSDIR") ); |
|
28 |
|
29 _LIT( KTestFile1, "root.txt" ); |
|
30 _LIT( KTestFile2, "Dir1\\level1.txt" ); |
|
31 _LIT( KTestFile3, "Dir1\\Dir2\\level2.txt" ); |
|
32 _LIT( KTestFile4, "Dir1\\Dir2\\Dir3\\level3.txt" ); |
|
33 _LIT( KTestFile5, "Dir1\\Dir2\\Dir3\\Dir4\\level4.txt" ); |
|
34 _LIT( KTestFile6, "Dir1\\Dir2\\Dir3\\Dir4\\Dir5\\level5.txt" ); |
|
35 _LIT( KTestFile7, "Dir1\\Dir2\\Dir3\\Dir4\\Dir5\\Dir6\\level6.txt" ); |
|
36 _LIT( KTestFile8, "Dir1\\Dir2\\Dir3\\Dir4\\Dir5\\Dir6\\Dir7\\level7.txt" ); |
|
37 _LIT( KTestFile9, "DeepDir1\\DeepDir2\\DeepDir3\\DeepDir4\\DeepDir5\\DeepDir6\\DeepDir7\\DeepDir8\\DeepDir9\\DeepDir10\\DeepDir11\\DeepDir12\\DeepDir13\\DeepDir14\\file.txt" ); |
|
38 _LIT( KTestFile10, "Parent\\parfile.txt" ); |
|
39 _LIT( KTestFile11, "Parent\\SubDir1A\\subfileA.txt" ); |
|
40 _LIT( KTestFile12, "Parent\\SubDir1B\\subfileB.txt" ); |
|
41 _LIT( KTestFile13, "Parent\\SubDir1C\\subfileC.txt" ); |
|
42 _LIT( KTestFile14, "Parent\\SubDir1D\\subfileD.txt" ); |
|
43 _LIT( KTestFile15, "Parent\\SubDir1E\\subfileE.txt" ); |
|
44 _LIT( KTestFile16, "Parent\\SubDir1F\\SubSubA\\subsub_a.txt" ); |
|
45 _LIT( KTestFile17, "Parent\\SubDir1F\\SubSubB\\subsub_b.txt" ); |
|
46 _LIT( KTestFile18, "Parent\\SubDir1F\\SubSubC\\subsub_c.txt" ); |
|
47 _LIT( KTestFile19, "Parent\\SubDir1F\\SubSubD\\subsub_d.txt" ); |
|
48 _LIT( KTestFile20, "Mixed\\par1.txt" ); |
|
49 _LIT( KTestFile21, "Mixed\\SubDir1\\sub1.txt" ); |
|
50 _LIT( KTestFile22, "Mixed\\SubDir2\\sub2.txt" ); |
|
51 _LIT( KTestFile23, "Mixed\\SubDir3\\sub3.txt" ); |
|
52 _LIT( KTestFile24, "Mixed\\SubDir4\\sub4.txt" ); |
|
53 _LIT( KTestFile25, "Mixed\\SubDir5\\sub5.txt" ); |
|
54 _LIT( KTestFile26, "Mixed\\SubDir6\\sub6.txt" ); |
|
55 _LIT( KTestFile27, "Mixed\\SubDir7\\sub7.txt" ); |
|
56 _LIT( KTestFile28, "Mixed\\SubDir8\\sub8.txt" ); |
|
57 _LIT( KTestFile29, "Mixed\\par2.txt" ); |
|
58 _LIT( KTestFile30, "Mixed\\par3.txt" ); |
|
59 _LIT( KTestFile31, "Mixed\\par4.txt" ); |
|
60 _LIT( KTestFile32, "Mixed\\par5.txt" ); |
|
61 _LIT( KTestFile33, "Mixed\\par6.txt" ); |
|
62 _LIT( KTestFile34, "Mixed\\par7.txt" ); |
|
63 _LIT( KTestFile35, "Mixed\\par8.txt" ); |
|
64 // required to test extension |
|
65 _LIT( KTestFile36, "ext.txt" ); |
|
66 _LIT( KTestFile37, "Dir1\\ext.txt" ); |
|
67 _LIT( KTestFile38, "Dir1\\level1_ext.txt" ); |
|
68 //required to test the unique files |
|
69 //(Note: These file names depend on the mount ids. Hence change in mount order will affect the test) |
|
70 _LIT( KTestFile39, "Exattrib\\test1.txt[02-00]" ); |
|
71 _LIT( KTestFile40, "Exattrib\\test1.txt[03-00]"); |
|
72 _LIT( KTestFile41, "Exattrib\\test2.txt[03-00]" ); |
|
73 _LIT( KTestFile42, "Exattrib\\test3-1.txt[02-00]"); |
|
74 _LIT( KTestFile43, "Exattrib\\test5-1.txt[x-y][03-00]"); |
|
75 |
|
76 const TInt KRootDirEntryCount = 17; |
|
77 |
|
78 _LIT( KRootFile, "root.txt" ); |
|
79 _LIT( KRootFileExt, "ext.txt" ); |
|
80 _LIT( KRootDir1, "Dir1" ); |
|
81 _LIT( KRootDeepDir1, "DeepDir1" ); |
|
82 _LIT( KRootDirParent, "Parent" ); |
|
83 _LIT( KRootDirMixed, "Mixed" ); |
|
84 _LIT( KRootDirReadTest, "ReadTest" ); |
|
85 _LIT( KRootDirAttrib, "Attrib" ); |
|
86 _LIT( KRootDirExattrib, "Exattrib" ); |
|
87 _LIT( KRootDirResource, "Resource" ); |
|
88 _LIT( KRootImg, "Img" ); |
|
89 _LIT( KRootSys, "sys" ); |
|
90 _LIT( KRootSystem, "system" ); |
|
91 _LIT( KRootTest, "Test" ); |
|
92 _LIT( KRootDirMultiple, "Multiple" ); |
|
93 _LIT( KRootAutoexec, "autoexec.bat" ); |
|
94 |
|
95 _LIT( KRootDirScripts, "scripts" ); |
|
96 |
|
97 |
|
98 _LIT( KSubDirOnlyBase, "Parent\\SubDir1F\\" ); |
|
99 _LIT( KSubSubPattern, "SubSub%c" ); |
|
100 const TInt KSubDirOnlyCount = 4; |
|
101 |
|
102 _LIT( KFilesOnlyBase, "Parent\\SubDir1F\\SubSubA\\" ); |
|
103 _LIT( KSubSubFilePattern, "subsub_%c.txt" ); |
|
104 const TInt KFilesOnlyCount = 1; |
|
105 |
|
106 _LIT( KMixedDirBase, "Mixed\\" ); |
|
107 _LIT( KMixedDirPattern, "SubDir%d" ); |
|
108 _LIT( KMixedFilePattern, "par%d.txt" ); |
|
109 const TInt KMixedSubDirCount = 8; |
|
110 const TInt KMixedSubFileCount = 8; |
|
111 |
|
112 |
|
113 const TInt KMultipleDirEntryCount=14; |
|
114 _LIT( KMultipleFile1, "new1.txt" ); |
|
115 _LIT( KMultipleFile2, "new2.txt" ); |
|
116 _LIT( KMultipleFile3, "new3.txt" ); |
|
117 _LIT( KMultipleFile4, "replaceme1.txt" ); |
|
118 _LIT( KMultipleFile5, "replaceme2.txt" ); |
|
119 _LIT( KMultipleFile6, "replaceme3.txt" ); |
|
120 _LIT( KMultipleFile7, "replaceme4.txt" ); |
|
121 _LIT( KMultipleFile8, "rom.txt" ); |
|
122 _LIT( KMultipleFile9, "romreplace.txt" ); |
|
123 // required to test multiple rofs |
|
124 _LIT( KMultipleFile10, "multirofs.txt" ); |
|
125 // files on user data fat partition |
|
126 _LIT( KMultipleFile11, "new4.txt" ); |
|
127 _LIT( KMultipleFile12, "replaceme5.txt" ); |
|
128 _LIT( KMultipleFile13, "romreplacefat.txt" ); |
|
129 _LIT( KMultipleFile14, "t_file.cpp" ); |
|
130 |
|
131 const TInt KExattribDirEntryCount = 11; |
|
132 |
|
133 _LIT( KExattribFile1, "test1.txt[02-00]" ); |
|
134 _LIT( KExattribFile2, "test1.txt[03-00]" ); |
|
135 _LIT( KExattribFile3, "test2.txt[03-00]" ); |
|
136 _LIT( KExattribFile4, "test3-1.txt[02-00]" ); |
|
137 _LIT( KExattribFile5, "test4-2.txt[03-00]" ); |
|
138 _LIT( KExattribFile6, "test5-1.txt[x-y][03-00]" ); |
|
139 _LIT( KExattribFile7, "test5-2.txt[x-y]" ); |
|
140 _LIT( KExattribFile8, "test8-1.txt[04-00]" ); |
|
141 _LIT( KExattribFile9, "test6-1.txt[04-00]" ); |
|
142 _LIT( KExattribFile10, "test7-1.txt[03-00]" ); |
|
143 _LIT( KExattribFile11, "test7-1.txt[04-00]" ); |
|
144 |
|
145 _LIT( KDriveBase, " :\\" ); |
|
146 _LIT( KDriveMultiple, "Multiple\\" ); |
|
147 _LIT( KDriveExattrib, "Exattrib\\" ); |
|
148 _LIT( KWildCard, "*" ); |
|
149 |
|
150 |
|
151 enum TEntrySet |
|
152 { |
|
153 ERoot, |
|
154 ERootExtension, |
|
155 EMultiple, |
|
156 EExattrib, |
|
157 }; |
|
158 |
|
159 LOCAL_C void TestOpenFilesL(TInt aDriveToTest, TBool aExtension, TBool aMultipleRofs) |
|
160 // |
|
161 // Tests that we can open files in various directories on the drive |
|
162 // |
|
163 { |
|
164 TInt index = 35; |
|
165 if(aExtension) |
|
166 index=37; |
|
167 if(aMultipleRofs) |
|
168 index=42; |
|
169 |
|
170 const TDesC* const fileArray[43] = |
|
171 { |
|
172 &KTestFile1, &KTestFile2, &KTestFile3, &KTestFile4, &KTestFile5, |
|
173 &KTestFile6, &KTestFile7, &KTestFile8, &KTestFile9, &KTestFile10, |
|
174 &KTestFile11, &KTestFile12, &KTestFile13, &KTestFile14, &KTestFile15, |
|
175 &KTestFile16, &KTestFile17, &KTestFile18, &KTestFile19, &KTestFile20, |
|
176 &KTestFile21, &KTestFile22, &KTestFile23, &KTestFile24, &KTestFile25, |
|
177 &KTestFile26, &KTestFile27, &KTestFile28, &KTestFile29, &KTestFile30, |
|
178 &KTestFile31, &KTestFile32, &KTestFile33, &KTestFile34, &KTestFile35, |
|
179 &KTestFile36, &KTestFile37, &KTestFile38, &KTestFile39, &KTestFile40, |
|
180 &KTestFile41, &KTestFile42, &KTestFile43 |
|
181 }; |
|
182 |
|
183 test.Next( _L("Test opening files in directories") ); |
|
184 TFileName name(KDriveBase); |
|
185 name[0] = TText('A' + aDriveToTest); |
|
186 |
|
187 for( TInt i = 0; i < index; i++ ) |
|
188 { |
|
189 name.SetLength( 3 ); // trim back to drive specifier |
|
190 if(aExtension && (i==1)) |
|
191 name.Append( *fileArray[i+36] ); |
|
192 else |
|
193 name.Append( *fileArray[i] ); |
|
194 test.Printf( _L("Opening file %S\n"), &name ); |
|
195 RFile file; |
|
196 TInt r = file.Open( TheFs, name, EFileRead ); |
|
197 TEST_FOR_ERROR( r ); |
|
198 file.Close(); |
|
199 } |
|
200 } |
|
201 |
|
202 |
|
203 LOCAL_C void TestScanDirL(TInt aDriveToTest, TEntrySet aEntrySet) |
|
204 // |
|
205 // Scan the root directory file |
|
206 // |
|
207 { |
|
208 const TDesC* const rootEntriesExt[ KRootDirEntryCount ] = |
|
209 { |
|
210 &KRootFileExt, &KRootFile, &KRootDir1, &KRootDeepDir1, |
|
211 &KRootDirParent, &KRootDirMixed, &KRootDirReadTest, &KRootDirAttrib, &KRootDirExattrib, |
|
212 &KRootDirResource, &KRootImg, &KRootSys, &KRootSystem, &KRootTest, &KRootDirMultiple, |
|
213 &KRootDirScripts, |
|
214 &KRootAutoexec |
|
215 }; |
|
216 |
|
217 const TDesC* const rootEntries[ KRootDirEntryCount-1 ] = |
|
218 { |
|
219 &KRootFile, &KRootDir1, &KRootDeepDir1, |
|
220 &KRootDirParent, &KRootDirMixed, &KRootDirReadTest, &KRootDirAttrib, &KRootDirExattrib, |
|
221 &KRootDirResource, &KRootImg, &KRootSys, &KRootSystem, &KRootTest, &KRootDirMultiple, |
|
222 &KRootDirScripts, |
|
223 &KRootAutoexec |
|
224 }; |
|
225 |
|
226 const TDesC* const multipleEntries[ KMultipleDirEntryCount ] = |
|
227 { |
|
228 &KMultipleFile1, &KMultipleFile2, &KMultipleFile3, &KMultipleFile4, &KMultipleFile5, |
|
229 &KMultipleFile6, &KMultipleFile7, &KMultipleFile8, &KMultipleFile9, &KMultipleFile10, |
|
230 &KMultipleFile11, &KMultipleFile12, &KMultipleFile13, &KMultipleFile14 |
|
231 }; |
|
232 |
|
233 const TDesC* const exattribEntries[ KExattribDirEntryCount ] = |
|
234 { |
|
235 &KExattribFile1, &KExattribFile2, &KExattribFile3, &KExattribFile4, |
|
236 &KExattribFile5, &KExattribFile6, &KExattribFile7, &KExattribFile8, |
|
237 &KExattribFile9, &KExattribFile10, &KExattribFile11 |
|
238 }; |
|
239 |
|
240 const TDesC* const *entries = NULL; |
|
241 TInt DirCount=0; |
|
242 TBool seen[KRootDirEntryCount]; |
|
243 memclr(seen, KRootDirEntryCount*sizeof(TBool)); |
|
244 TFileName name(KDriveBase); |
|
245 name[0] = TText('A' + aDriveToTest); |
|
246 |
|
247 switch (aEntrySet) |
|
248 { |
|
249 case ERoot: |
|
250 DirCount=KRootDirEntryCount-1; |
|
251 entries=rootEntries; |
|
252 test.Next( _L("Scanning root directory") ); |
|
253 break; |
|
254 case ERootExtension: |
|
255 DirCount=KRootDirEntryCount; |
|
256 entries=rootEntriesExt; |
|
257 test.Next( _L("Scanning root extension directory") ); |
|
258 break; |
|
259 case EMultiple: |
|
260 DirCount=KMultipleDirEntryCount; |
|
261 entries=multipleEntries; |
|
262 name.Append(KDriveMultiple); |
|
263 test.Next( _L("Scanning multiple directory") ); |
|
264 break; |
|
265 case EExattrib: |
|
266 DirCount=KExattribDirEntryCount; |
|
267 entries=exattribEntries; |
|
268 name.Append(KDriveExattrib); |
|
269 test.Next( _L("Scanning Exattrib directory") ); |
|
270 break; |
|
271 default: |
|
272 test(EFalse); |
|
273 } |
|
274 |
|
275 CDir* dir; |
|
276 TInt r = TheFs.GetDir( name, KEntryAttMaskSupported, ESortNone, dir ); |
|
277 TEST_FOR_ERROR( r ); |
|
278 |
|
279 TInt actualCount = dir->Count(); |
|
280 for(TInt i = 0; i < actualCount; i++) |
|
281 { |
|
282 const TEntry& e = dir->operator[](i); |
|
283 TFileName lowerName(e.iName); |
|
284 lowerName.LowerCase(); |
|
285 TBool found = EFalse; |
|
286 // try to find the name in our list |
|
287 for(TInt j = 0; j < DirCount && !found; j++) |
|
288 { |
|
289 TFileName expectedLower(*entries[j]); |
|
290 expectedLower.LowerCase(); |
|
291 // Check the directory name is that expected. |
|
292 found = lowerName == expectedLower; |
|
293 if(found) |
|
294 { |
|
295 if(seen[j]) |
|
296 { |
|
297 test.Printf( _L("ERROR: saw entry %S twice\n"), &e.iName ); |
|
298 test( EFalse ); |
|
299 } |
|
300 else |
|
301 { |
|
302 seen[j] = ETrue; |
|
303 } |
|
304 } |
|
305 } |
|
306 if (!found) |
|
307 { |
|
308 test.Printf( _L("ERROR: entry %S unknown\n"), &e.iName ); |
|
309 test( EFalse ); |
|
310 } |
|
311 } |
|
312 // All the entries are those expected but are there enough matching entries. |
|
313 // Allow the autoexe.bat to not be present so the test can pass when run |
|
314 // when not part of an auto test rom. |
|
315 TInt tolerance = 1; |
|
316 if (aEntrySet == ERoot || aEntrySet == ERootExtension) |
|
317 {// The "scripts" directory is not present on all roms. |
|
318 tolerance++; |
|
319 } |
|
320 test_Value(actualCount, actualCount >= DirCount-tolerance); |
|
321 delete dir; |
|
322 } |
|
323 |
|
324 |
|
325 |
|
326 LOCAL_C void TestSubDirsOnlyL(TInt aDriveToTest) |
|
327 // |
|
328 // Tests that scanning a directory containing only subdirectories |
|
329 // only returns entries marked as directories |
|
330 // |
|
331 { |
|
332 test.Next( _L("Testing scan of dir containing only subdirs") ); |
|
333 CDir* dir; |
|
334 |
|
335 TFileName name(KDriveBase); |
|
336 name[0] = TText('A' + aDriveToTest); |
|
337 name.Append( KSubDirOnlyBase ); |
|
338 name.Append( KWildCard ); |
|
339 |
|
340 TInt r = TheFs.GetDir( name, KEntryAttMaskSupported, ESortNone, dir ); |
|
341 TEST_FOR_ERROR( r ); |
|
342 |
|
343 TEST_FOR_MATCH( dir->Count(), KSubDirOnlyCount ); |
|
344 |
|
345 TBuf<32> subEntryName; |
|
346 for( TInt i = 0; i < KSubDirOnlyCount; i++ ) |
|
347 { |
|
348 const TEntry& e = dir->operator[](i); |
|
349 subEntryName.Format( KSubSubPattern, 'A' + i ); |
|
350 test.Printf( _L("Found entry %S\n"), &e.iName ); |
|
351 test( e.iName == subEntryName ); |
|
352 test( e.IsDir() ); |
|
353 } |
|
354 delete dir; |
|
355 } |
|
356 |
|
357 |
|
358 LOCAL_C void TestFilesOnlyL(TInt aDriveToTest) |
|
359 // |
|
360 // Tests that scanning a directory containing only files |
|
361 // does not return any entries marked as files |
|
362 // |
|
363 { |
|
364 test.Next( _L("Testing scan of dir containing only files") ); |
|
365 CDir* dir; |
|
366 |
|
367 TFileName name(KDriveBase); |
|
368 name[0] = TText('A' + aDriveToTest); |
|
369 name.Append( KFilesOnlyBase ); |
|
370 name.Append( KWildCard ); |
|
371 |
|
372 TInt r = TheFs.GetDir( name, KEntryAttMaskSupported, ESortNone, dir ); |
|
373 TEST_FOR_ERROR( r ); |
|
374 |
|
375 TEST_FOR_MATCH( dir->Count(), KFilesOnlyCount ); |
|
376 |
|
377 TBuf<32> subEntryName; |
|
378 for( TInt i = 0; i < KFilesOnlyCount; i++ ) |
|
379 { |
|
380 const TEntry& e = dir->operator[](i); |
|
381 subEntryName.Format( KSubSubFilePattern, 'a' + i ); |
|
382 test.Printf( _L("Found entry %S\n"), &e.iName ); |
|
383 test( e.iName == subEntryName ); |
|
384 test( !e.IsDir() ); |
|
385 } |
|
386 delete dir; |
|
387 } |
|
388 |
|
389 |
|
390 LOCAL_C void TestMaskDirsL(TInt aDriveToTest) |
|
391 // |
|
392 // Test scanning a directory with masking to return only directories |
|
393 // |
|
394 { |
|
395 test.Next( _L("Testing scan of dir masking out files") ); |
|
396 CDir* dir; |
|
397 |
|
398 TFileName name(KDriveBase); |
|
399 name[0] = TText('A' + aDriveToTest); |
|
400 name.Append( KMixedDirBase ); |
|
401 name.Append( KWildCard ); |
|
402 |
|
403 TInt r = TheFs.GetDir( name, KEntryAttMatchExclusive | KEntryAttDir, ESortNone, dir ); |
|
404 TEST_FOR_ERROR( r ); |
|
405 |
|
406 TEST_FOR_MATCH( dir->Count(), KMixedSubDirCount ); |
|
407 |
|
408 TBuf<32> subEntryName; |
|
409 for( TInt i = 0; i < KMixedSubDirCount; i++ ) |
|
410 { |
|
411 const TEntry& e = dir->operator[](i); |
|
412 subEntryName.Format( KMixedDirPattern, i+1 ); |
|
413 test.Printf( _L("Found entry %S\n"), &e.iName ); |
|
414 test( e.iName == subEntryName ); |
|
415 test( e.IsDir() ); |
|
416 } |
|
417 delete dir; |
|
418 } |
|
419 |
|
420 LOCAL_C void TestMaskFilesL(TInt aDriveToTest) |
|
421 // |
|
422 // Test scanning a directory with masking to return only files |
|
423 // |
|
424 { |
|
425 test.Next( _L("Testing scan of dir masking out directories") ); |
|
426 CDir* dir; |
|
427 |
|
428 TFileName name(KDriveBase); |
|
429 name[0] = TText('A' + aDriveToTest); |
|
430 name.Append( KMixedDirBase ); |
|
431 name.Append( KWildCard ); |
|
432 |
|
433 TInt r = TheFs.GetDir( name, KEntryAttMatchExclude | KEntryAttDir, ESortNone, dir ); |
|
434 TEST_FOR_ERROR( r ); |
|
435 |
|
436 TEST_FOR_MATCH( dir->Count(), KMixedSubFileCount ); |
|
437 |
|
438 TBuf<32> subEntryName; |
|
439 for( TInt i = 0; i < KMixedSubFileCount; i++ ) |
|
440 { |
|
441 const TEntry& e = dir->operator[](i); |
|
442 subEntryName.Format( KMixedFilePattern, i+1 ); |
|
443 test.Printf( _L("Found entry %S\n"), &e.iName ); |
|
444 test( e.iName == subEntryName ); |
|
445 test( !e.IsDir() ); |
|
446 } |
|
447 delete dir; |
|
448 } |
|
449 |
|
450 LOCAL_C void TestGetDirL(TInt aDriveToTest) |
|
451 // |
|
452 // Test UID scanning of a directory |
|
453 // |
|
454 { |
|
455 test.Next( _L("Testing scan of dir with UID bitmask") ); |
|
456 |
|
457 TFileName name(KDriveBase); |
|
458 name[0] = TText('A' + aDriveToTest); |
|
459 name.Append( KRootDirResource ); |
|
460 name.Append(_L("\\")); |
|
461 |
|
462 const TUid KUidInterfaceImplementationCollectionInfo = {0x101F747D}; |
|
463 |
|
464 TUidType rscUidType(KNullUid,KUidInterfaceImplementationCollectionInfo,KNullUid); |
|
465 |
|
466 CDir* dir; |
|
467 TInt r = TheFs.GetDir(name, rscUidType, ESortByUid, dir); |
|
468 test(r==KErrNone); |
|
469 TInt count = dir->Count(); |
|
470 test(count==10); |
|
471 delete dir; |
|
472 |
|
473 TUidType uidType2(TUid::Uid('X'),TUid::Uid('Y'),TUid::Uid('Z')); |
|
474 r = TheFs.GetDir(name, uidType2, ESortByUid, dir); |
|
475 test(r==KErrNone); |
|
476 count = dir->Count(); |
|
477 test(count==1); |
|
478 delete dir; |
|
479 } |
|
480 |
|
481 |
|
482 |
|
483 //************************ |
|
484 // Entry point |
|
485 |
|
486 void DoTestL(TInt aDriveToTest) |
|
487 { |
|
488 test.Title(); |
|
489 test.Start( _L("Testing ROFS directory structure") ); |
|
490 |
|
491 test.Printf( _L("Looking for ROFS extension..\n")); |
|
492 TBool extension = EFalse; |
|
493 TFileName name(KDriveBase); |
|
494 name[0] = TText('A' + aDriveToTest); |
|
495 |
|
496 name.SetLength( 3 ); // trim back to drive specifier |
|
497 name.Append( KTestFile36 ); |
|
498 |
|
499 RFile file; |
|
500 test.Printf( _L("Attempt to open file %S.."), &name ); |
|
501 TInt r = file.Open( TheFs, name, EFileRead ); |
|
502 if(r==KErrNone) |
|
503 { |
|
504 extension=ETrue; |
|
505 file.Close(); |
|
506 test.Printf( _L("ROFS extension found.\n")); |
|
507 } |
|
508 else if(r==KErrNotFound) |
|
509 { |
|
510 test.Printf( _L("Not found, ROFS extension not present.\n")); |
|
511 } |
|
512 |
|
513 test.Printf( _L("Looking for multiple ROFS..\n")); |
|
514 TBool multipleRofs = EFalse; |
|
515 name.SetLength( 3 ); // trim back to drive specifier |
|
516 name.Append( KMultipleFile10 ); |
|
517 |
|
518 test.Printf( _L("Attempt to open file %S.."), &name ); |
|
519 r = file.Open( TheFs, name, EFileRead ); |
|
520 if(r==KErrNone) |
|
521 { |
|
522 multipleRofs=ETrue; |
|
523 file.Close(); |
|
524 test.Printf( _L("Multiple ROFS found. %S is present.\n"), &name); |
|
525 } |
|
526 else if(r==KErrNotFound) |
|
527 { |
|
528 test.Printf( _L("No multiple ROFS found. %S is not present.\n"), &name); |
|
529 } |
|
530 |
|
531 TestOpenFilesL(aDriveToTest,extension,multipleRofs); |
|
532 TestScanDirL(aDriveToTest, extension?ERootExtension:ERoot); |
|
533 TestSubDirsOnlyL(aDriveToTest); |
|
534 TestFilesOnlyL(aDriveToTest); |
|
535 TestMaskDirsL(aDriveToTest); |
|
536 TestMaskFilesL(aDriveToTest); |
|
537 TestGetDirL(aDriveToTest); |
|
538 |
|
539 // Test dir works for muliple rofs |
|
540 if (multipleRofs) |
|
541 { |
|
542 TestScanDirL(aDriveToTest, EMultiple); |
|
543 TestScanDirL(aDriveToTest, EExattrib); |
|
544 } |
|
545 |
|
546 test.End(); |
|
547 } |