|
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". |
|
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 <e32std.h> |
|
19 #include <e32std_private.h> |
|
20 #include <e32svr.h> |
|
21 #include <e32def.h> |
|
22 #include <e32def_private.h> |
|
23 #include "t_server.h" |
|
24 |
|
25 GLDEF_D RTest test(_L("t_dctcb")); |
|
26 GLDEF_D TTime gTimeNow; |
|
27 LOCAL_D TInt gTheDriveNum; |
|
28 |
|
29 const TInt KPathPosition = 2; |
|
30 _LIT(KExpectedPrivatePath, "\\Private\\00000001\\"); |
|
31 |
|
32 |
|
33 _LIT(KResourcePath, "?:\\Resource\\"); |
|
34 _LIT(KSystemPath, "?:\\Sys\\"); |
|
35 _LIT(KPrivatePath, "?:\\Private\\"); |
|
36 _LIT(KPrivateFalseID, "?:\\Private\\FFFFFFFF\\"); |
|
37 _LIT(KDriveName, "Billy"); |
|
38 _LIT(KVolLable, "Benny"); |
|
39 |
|
40 _LIT(KFileSys, "systemfile.txt"); |
|
41 //_LIT(KFileSys2, "systemfile.tmp"); |
|
42 _LIT(KFileSys3, "sysfile.rna"); |
|
43 |
|
44 _LIT(KFilePri, "privatefile.txt"); |
|
45 _LIT(KFilePri2, "privatefile.tmp"); |
|
46 _LIT(KFilePri3, "prifile.rna"); |
|
47 |
|
48 _LIT(KFileRes, "resourcefile.txt"); |
|
49 //_LIT(KFileRes2, "resourcefile.tmp"); |
|
50 _LIT(KFileRes3, "resfile.rna"); |
|
51 |
|
52 _LIT(KMkDirSub,"Subdir\\"); |
|
53 _LIT(KOldFile,"?:\\Anyold.txt"); |
|
54 //_LIT(KNullPath, ""); |
|
55 |
|
56 //_LIT(KLFFSName, "Lffs"); |
|
57 |
|
58 _LIT(KWildPath, "Z:\\SYS\\"); |
|
59 _LIT(KWildFile, "*"); |
|
60 |
|
61 TCapability TheCaps; |
|
62 TBuf<4> driveBuf=_L("?:\\"); |
|
63 RFormat format; |
|
64 TInt count; |
|
65 RRawDisk rawdisk; |
|
66 RFile file1; |
|
67 RFile file2; |
|
68 RDir dir; |
|
69 |
|
70 TInt r; |
|
71 TBuf<40> fsname; |
|
72 TBuf<40> systestname; |
|
73 TBuf<40> pritestname; |
|
74 TBuf<40> restestname; |
|
75 TBuf<40> theprivatepath; |
|
76 TBuf<40> pritestfalseidname; |
|
77 TBuf<40> mkdirname; |
|
78 TFileName fromTemp; |
|
79 |
|
80 TBuf<25> sysfilename; |
|
81 TBuf<30> realName; |
|
82 TBuf<40> shortfilename; |
|
83 TBuf<40> longfilename; |
|
84 |
|
85 TRequestStatus aStat1; |
|
86 TRequestStatus aStat2; |
|
87 TRequestStatus aStat3; |
|
88 TRequestStatus aStat4; |
|
89 |
|
90 TVolumeInfo aVolInfo; |
|
91 |
|
92 TBuf<40> systestfile; |
|
93 TBuf<40> pritestfile; |
|
94 TBuf<40> restestfile; |
|
95 TBuf<40> systestfile1; |
|
96 TBuf<40> pritestfile1; |
|
97 TBuf<40> restestfile1; |
|
98 |
|
99 TTime testtime; |
|
100 TBuf<20> oldName; |
|
101 |
|
102 TBuf<25> temp; |
|
103 |
|
104 TEntry entry; |
|
105 |
|
106 |
|
107 LOCAL_C void TestPathCheck() |
|
108 // |
|
109 // This test case is brought in by INC054580 |
|
110 // (NTT Renaming sys ¨Cfolder on C -drive on H2 allows user to access sys -files) |
|
111 // |
|
112 { |
|
113 TInt r = TheFs.Rename(_L("\\sys"), _L("\\sysbad")); |
|
114 test(r == KErrNone); |
|
115 r = TheFs.Rename(_L("\\resource"), _L("\\resourcebad")); |
|
116 test(r == KErrNone); |
|
117 r = TheFs.Rename(_L("\\sysbad"), _L("\\sys")); |
|
118 test(r == KErrNone); |
|
119 r = TheFs.Rename(_L("\\resourcebad"), _L("\\resource")); |
|
120 test(r == KErrNone); |
|
121 r = TheFs.Rename(_L("\\private"), _L("\\privatebad")); |
|
122 test(r == KErrPermissionDenied); |
|
123 } |
|
124 |
|
125 LOCAL_C void systemRFsTest() |
|
126 // |
|
127 // RFs test on system Directory |
|
128 // |
|
129 { |
|
130 __UHEAP_MARK; |
|
131 systestname=KSystemPath; |
|
132 systestname[0]=(TText)('A' + gTheDriveNum); |
|
133 |
|
134 mkdirname.Zero(); |
|
135 mkdirname.Append(systestname); |
|
136 mkdirname.Append(KMkDirSub); |
|
137 r=TheFs.MkDirAll(mkdirname); |
|
138 test(r==KErrNone); |
|
139 |
|
140 TheFs.RmDir(mkdirname); |
|
141 test(r==KErrNone); |
|
142 |
|
143 r=TheFs.SetSubst(systestname,EDriveO); |
|
144 test(r==KErrPermissionDenied); |
|
145 |
|
146 r=TheFs.RealName(_L("O:\\File.XXX"),realName); |
|
147 test(r==KErrNone); |
|
148 |
|
149 r=TheFs.SetSessionPath(systestname); |
|
150 test(r==KErrPermissionDenied); |
|
151 |
|
152 TheFs.NotifyChange(ENotifyAll,aStat1,systestname); |
|
153 test(aStat1==KErrPermissionDenied); |
|
154 |
|
155 systestfile=KSystemPath; |
|
156 systestfile[0]=(TText)('A' + gTheDriveNum); |
|
157 systestfile1=systestfile; |
|
158 systestfile.Append(KFileSys); |
|
159 systestfile1.Append(KFileSys3); |
|
160 |
|
161 oldName=KOldFile; |
|
162 oldName[0]=(TText)gDriveToTest; |
|
163 |
|
164 r=TheFs.GetShortName(systestfile, shortfilename); |
|
165 test(r==KErrPermissionDenied || r==KErrNotSupported); |
|
166 |
|
167 r=TheFs.GetLongName(systestfile1, longfilename); |
|
168 test(r==KErrPermissionDenied || r==KErrNotSupported); |
|
169 |
|
170 r=file1.Create(TheFs,oldName,EFileWrite); |
|
171 test(r==KErrNone || r==KErrAlreadyExists); |
|
172 file1.Close(); |
|
173 |
|
174 r=TheFs.Replace(oldName,systestfile); |
|
175 test(r==KErrNone); |
|
176 |
|
177 r=TheFs.Delete(systestfile1); |
|
178 test(r==KErrNone || r==KErrNotFound); |
|
179 |
|
180 r=TheFs.Rename(systestfile,systestfile1); |
|
181 test(r==KErrNone); |
|
182 |
|
183 r=TheFs.Entry(systestfile1,entry); |
|
184 test(r==KErrPermissionDenied); |
|
185 |
|
186 r=TheFs.SetEntry(systestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly); |
|
187 test(r==KErrNone); |
|
188 |
|
189 r=TheFs.Delete(systestfile1); |
|
190 test(r==KErrNone); |
|
191 |
|
192 __UHEAP_MARKEND; |
|
193 |
|
194 } |
|
195 |
|
196 LOCAL_C void ResourceRFsTest() |
|
197 // |
|
198 // |
|
199 // |
|
200 { |
|
201 __UHEAP_MARK; |
|
202 |
|
203 restestname=KResourcePath; |
|
204 restestname[0]=(TText)('A' + gTheDriveNum); |
|
205 |
|
206 mkdirname.Zero(); |
|
207 mkdirname.Append(restestname); |
|
208 mkdirname.Append(KMkDirSub); |
|
209 r=TheFs.MkDirAll(mkdirname); |
|
210 test(r==KErrNone); |
|
211 |
|
212 TheFs.RmDir(mkdirname); |
|
213 test(r==KErrNone); |
|
214 |
|
215 r=TheFs.SetSubst(restestname,EDriveO); |
|
216 test(r==KErrPermissionDenied || r==KErrGeneral); |
|
217 |
|
218 r=TheFs.RealName(_L("O:\\File.XXX"),realName); |
|
219 test(r==KErrNone); |
|
220 |
|
221 r=TheFs.SetSessionPath(restestname); |
|
222 test(r==KErrNone); |
|
223 |
|
224 TheFs.NotifyChange(ENotifyAll,aStat4,restestname); |
|
225 test(aStat4==KRequestPending); |
|
226 |
|
227 restestfile=KResourcePath; |
|
228 restestfile[0]=(TText)('A' + gTheDriveNum); |
|
229 restestfile1=restestfile; |
|
230 restestfile.Append(KFileRes); |
|
231 restestfile1.Append(KFileRes3); |
|
232 |
|
233 oldName=KOldFile; |
|
234 oldName[0]=(TText)gDriveToTest; |
|
235 |
|
236 r=TheFs.GetShortName(restestfile, shortfilename); |
|
237 test(r==KErrNone || KErrNotFound || r==KErrNotSupported); |
|
238 |
|
239 r=TheFs.GetLongName(restestfile1, longfilename); |
|
240 test(r==KErrNone || KErrNotFound || r==KErrNotSupported); |
|
241 |
|
242 r=file1.Create(TheFs,oldName,EFileWrite); |
|
243 test(r==KErrNone || r==KErrAlreadyExists); |
|
244 file1.Close(); |
|
245 |
|
246 r=TheFs.Replace(oldName,restestfile); |
|
247 test(r==KErrNone); |
|
248 |
|
249 r=TheFs.Rename(restestfile,restestfile1); |
|
250 test(r==KErrNone); |
|
251 |
|
252 r=TheFs.Entry(restestfile1,entry); |
|
253 test(r==KErrNone); |
|
254 |
|
255 r=TheFs.SetEntry(restestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly); |
|
256 test(r==KErrNone); |
|
257 |
|
258 r=TheFs.Delete(restestfile1); |
|
259 test(r==KErrNone); |
|
260 |
|
261 __UHEAP_MARK; |
|
262 |
|
263 } |
|
264 |
|
265 LOCAL_C void privatefalseIDRFsTest() |
|
266 // |
|
267 // |
|
268 // |
|
269 { |
|
270 __UHEAP_MARK; |
|
271 |
|
272 //private |
|
273 pritestfalseidname=KPrivateFalseID; |
|
274 pritestfalseidname[0]=(TText)('A' + gTheDriveNum); |
|
275 |
|
276 mkdirname.Zero(); |
|
277 mkdirname.Append(pritestfalseidname); |
|
278 mkdirname.Append(KMkDirSub); |
|
279 |
|
280 r=TheFs.MkDirAll(mkdirname); |
|
281 test(r==KErrPermissionDenied); |
|
282 |
|
283 r=TheFs.RmDir(mkdirname); |
|
284 test(r==KErrPermissionDenied); |
|
285 |
|
286 r=TheFs.SetSubst(pritestfalseidname,EDriveO); |
|
287 test(r==KErrPermissionDenied); |
|
288 |
|
289 r=TheFs.RealName(_L("O:\\File.XXX"),realName); |
|
290 test(r==KErrNone); |
|
291 |
|
292 r=TheFs.SetSessionPath(pritestfalseidname); |
|
293 test(r==KErrPermissionDenied); |
|
294 |
|
295 TheFs.NotifyChange(ENotifyAll,aStat2,pritestfalseidname); |
|
296 test(r==KErrPermissionDenied); |
|
297 |
|
298 |
|
299 pritestfile=KPrivateFalseID; |
|
300 pritestfile[0]=(TText)('A' + gTheDriveNum); |
|
301 pritestfile1=pritestfile; |
|
302 pritestfile.Append(KFilePri2); |
|
303 pritestfile1.Append(KFilePri3); |
|
304 |
|
305 oldName=KOldFile; |
|
306 oldName[0]=(TText)gDriveToTest; |
|
307 |
|
308 r=TheFs.GetShortName(pritestfile, shortfilename); |
|
309 test(r==KErrPermissionDenied || r==KErrNotSupported); |
|
310 |
|
311 r=TheFs.GetLongName(pritestfile1, longfilename); |
|
312 test(r==KErrPermissionDenied || r==KErrNotSupported); |
|
313 |
|
314 r=file1.Create(TheFs,oldName,EFileWrite); |
|
315 test(r==KErrNone || r==KErrAlreadyExists); |
|
316 file1.Close(); |
|
317 |
|
318 r=TheFs.Replace(oldName,pritestfile); |
|
319 test(r==KErrPermissionDenied); |
|
320 |
|
321 r=TheFs.Rename(pritestfile,pritestfile1); |
|
322 test(r==KErrPermissionDenied); |
|
323 |
|
324 r=TheFs.Entry(pritestfile1,entry); |
|
325 test(r==KErrPermissionDenied); |
|
326 |
|
327 r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly); |
|
328 test(r==KErrPermissionDenied); |
|
329 |
|
330 r=TheFs.Delete(pritestfile1); |
|
331 test(r==KErrPermissionDenied); |
|
332 |
|
333 __UHEAP_MARKEND; |
|
334 } |
|
335 |
|
336 |
|
337 |
|
338 LOCAL_C void privateRFsTest() |
|
339 // |
|
340 // |
|
341 // |
|
342 { |
|
343 __UHEAP_MARK; |
|
344 //private |
|
345 pritestname=KPrivatePath; |
|
346 pritestname[0]=(TText)('A' + gTheDriveNum); |
|
347 |
|
348 mkdirname.Zero(); |
|
349 mkdirname.Append(pritestname); |
|
350 mkdirname.Append(KMkDirSub); |
|
351 |
|
352 r=TheFs.MkDirAll(mkdirname); |
|
353 test(r==KErrPermissionDenied); |
|
354 |
|
355 r=TheFs.RmDir(mkdirname); |
|
356 test(r==KErrPermissionDenied); |
|
357 |
|
358 r=TheFs.SetSubst(pritestname,EDriveO); |
|
359 test(r==KErrPermissionDenied); |
|
360 |
|
361 r=TheFs.RealName(_L("O:\\File.XXX"),realName); |
|
362 test(r==KErrNone); |
|
363 |
|
364 r=TheFs.SetSessionPath(pritestname); |
|
365 test(r==KErrPermissionDenied); |
|
366 |
|
367 TheFs.NotifyChange(ENotifyAll,aStat2,pritestname); |
|
368 test(r==KErrPermissionDenied); |
|
369 |
|
370 |
|
371 pritestfile=KPrivatePath; |
|
372 pritestfile[0]=(TText)('A' + gTheDriveNum); |
|
373 pritestfile1=pritestfile; |
|
374 pritestfile.Append(KFilePri2); |
|
375 pritestfile1.Append(KFilePri3); |
|
376 |
|
377 oldName=KOldFile; |
|
378 oldName[0]=(TText)gDriveToTest; |
|
379 |
|
380 r=TheFs.GetShortName(pritestfile, shortfilename); |
|
381 test(r==KErrPermissionDenied || r==KErrNotSupported); |
|
382 |
|
383 r=TheFs.GetLongName(pritestfile1, longfilename); |
|
384 test(r==KErrPermissionDenied || r==KErrNotSupported); |
|
385 |
|
386 r=file1.Create(TheFs,oldName,EFileWrite); |
|
387 test(r==KErrNone || r==KErrAlreadyExists); |
|
388 file1.Close(); |
|
389 |
|
390 r=TheFs.Replace(oldName,pritestfile); |
|
391 test(r==KErrPermissionDenied); |
|
392 |
|
393 r=TheFs.Rename(pritestfile,pritestfile1); |
|
394 test(r==KErrPermissionDenied); |
|
395 |
|
396 r=TheFs.Entry(pritestfile1,entry); |
|
397 test(r==KErrPermissionDenied); |
|
398 |
|
399 r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly); |
|
400 test(r==KErrPermissionDenied); |
|
401 |
|
402 r=TheFs.Delete(pritestfile1); |
|
403 test(r==KErrPermissionDenied); |
|
404 |
|
405 __UHEAP_MARKEND; |
|
406 } |
|
407 |
|
408 |
|
409 LOCAL_C void privateSIDRFstest() |
|
410 { |
|
411 __UHEAP_MARK; |
|
412 |
|
413 theprivatepath[0]=(TText)gDriveToTest; |
|
414 test.Printf(_L("the Private Path = %S"),&theprivatepath); |
|
415 |
|
416 mkdirname.Zero(); |
|
417 mkdirname.Append(theprivatepath); |
|
418 mkdirname.Append(KMkDirSub); |
|
419 r=TheFs.MkDirAll(mkdirname); |
|
420 test(r==KErrNone); |
|
421 |
|
422 r=TheFs.RmDir(mkdirname); |
|
423 test(r==KErrNone); |
|
424 |
|
425 r=TheFs.SetSubst(theprivatepath,EDriveO); |
|
426 test(r==KErrPermissionDenied || r==KErrGeneral); // Drive may already be substituted |
|
427 |
|
428 r=TheFs.RealName(_L("O:\\File.XXX"),realName); |
|
429 test(r==KErrNone); |
|
430 |
|
431 r=TheFs.SetSessionPath(theprivatepath); |
|
432 test(r==KErrNone); |
|
433 |
|
434 TheFs.NotifyChange(ENotifyAll,aStat3,theprivatepath); |
|
435 test(aStat3==KRequestPending); |
|
436 |
|
437 pritestfile=theprivatepath; |
|
438 pritestfile[0]=(TText)('A' + gTheDriveNum); |
|
439 pritestfile1=pritestfile; |
|
440 pritestfile.Append(KFilePri2); |
|
441 pritestfile1.Append(KFilePri3); |
|
442 |
|
443 oldName=KOldFile; |
|
444 oldName[0]=(TText)gDriveToTest; |
|
445 |
|
446 r=TheFs.GetShortName(pritestfile, shortfilename); |
|
447 test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported); |
|
448 |
|
449 r=TheFs.GetLongName(pritestfile1, longfilename); |
|
450 test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported); |
|
451 |
|
452 r=file1.Create(TheFs,oldName,EFileWrite); |
|
453 test(r==KErrNone || r==KErrAlreadyExists); |
|
454 file1.Close(); |
|
455 |
|
456 r=TheFs.Replace(oldName,pritestfile); |
|
457 test(r==KErrNone); |
|
458 |
|
459 r=TheFs.Rename(pritestfile,pritestfile1); |
|
460 test(r==KErrNone || r==KErrAlreadyExists); |
|
461 |
|
462 r=TheFs.Entry(pritestfile1,entry); |
|
463 test(r==KErrNone); |
|
464 |
|
465 r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly); |
|
466 test(r==KErrNone); |
|
467 |
|
468 r=TheFs.Delete(pritestfile1); |
|
469 test(r==KErrNone); |
|
470 |
|
471 __UHEAP_MARKEND; |
|
472 } |
|
473 |
|
474 |
|
475 LOCAL_C void systemRFiletest() |
|
476 // |
|
477 //RFile testing with session path set to //sys// |
|
478 // |
|
479 { |
|
480 __UHEAP_MARK; |
|
481 |
|
482 r=TheFs.SetSessionPath(systestname); |
|
483 test(r==KErrPermissionDenied); |
|
484 |
|
485 r=file1.Temp(TheFs,systestname,fromTemp,EFileWrite); |
|
486 test(r==KErrNone); |
|
487 file1.Close(); |
|
488 |
|
489 TBuf<25> sysfilename; |
|
490 sysfilename.Append(systestname); |
|
491 sysfilename.Append(KFileSys); |
|
492 |
|
493 r=file1.Create(TheFs,sysfilename,EFileWrite); |
|
494 test(r==KErrNone); |
|
495 file1.Close(); |
|
496 |
|
497 r=file1.Open(TheFs,sysfilename,EFileWrite); |
|
498 test(r==KErrNone); |
|
499 file1.Close(); |
|
500 |
|
501 r=file1.Open(TheFs,sysfilename,EFileRead); |
|
502 test(r==KErrPermissionDenied); |
|
503 file1.Close(); |
|
504 |
|
505 r=file1.Replace(TheFs,sysfilename,EFileWrite); |
|
506 test(r==KErrNone); |
|
507 |
|
508 TBuf<25> sysfilename2; |
|
509 sysfilename2.Append(systestname); |
|
510 sysfilename2.Append(KFileSys3); |
|
511 |
|
512 r=file1.Rename(sysfilename2); |
|
513 test(r==KErrNone); |
|
514 file1.Close(); |
|
515 |
|
516 TFindFile finder(TheFs); |
|
517 CDir* dir = NULL; |
|
518 r=finder.FindWildByDir(KWildFile, KWildPath, dir); |
|
519 if (!(r==KErrPermissionDenied)) |
|
520 test.Printf(_L("T_DCTCB: test find wildcards r = %d (expected KErrPermissionDenied)\n"), r); |
|
521 test(r==KErrPermissionDenied); |
|
522 delete dir; |
|
523 |
|
524 __UHEAP_MARKEND; |
|
525 } |
|
526 |
|
527 LOCAL_C void resourceRFiletest() |
|
528 // |
|
529 //RFile testing with session path set to //resource// |
|
530 // |
|
531 { |
|
532 __UHEAP_MARK; |
|
533 |
|
534 r=TheFs.SetSessionPath(restestname); |
|
535 test(r==KErrNone); |
|
536 |
|
537 r=file1.Temp(TheFs,restestname,fromTemp,EFileWrite); |
|
538 test(r==KErrNone); |
|
539 file1.Close(); |
|
540 |
|
541 r=file1.Create(TheFs,KFileRes,EFileWrite); |
|
542 test(r==KErrNone); |
|
543 file1.Close(); |
|
544 |
|
545 r=file1.Open(TheFs,KFileRes,EFileWrite|EFileShareExclusive ); |
|
546 test(r==KErrNone); |
|
547 |
|
548 r=file1.Rename(KFileRes3); |
|
549 test(r==KErrNone); |
|
550 file1.Close(); |
|
551 |
|
552 r=file1.Open(TheFs,KFileRes3,EFileShareReadersOrWriters|EFileRead); |
|
553 test(r==KErrNone); |
|
554 file1.Close(); |
|
555 |
|
556 r=file1.Open(TheFs,KFileRes3,EFileShareReadersOrWriters|EFileWrite); |
|
557 test(r==KErrNone); |
|
558 file1.Close(); |
|
559 |
|
560 r=file1.Open(TheFs,KFileRes3,EFileShareReadersOnly); |
|
561 test(r==KErrNone); |
|
562 |
|
563 r=file1.ChangeMode(EFileShareExclusive); |
|
564 test(r==KErrNone); |
|
565 file1.Close(); |
|
566 |
|
567 r=file1.Replace(TheFs,KFileRes,EFileWrite); |
|
568 test(r==KErrNone); |
|
569 file1.Close(); |
|
570 |
|
571 __UHEAP_MARKEND; |
|
572 |
|
573 } |
|
574 |
|
575 |
|
576 LOCAL_C void privatefalseIDRFiletest() |
|
577 // |
|
578 //RFile testing with session path set to //Private//false ID |
|
579 // |
|
580 { |
|
581 __UHEAP_MARK; |
|
582 |
|
583 r=TheFs.SetSessionPath(pritestfalseidname); |
|
584 test(r==KErrPermissionDenied); |
|
585 |
|
586 r=file1.Temp(TheFs,pritestfalseidname,fromTemp,EFileWrite); |
|
587 test(r==KErrPermissionDenied); |
|
588 file1.Close(); |
|
589 |
|
590 // Since can't set session path create explicit path |
|
591 pritestfile=KPrivateFalseID; |
|
592 pritestfile[0]=(TText)('A' + gTheDriveNum); |
|
593 pritestfile.Append(KFilePri); |
|
594 |
|
595 r=file1.Create(TheFs,pritestfile,EFileWrite); |
|
596 test(r==KErrPermissionDenied); |
|
597 file1.Close(); |
|
598 |
|
599 r=file1.Open(TheFs,pritestfile,EFileWrite); |
|
600 test(r==KErrPermissionDenied); |
|
601 file1.Close(); |
|
602 |
|
603 r=file1.Open(TheFs,pritestfile,EFileRead); |
|
604 test(r==KErrPermissionDenied); |
|
605 file1.Close(); |
|
606 |
|
607 r=file1.Replace(TheFs,pritestfile,EFileWrite); |
|
608 test(r==KErrPermissionDenied); |
|
609 |
|
610 // File does not exist so can't rename it |
|
611 /* r=file1.Rename(KFilePri3); |
|
612 test(r==KErrAlreadyExists || r==KErrNone); |
|
613 file1.Close(); |
|
614 */ __UHEAP_MARKEND; |
|
615 } |
|
616 |
|
617 |
|
618 LOCAL_C void privateRFiletest() |
|
619 // |
|
620 //RFile testing with session path set to //Private// |
|
621 // |
|
622 { |
|
623 __UHEAP_MARK; |
|
624 |
|
625 r=TheFs.SetSessionPath(pritestname); |
|
626 test(r==KErrPermissionDenied); |
|
627 |
|
628 r=file1.Temp(TheFs,pritestname,fromTemp,EFileWrite); |
|
629 test(r==KErrPermissionDenied); |
|
630 file1.Close(); |
|
631 |
|
632 // Since can't set session path create explicit path |
|
633 pritestfile=KPrivatePath; |
|
634 pritestfile[0]=(TText)('A' + gTheDriveNum); |
|
635 pritestfile.Append(KFilePri); |
|
636 |
|
637 r=file1.Create(TheFs,pritestfile,EFileWrite); |
|
638 test(r==KErrPermissionDenied); |
|
639 file1.Close(); |
|
640 |
|
641 r=file1.Open(TheFs,pritestfile,EFileWrite); |
|
642 test(r==KErrPermissionDenied); |
|
643 file1.Close(); |
|
644 |
|
645 r=file1.Open(TheFs,pritestfile,EFileRead); |
|
646 test(r==KErrPermissionDenied); |
|
647 file1.Close(); |
|
648 |
|
649 r=file1.Replace(TheFs,pritestfile,EFileWrite); |
|
650 test(r==KErrPermissionDenied); |
|
651 |
|
652 // File does not exist so can't be renamed |
|
653 /* r=file1.Rename(KFilePri3); |
|
654 test(r==KErrNone); |
|
655 file1.Close(); |
|
656 */ |
|
657 __UHEAP_MARKEND; |
|
658 } |
|
659 |
|
660 |
|
661 LOCAL_C void privateSIDRFiletest() |
|
662 // |
|
663 //Rfile Testing with session path set to //Private//UID// |
|
664 // |
|
665 { |
|
666 __UHEAP_MARK; |
|
667 r=TheFs.SetSessionToPrivate(gTheDriveNum); |
|
668 test(r==KErrNone); |
|
669 |
|
670 r=file1.Temp(TheFs,theprivatepath,fromTemp,EFileWrite); |
|
671 test(r==KErrNone); |
|
672 file1.Close(); |
|
673 |
|
674 r=file1.Create(TheFs,KFilePri,EFileWrite); |
|
675 test(r==KErrNone); |
|
676 file1.Close(); |
|
677 |
|
678 r=file1.Open(TheFs,KFilePri,EFileWrite); |
|
679 test(r==KErrNone); |
|
680 file1.Close(); |
|
681 |
|
682 r=file1.Open(TheFs,KFilePri,EFileRead); |
|
683 test(r==KErrNone); |
|
684 file1.Close(); |
|
685 |
|
686 r=file1.Replace(TheFs,KFilePri,EFileWrite); |
|
687 test(r==KErrNone); |
|
688 |
|
689 r=file1.Rename(KFilePri3); |
|
690 test(r==KErrNone); |
|
691 file1.Close(); |
|
692 __UHEAP_MARKEND; |
|
693 } |
|
694 |
|
695 LOCAL_C void RDirtest() |
|
696 // |
|
697 // |
|
698 // |
|
699 { |
|
700 __UHEAP_MARK; |
|
701 |
|
702 //system |
|
703 CDir* dirEntries; |
|
704 TBuf<30> dirNameBuf(KSystemPath); |
|
705 dirNameBuf[0]=(TText)gDriveToTest; |
|
706 r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal); |
|
707 test(r==KErrPermissionDenied); |
|
708 dir.Close(); |
|
709 r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries); |
|
710 test(r==KErrPermissionDenied); |
|
711 dirNameBuf.Zero(); |
|
712 delete dirEntries; |
|
713 |
|
714 //Private |
|
715 dirNameBuf=KPrivatePath; |
|
716 dirNameBuf[0]=(TText)gDriveToTest; |
|
717 r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal); |
|
718 test(r==KErrPermissionDenied); |
|
719 dir.Close(); |
|
720 r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries); |
|
721 test(r==KErrPermissionDenied); |
|
722 dirNameBuf.Zero(); |
|
723 delete dirEntries; |
|
724 |
|
725 //Private//falseID |
|
726 dirNameBuf=KPrivateFalseID; |
|
727 dirNameBuf[0]=(TText)gDriveToTest; |
|
728 r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal); |
|
729 test(r==KErrPermissionDenied); |
|
730 dir.Close(); |
|
731 r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries); |
|
732 test(r==KErrPermissionDenied); |
|
733 dirNameBuf.Zero(); |
|
734 delete dirEntries; |
|
735 |
|
736 //Private/uid |
|
737 TheFs.PrivatePath(dirNameBuf); |
|
738 dirNameBuf.Insert(0,_L("?:")); |
|
739 dirNameBuf[0]=(TText)gDriveToTest; |
|
740 r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal); |
|
741 test(r==KErrNone); |
|
742 dir.Close(); |
|
743 r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries); |
|
744 test(r==KErrNone); |
|
745 dirNameBuf.Zero(); |
|
746 delete dirEntries; |
|
747 //Resource |
|
748 dirNameBuf=KResourcePath; |
|
749 dirNameBuf[0]=(TText)gDriveToTest; |
|
750 r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal); |
|
751 test(r==KErrNone); |
|
752 r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries); |
|
753 test(r==KErrNone); |
|
754 dir.Close(); |
|
755 delete dirEntries; |
|
756 __UHEAP_MARKEND; |
|
757 } |
|
758 |
|
759 |
|
760 LOCAL_C void TestTcbCaps() |
|
761 // |
|
762 // Test with tcb capabilities |
|
763 // |
|
764 { |
|
765 __UHEAP_MARK; |
|
766 r=TheFs.FileSystemName(fsname,gTheDriveNum); |
|
767 test(r==KErrNone); |
|
768 r = DismountFileSystem(TheFs, fsname, gTheDriveNum); |
|
769 test(r==KErrPermissionDenied); |
|
770 r = MountFileSystem(TheFs, fsname, gTheDriveNum); |
|
771 test(r==KErrPermissionDenied); |
|
772 r=TheFs.SetDriveName(gTheDriveNum,KDriveName); |
|
773 test(r==KErrPermissionDenied); |
|
774 #ifndef __WINS__ |
|
775 r=TheFs.SetVolumeLabel(KVolLable, gTheDriveNum); |
|
776 test(r==KErrPermissionDenied); |
|
777 #endif |
|
778 |
|
779 systemRFsTest(); |
|
780 ResourceRFsTest(); |
|
781 privateRFsTest(); |
|
782 privateSIDRFstest(); |
|
783 |
|
784 privatefalseIDRFsTest(); |
|
785 |
|
786 systemRFiletest(); |
|
787 resourceRFiletest(); |
|
788 privateRFiletest(); |
|
789 privateSIDRFiletest(); |
|
790 privatefalseIDRFiletest(); |
|
791 |
|
792 //check notifier return values set in rfs testing |
|
793 User::WaitForRequest(aStat1); |
|
794 User::WaitForRequest(aStat2); |
|
795 User::WaitForRequest(aStat3); |
|
796 User::WaitForRequest(aStat4); |
|
797 test(aStat1==KErrPermissionDenied); |
|
798 test(aStat2==KErrPermissionDenied); |
|
799 test(aStat3==KErrNone); |
|
800 test(aStat4==KErrNone); |
|
801 |
|
802 r=TheFs.SetSessionPath(systestname); |
|
803 test(r==KErrPermissionDenied); |
|
804 |
|
805 //Test RRawDisk class |
|
806 r=rawdisk.Open(TheFs,gTheDriveNum); |
|
807 test(r==KErrNone); |
|
808 rawdisk.Close(); |
|
809 |
|
810 RDirtest(); |
|
811 |
|
812 #ifdef __WINS__ |
|
813 if (User::UpperCase(driveBuf[0]) != 'C') |
|
814 #endif |
|
815 { |
|
816 //Test RFormat class |
|
817 r=format.Open(TheFs,driveBuf,EHighDensity,count); |
|
818 test(r==KErrPermissionDenied); |
|
819 |
|
820 while(count) |
|
821 { |
|
822 TInt r=format.Next(count); |
|
823 test(r==KErrNone); |
|
824 } |
|
825 format.Close(); |
|
826 } |
|
827 |
|
828 driveBuf[0]=(TText)gDriveToTest; |
|
829 r=TheFs.ScanDrive(driveBuf); |
|
830 test((r==KErrPermissionDenied)||(r==KErrNotSupported)); |
|
831 r=TheFs.CheckDisk(driveBuf); |
|
832 test((r==KErrPermissionDenied)||(r==KErrNotSupported)); |
|
833 __UHEAP_MARKEND; |
|
834 } |
|
835 |
|
836 LOCAL_C void TestCaps() |
|
837 // |
|
838 // test format etc that require certain capabilities |
|
839 // |
|
840 { |
|
841 __UHEAP_MARK; |
|
842 #ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
843 const char myDiagMsg[] = "Capability Check Failure"; |
|
844 #endif //!__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
845 r=RProcess().HasCapability(ECapabilityTCB, __PLATSEC_DIAGNOSTIC_STRING(myDiagMsg)); |
|
846 test(r); |
|
847 |
|
848 driveBuf[0]=(TText)gDriveToTest; |
|
849 r=TheFs.SessionPath(temp); |
|
850 test(r==KErrNone); |
|
851 test.Printf(_L("Session path: %S"),&temp); |
|
852 r=TheFs.CreatePrivatePath(gTheDriveNum); |
|
853 test(r==KErrNone || r== KErrAlreadyExists); |
|
854 |
|
855 TBuf<18> tempPri; |
|
856 r=TheFs.PrivatePath(tempPri); |
|
857 test(r==KErrNone); |
|
858 theprivatepath = _L("?:"); |
|
859 theprivatepath.Append(tempPri); |
|
860 |
|
861 TestTcbCaps(); |
|
862 |
|
863 TFileName thesessionpath; |
|
864 r=TheFs.SetSessionToPrivate(gTheDriveNum); |
|
865 test(r==KErrNone); |
|
866 r=TheFs.SessionPath(thesessionpath); |
|
867 test(r==KErrNone); |
|
868 test(thesessionpath == theprivatepath); |
|
869 __UHEAP_MARKEND; |
|
870 } |
|
871 |
|
872 |
|
873 TFileName dirName; |
|
874 |
|
875 LOCAL_C void ScanDir(const TDesC& aName, CDirScan::TScanDirection aDirection, TInt aError) |
|
876 { |
|
877 CDirScan* scanner = NULL; |
|
878 TRAP(r, scanner = CDirScan::NewL(TheFs)); |
|
879 test(r == KErrNone && scanner); |
|
880 |
|
881 TRAP(r, scanner->SetScanDataL(aName,KEntryAttDir,ESortByName|EAscending,aDirection)); |
|
882 test(r == KErrNone); |
|
883 |
|
884 CDir *entryList=NULL; |
|
885 for (;;) |
|
886 { |
|
887 TRAP(r, scanner->NextL(entryList)); |
|
888 test(r == aError); |
|
889 if (entryList==NULL) |
|
890 break; |
|
891 TInt count=entryList->Count(); |
|
892 while (count--) |
|
893 { |
|
894 TEntry data=(*entryList)[count]; |
|
895 TBuf<KMaxFileName> path=scanner->AbbreviatedPath(); |
|
896 dirName = path; |
|
897 dirName.Append(data.iName); |
|
898 test.Printf(_L(" %S\n"),&dirName); |
|
899 |
|
900 } |
|
901 delete entryList; |
|
902 entryList=NULL; |
|
903 } |
|
904 delete scanner; |
|
905 |
|
906 } |
|
907 |
|
908 /** |
|
909 The following test, tests CFileMan and CDirScan API on folders private and sys |
|
910 to confirm that any operation on these folders for any app with incorrect capability |
|
911 returns KErrPermissionDenied. This test step was added as a result of DEF051428 |
|
912 ("PlatSec: Incorrect errors returned by f32") |
|
913 */ |
|
914 LOCAL_C void TestCaging() |
|
915 { |
|
916 CFileMan* fMan=CFileMan::NewL(TheFs); |
|
917 TInt r; |
|
918 if(fMan!=NULL) |
|
919 { |
|
920 |
|
921 // Checking the private path |
|
922 TBuf<30> privatepath; |
|
923 r=TheFs.PrivatePath(privatepath); |
|
924 test.Printf(_L("Private Path is=%S"),&privatepath); |
|
925 |
|
926 r = TheFs.MkDir(_L("\\Caged\\")); |
|
927 test(r==KErrNone || r==KErrAlreadyExists); |
|
928 |
|
929 CDir* entryCount=NULL; |
|
930 r=TheFs.GetDir(_L("\\*.*"),KEntryAttNormal,ESortNone,entryCount); |
|
931 test(r==KErrNone); |
|
932 TInt rootCount= entryCount->Count(); |
|
933 |
|
934 delete entryCount; |
|
935 entryCount=NULL; |
|
936 |
|
937 |
|
938 //Testing Copy |
|
939 CDir* entryCount2=NULL; |
|
940 r=fMan->Copy(_L("\\sys\\"),_L("\\Caged\\")); |
|
941 test(r == KErrPermissionDenied); |
|
942 r=fMan->Copy(_L("\\*"),_L("\\Caged\\")); |
|
943 test(r == KErrNone); |
|
944 |
|
945 r=TheFs.GetDir(_L("\\Caged\\*.*"),KEntryAttNormal,ESortNone,entryCount2); |
|
946 test(r==KErrNone); |
|
947 TInt cagedCount= entryCount2->Count(); |
|
948 |
|
949 test(cagedCount==rootCount); |
|
950 |
|
951 delete entryCount2; |
|
952 entryCount2=NULL; |
|
953 |
|
954 r=fMan->Copy(_L("\\private\\two\\moo"),_L("\\private\\two\\mew")); |
|
955 test(r == KErrPermissionDenied); |
|
956 |
|
957 // Create a test file |
|
958 RFile testFile; |
|
959 r = testFile.Replace(TheFs, _L("\\capTest"),EFileWrite); |
|
960 test(r==KErrNone || r==KErrAlreadyExists); |
|
961 testFile.Close(); |
|
962 |
|
963 TFileName name; |
|
964 name = privatepath; |
|
965 name.Append(_L("privateFile.tst")); |
|
966 RFile privateFile; |
|
967 r = privateFile.Replace(TheFs, name,EFileWrite); |
|
968 test(r==KErrNone || r==KErrAlreadyExists); |
|
969 privateFile.Close(); |
|
970 |
|
971 |
|
972 r=fMan->Copy(_L("\\capTest"),_L("\\private\\two\\moo")); |
|
973 test(r == KErrPermissionDenied); |
|
974 r=fMan->Copy(_L("\\capTest"),_L("\\sys\\bin\\moo")); |
|
975 test(r == KErrPathNotFound); |
|
976 r=fMan->Copy(_L("\\sys\\bin\\capTest"),_L("\\sys\\bin\\moo")); |
|
977 test(r == KErrPermissionDenied); |
|
978 r=fMan->Copy(_L("\\capTest"),_L("\\sys\\capTest")); |
|
979 test(r == KErrNone || r==KErrAlreadyExists); |
|
980 r=fMan->Copy(_L("\\sys\\*"),_L("\\")); |
|
981 test (r==KErrPermissionDenied); |
|
982 r=fMan->Copy(name,_L("\\sys\\")); |
|
983 test(r==KErrNone); |
|
984 |
|
985 // Testing Move |
|
986 r=fMan->Move(_L("\\private\\two\\moo"),_L("\\private\\one\\moo")); |
|
987 test(r == KErrPermissionDenied); |
|
988 r=fMan->Move(_L("\\private\\two\\moo.."),_L("\\private\\one\\moo")); |
|
989 test(r == KErrPermissionDenied); |
|
990 r=fMan->Move(_L("\\private\\two\\moo"),_L("\\private\\one\\moo..")); |
|
991 test(r == KErrPermissionDenied); |
|
992 r=fMan->Move(name,_L("\\privateFile.tst")); |
|
993 test(r == KErrNone); |
|
994 r=fMan->Move(_L("\\privateFile.tst"),name); |
|
995 test(r == KErrNone); |
|
996 |
|
997 |
|
998 // Testing Attribs |
|
999 r=fMan->Attribs(_L("\\private\\two\\moo"),KEntryAttReadOnly,0,TTime(0)); |
|
1000 test(r == KErrPermissionDenied); |
|
1001 r=fMan->Attribs(_L("\\private\\moo"),KEntryAttReadOnly,0,TTime(0)); |
|
1002 test(r == KErrPermissionDenied); |
|
1003 r=fMan->Attribs(name,KEntryAttReadOnly,0,TTime(0)); |
|
1004 test(r == KErrNone); |
|
1005 r=fMan->Attribs(name,0,KEntryAttReadOnly,TTime(0)); |
|
1006 test(r == KErrNone); |
|
1007 |
|
1008 // Testing Move |
|
1009 r=fMan->Move(_L("\\private\\two\\moo"),_L("\\private\\one\\moo")); |
|
1010 test(r == KErrPermissionDenied); |
|
1011 r=fMan->Move(_L("\\private\\two\\moo.."),_L("\\private\\one\\moo")); |
|
1012 test(r == KErrPermissionDenied); |
|
1013 r=fMan->Move(_L("\\private\\two\\moo"),_L("\\private\\one\\moo..")); |
|
1014 test(r == KErrPermissionDenied); |
|
1015 r=fMan->Move(name,_L("\\privateFile.tst")); |
|
1016 test(r == KErrNone); |
|
1017 r=fMan->Move(_L("\\privateFile.tst"),name); |
|
1018 test(r == KErrNone); |
|
1019 |
|
1020 |
|
1021 // Testing RmDir |
|
1022 r=fMan->RmDir(_L("\\private\\")); |
|
1023 test(r == KErrPermissionDenied); |
|
1024 r=fMan->RmDir(_L("\\private\\two\\")); |
|
1025 test(r == KErrPermissionDenied); |
|
1026 r=fMan->RmDir(_L("\\private\\tw?\\")); |
|
1027 test(r == KErrPermissionDenied); |
|
1028 r=fMan->RmDir(_L("\\sys\\")); |
|
1029 test(r == KErrPermissionDenied); |
|
1030 |
|
1031 |
|
1032 // Testing Rename |
|
1033 r=fMan->Rename(_L("\\private\\two\\moo"),_L("\\private\\two\\mew")); |
|
1034 test(r == KErrPermissionDenied); |
|
1035 |
|
1036 // Testing Delete |
|
1037 r=fMan->Delete(_L("\\private\\two\\test")); |
|
1038 test(r == KErrPermissionDenied); |
|
1039 r=fMan->Delete(_L("\\private\\moo")); |
|
1040 test(r == KErrPermissionDenied); |
|
1041 r=fMan->Delete(_L("\\sys\\")); |
|
1042 test(r == KErrPermissionDenied); |
|
1043 |
|
1044 //Something that actually exists in Private |
|
1045 r=fMan->Rename(name,_L("\\private\\00000001\\moo")); |
|
1046 test(r == KErrNone); |
|
1047 r=fMan->Rename(_L("\\private\\00000001\\moo"),name); |
|
1048 test(r == KErrNone); |
|
1049 r=fMan->Copy(name,_L("\\private\\00000001\\moo")); |
|
1050 test(r == KErrNone); |
|
1051 r=fMan->Delete(_L("\\private\\00000001\\moo")); |
|
1052 test(r == KErrNone); |
|
1053 |
|
1054 // Clean up the test data |
|
1055 r=fMan->RmDir(_L("\\Caged\\")); |
|
1056 test(r == KErrNone); |
|
1057 r=fMan->Delete(_L("\\capTest")); |
|
1058 test(r == KErrNone); |
|
1059 r=fMan->Delete(name); |
|
1060 test(r == KErrNone); |
|
1061 delete(fMan); |
|
1062 } |
|
1063 |
|
1064 // CDirScan tests |
|
1065 ScanDir(_L("\\"), CDirScan::EScanUpTree, KErrNone); |
|
1066 ScanDir(_L("\\"), CDirScan::EScanDownTree, KErrNone); |
|
1067 ScanDir(_L("\\private\\"), CDirScan::EScanDownTree, KErrPermissionDenied); |
|
1068 ScanDir(_L("\\private\\"), CDirScan::EScanUpTree, KErrPermissionDenied); |
|
1069 ScanDir(_L("\\sys\\"), CDirScan::EScanDownTree, KErrPermissionDenied); |
|
1070 ScanDir(_L("\\sys\\"), CDirScan::EScanUpTree, KErrPermissionDenied); |
|
1071 } |
|
1072 |
|
1073 void TestSystemDrive() |
|
1074 { |
|
1075 test.Next(_L("TestSystemDrive")); |
|
1076 TDriveNumber drive = RFs::GetSystemDrive(); |
|
1077 test.Printf(_L("System Drive is %c:\n"), 'A'+drive); |
|
1078 for(TInt i=EDriveA; i<=EDriveZ; i++) |
|
1079 { |
|
1080 TDriveInfo info; |
|
1081 test(TheFs.Drive(info, i) == KErrNone); |
|
1082 if(info.iType==EMediaHardDisk || info.iType==EMediaFlash || info.iType==EMediaNANDFlash) |
|
1083 { |
|
1084 if(info.iDriveAtt & (KDriveAttLocal|KDriveAttInternal)) |
|
1085 { |
|
1086 if(!(info.iDriveAtt & (KDriveAttRom|KDriveAttRedirected|KDriveAttSubsted|KDriveAttRemovable))) |
|
1087 { |
|
1088 test.Printf(_L("Setting %c:"), 'A'+i); |
|
1089 TInt ret = TheFs.SetSystemDrive((TDriveNumber)i); |
|
1090 test.Printf(_L("%d\n"), ret); |
|
1091 test(ret == KErrNone || ret == KErrAlreadyExists); |
|
1092 if(ret == KErrNone) |
|
1093 { |
|
1094 drive = (TDriveNumber)i; |
|
1095 test.Printf(_L("Re-setting %c:"), 'A'+i); |
|
1096 ret = TheFs.SetSystemDrive(drive); |
|
1097 test.Printf(_L("%d\n"), ret); |
|
1098 test(ret == KErrAlreadyExists); |
|
1099 } |
|
1100 } |
|
1101 } |
|
1102 } |
|
1103 } |
|
1104 TChar drvchar = RFs::GetSystemDriveChar(); |
|
1105 test(drvchar == (TChar)('A' + drive)); |
|
1106 test(drive == RFs::GetSystemDrive()); |
|
1107 } |
|
1108 |
|
1109 LOCAL_C void CleanupL() |
|
1110 // |
|
1111 // Clean up tests |
|
1112 // |
|
1113 { |
|
1114 test.Next(_L("Delete test directory")); |
|
1115 CFileMan* fMan=CFileMan::NewL(TheFs); |
|
1116 TInt r=fMan->RmDir(gSessionPath); |
|
1117 test(r==KErrNone || KErrPathNotFound); |
|
1118 delete fMan; |
|
1119 } |
|
1120 |
|
1121 GLDEF_C void CallTestsL(/*TChar aDriveLetter*/) |
|
1122 // |
|
1123 // Do all tests |
|
1124 // |
|
1125 { |
|
1126 if( !PlatSec::IsCapabilityEnforced(ECapabilityTCB)) |
|
1127 { |
|
1128 test.Printf(_L("Capability ECapabilityTCB not enabled - leaving t_dctcb")); |
|
1129 test.Printf(_L("\n")); // Prevent overwrite by next print |
|
1130 return; |
|
1131 } |
|
1132 |
|
1133 TurnAllocFailureOff(); |
|
1134 TheFs.CharToDrive(gDriveToTest,gTheDriveNum); |
|
1135 |
|
1136 TBuf<30> sesspath; |
|
1137 sesspath=_L("?:\\"); |
|
1138 sesspath[0] = (TText)gDriveToTest; |
|
1139 |
|
1140 TInt r= TheFs.SetSessionPath(sesspath); |
|
1141 test(r==KErrNone); |
|
1142 |
|
1143 //cleanup from previous run of this test |
|
1144 TBuf<20> delDir; |
|
1145 CFileMan* fMan=CFileMan::NewL(TheFs); |
|
1146 delDir=KResourcePath; |
|
1147 delDir[0]=(TText)gDriveToTest; |
|
1148 r=fMan->RmDir(delDir); |
|
1149 test(r==KErrNone || KErrNotFound); |
|
1150 delDir=KSystemPath; |
|
1151 delDir[0]=(TText)gDriveToTest; |
|
1152 r=fMan->RmDir(delDir); |
|
1153 test(r==KErrNone || KErrNotFound); |
|
1154 delDir=KPrivatePath; |
|
1155 delDir[0]=(TText)gDriveToTest; |
|
1156 r=fMan->RmDir(delDir); |
|
1157 test(r==KErrNone || KErrNotFound); |
|
1158 delete fMan; |
|
1159 |
|
1160 //check double mode ie that Defpath still works |
|
1161 RFs fs1; |
|
1162 RFs fs2; |
|
1163 |
|
1164 r=fs1.Connect(); |
|
1165 test(r==KErrNone); |
|
1166 r=fs1.SessionPath(sesspath); |
|
1167 test(r==KErrNone); |
|
1168 test.Printf(_L("session1 Path=%S"),&sesspath); |
|
1169 |
|
1170 TBuf<30> privatepath; |
|
1171 r=fs1.SetSessionToPrivate(gTheDriveNum); |
|
1172 test(r==KErrNone); |
|
1173 r=fs1.PrivatePath(privatepath); |
|
1174 test(r==KErrNone); |
|
1175 r=privatepath.Compare(KExpectedPrivatePath()); |
|
1176 test(r==0); |
|
1177 r=fs1.SessionPath(sesspath); |
|
1178 test(r==KErrNone); |
|
1179 r=privatepath.Compare(sesspath.Mid(KPathPosition)); |
|
1180 test(r==0); |
|
1181 r=fs1.CreatePrivatePath(gTheDriveNum); |
|
1182 test(r==KErrNone); |
|
1183 fs1.Close(); |
|
1184 |
|
1185 r=fs2.Connect(); |
|
1186 test(r==KErrNone); |
|
1187 r=fs2.SessionPath(sesspath); |
|
1188 test(r==KErrNone); |
|
1189 test.Printf(_L("session2 Path=%S"),&sesspath); |
|
1190 fs2.Close(); |
|
1191 |
|
1192 TestCaps(); |
|
1193 TestCaging(); |
|
1194 TestPathCheck(); |
|
1195 TestSystemDrive(); |
|
1196 |
|
1197 test.Printf(_L("No of files open=%d"), TheFs.ResourceCount()); |
|
1198 |
|
1199 CleanupL(); |
|
1200 } |