First public contribution.
1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 #include <e32std_private.h>
21 #include <e32def_private.h>
25 GLDEF_D RTest test(_L("t_dcallfiles"));
26 GLDEF_D TTime gTimeNow;
27 LOCAL_D TInt gTheDriveNum;
29 //_LIT(KDefPath, "\\Default\\");
31 const TInt KPathPosition = 2;
32 _LIT(KExpectedPrivatePath, "\\Private\\00000001\\");
34 _LIT(KResourcePath, "?:\\Resource\\");
35 _LIT(KSystemPath, "?:\\Sys\\");
36 _LIT(KPrivatePath, "?:\\Private\\");
37 _LIT(KPrivateFalseID, "?:\\Private\\FFFFFFFF\\");
38 _LIT(KDriveName, "Billy");
39 //_LIT(KVolLable, "Benny");
41 _LIT(KFileSys, "systemfile.txt");
42 //_LIT(KFileSys2, "systemfile.tmp");
43 _LIT(KFileSys3, "sysfile.rna");
45 _LIT(KFilePri, "privatefile.txt");
46 _LIT(KFilePri2, "privatefile.tmp");
47 _LIT(KFilePri3, "prifile.rna");
49 _LIT(KFileRes, "resourcefile.txt");
50 //_LIT(KFileRes2, "resourcefile.tmp");
51 _LIT(KFileRes3, "resfile.rna");
53 _LIT(KMkDirSub,"Subdir\\");
54 _LIT(KOldFile,"?:\\Anyold.txt");
55 //_LIT(KNullPath, "");
56 //_LIT(KLFFSName, "Lffs");
58 _LIT(KWildPath, "Z:\\SYS\\");
60 _LIT(KSysBinFile, "z:\\sys\\bin\\t_findcaptestfile.txt");
64 TBuf<4> driveBuf=_L("?:\\");
77 TBuf<40> theprivatepath;
78 TBuf<40> pritestfalseidname;
82 TBuf<40> shortfilename;
83 TBuf<40> longfilename;
86 TRequestStatus aStat1;
87 TRequestStatus aStat2;
88 TRequestStatus aStat3;
89 TRequestStatus aStat4;
92 // TDriveInfo adriveInfo;
97 TBuf<40> systestfile1;
98 TBuf<40> pritestfile1;
99 TBuf<40> restestfile1;
109 LOCAL_C void TestPathCheck()
111 // This test case is brought in by INC054580
112 // (NTT Renaming sys ¨Cfolder on C -drive on H2 allows user to access sys -files)
115 TInt r = TheFs.Rename(_L("\\sys"), _L("\\sysbad"));
116 test(r == KErrPermissionDenied);
117 r = TheFs.Rename(_L("\\resource"), _L("\\resourcebad"));
118 test(r == KErrPermissionDenied);
119 r = TheFs.Rename(_L("\\private"), _L("\\privatebad"));
121 r = TheFs.Rename(_L("\\privatebad"), _L("\\private"));
125 LOCAL_C void systemRFstest()
131 systestname=KSystemPath;
132 systestname[0]=(TText)('A' + gTheDriveNum);
135 mkdirname.Append(systestname);
136 mkdirname.Append(KMkDirSub);
137 r=TheFs.MkDirAll(mkdirname);
138 test(r==KErrPermissionDenied);
140 r=TheFs.RmDir(mkdirname);
141 test(r==KErrPermissionDenied);
143 r=TheFs.SetSubst(systestname,EDriveO);
144 test(r==KErrPermissionDenied);
146 r=TheFs.SetSessionPath(systestname);
149 TheFs.NotifyChange(ENotifyAll,aStat1,systestname);
150 test(aStat1==KRequestPending);
152 systestfile=KSystemPath;
153 systestfile[0]=(TText)('A' + gTheDriveNum);
154 systestfile1=systestfile;
155 systestfile.Append(KFileSys);
156 systestfile1.Append(KFileSys3);
159 oldName[0]=(TText)gDriveToTest;
161 r=TheFs.GetShortName(systestfile, shortfilename);
162 test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
164 r=TheFs.GetLongName(systestfile1, longfilename);
165 test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
167 r=file1.Create(TheFs,oldName,EFileWrite);
168 test(r==KErrNone || r==KErrAlreadyExists);
171 r=TheFs.Replace(oldName,systestfile);
172 test(r==KErrPermissionDenied);
174 r=TheFs.Rename(systestfile,systestfile1);
175 test(r==KErrPermissionDenied);
177 r=TheFs.Entry(systestfile1,entry);
178 test(r==KErrNone || r==KErrNotFound);
180 r=TheFs.SetEntry(systestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
181 test(r==KErrPermissionDenied);
183 r=TheFs.Delete(systestfile1);
184 test(r==KErrPermissionDenied);
189 LOCAL_C void resourceRFstest()
195 restestname=KResourcePath;
196 restestname[0]=(TText)('A' + gTheDriveNum);
199 mkdirname.Append(restestname);
200 mkdirname.Append(KMkDirSub);
201 r=TheFs.MkDirAll(mkdirname);
202 test(r==KErrPermissionDenied);
204 TheFs.RmDir(mkdirname);
205 test(r==KErrPermissionDenied);
208 r=TheFs.SetSubst(restestname,EDriveO);
209 test(r==KErrPermissionDenied);
211 r=TheFs.RealName(_L("O:\\File.XXX"),realName);
214 r=TheFs.SetSessionPath(restestname);
217 TheFs.NotifyChange(ENotifyAll,aStat4,restestname);
218 test(aStat4==KRequestPending);
221 restestfile=KResourcePath;
222 restestfile[0]=(TText)('A' + gTheDriveNum);
223 restestfile1=restestfile;
224 restestfile.Append(KFileRes);
225 restestfile1.Append(KFileRes3);
228 oldName[0]=(TText)gDriveToTest;
230 r=TheFs.GetShortName(restestfile, shortfilename);
231 test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
233 r=TheFs.GetLongName(restestfile1, longfilename);
234 test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
236 r=file1.Create(TheFs,oldName,EFileWrite);
237 test(r==KErrNone || r==KErrAlreadyExists);
240 r=TheFs.Replace(oldName,restestfile);
241 test(r==KErrPermissionDenied);
243 r=TheFs.Rename(restestfile,restestfile1);
244 test(r==KErrPermissionDenied);
246 r=TheFs.Entry(restestfile1,entry);
247 test(r==KErrNone || r==KErrNotFound);
249 r=TheFs.SetEntry(restestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
250 test(r==KErrPermissionDenied);
252 r=TheFs.Delete(restestfile1);
253 test(r==KErrPermissionDenied);
258 LOCAL_C void privatefalseIDRFstest()
264 pritestfalseidname=KPrivateFalseID;
265 pritestfalseidname[0]=(TText)('A' + gTheDriveNum);
268 mkdirname.Append(pritestfalseidname);
269 mkdirname.Append(KMkDirSub);
271 r=TheFs.MkDirAll(mkdirname);
274 r=TheFs.RmDir(mkdirname);
277 r=TheFs.SetSubst(pritestfalseidname,EDriveO);
278 test(r==KErrPermissionDenied);
280 r=TheFs.RealName(_L("O:\\File.XXX"),realName);
283 r=TheFs.SetSessionPath(pritestfalseidname);
286 TheFs.NotifyChange(ENotifyAll,aStat2,pritestfalseidname);
287 test(aStat2==KRequestPending);
289 pritestfile=KPrivateFalseID;
290 pritestfile[0]=(TText)('A' + gTheDriveNum);
291 pritestfile1=pritestfile;
292 pritestfile.Append(KFilePri2);
293 pritestfile1.Append(KFilePri3);
296 oldName[0]=(TText)gDriveToTest;
298 r=TheFs.GetShortName(pritestfile, shortfilename);
299 test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
301 r=TheFs.GetLongName(pritestfile1, longfilename);
302 test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
304 r=file1.Create(TheFs,oldName,EFileWrite);
305 test(r==KErrNone || r==KErrAlreadyExists);
308 r=TheFs.Replace(oldName,pritestfile);
311 r=TheFs.Rename(pritestfile,pritestfile1);
312 test(r==KErrNone || r==KErrAlreadyExists);
314 r=TheFs.Entry(pritestfile1,entry);
317 r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
320 r=TheFs.Delete(pritestfile1);
326 LOCAL_C void privateRFstest()
332 pritestname=KPrivatePath;
333 pritestname[0]=(TText)('A' + gTheDriveNum);
336 mkdirname.Append(pritestname);
337 mkdirname.Append(KMkDirSub);
339 r=TheFs.MkDirAll(mkdirname);
342 r=TheFs.RmDir(mkdirname);
345 r=TheFs.SetSubst(pritestname,EDriveO);
346 test(r==KErrPermissionDenied);
348 r=TheFs.RealName(_L("O:\\File.XXX"),realName);
351 r=TheFs.SetSessionPath(pritestname);
354 TheFs.NotifyChange(ENotifyAll,aStat2,pritestname);
355 test(aStat2==KRequestPending);
357 pritestfile=KPrivatePath;
358 pritestfile[0]=(TText)('A' + gTheDriveNum);
359 pritestfile1=pritestfile;
360 pritestfile.Append(KFilePri2);
361 pritestfile1.Append(KFilePri3);
364 oldName[0]=(TText)gDriveToTest;
366 r=TheFs.GetShortName(pritestfile, shortfilename);
367 test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
369 r=TheFs.GetLongName(pritestfile1, longfilename);
370 test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
372 r=file1.Create(TheFs,oldName,EFileWrite);
373 test(r==KErrNone || r==KErrAlreadyExists);
376 r=TheFs.Replace(oldName,pritestfile);
379 r=TheFs.Rename(pritestfile,pritestfile1);
380 test(r==KErrNone || r==KErrAlreadyExists);
382 r=TheFs.Entry(pritestfile1,entry);
385 r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
388 r=TheFs.Delete(pritestfile1);
394 LOCAL_C void privateSIDRFstest()
401 theprivatepath[0]=(TText)gDriveToTest;
402 test.Printf(_L("the Private Path = %S"),&theprivatepath);
405 mkdirname.Append(theprivatepath);
406 mkdirname.Append(KMkDirSub);
407 r=TheFs.MkDirAll(mkdirname);
410 r=TheFs.RmDir(mkdirname);
413 r=TheFs.SetSubst(theprivatepath,EDriveO);
414 test(r==KErrPermissionDenied);
416 r=TheFs.RealName(_L("O:\\File.XXX"),realName);
419 r=TheFs.SetSessionPath(theprivatepath);
422 TheFs.NotifyChange(ENotifyAll,aStat3,theprivatepath);
423 test(aStat3==KRequestPending);
425 pritestfile=theprivatepath;
426 pritestfile[0]=(TText)('A' + gTheDriveNum);
427 pritestfile1=pritestfile;
428 pritestfile.Append(KFilePri2);
429 pritestfile1.Append(KFilePri3);
432 oldName[0]=(TText)gDriveToTest;
434 r=TheFs.GetShortName(pritestfile, shortfilename);
435 test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
437 r=TheFs.GetLongName(pritestfile1, longfilename);
438 test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
440 r=file1.Create(TheFs,oldName,EFileWrite);
441 test(r==KErrNone || r==KErrAlreadyExists);
444 r=TheFs.Replace(oldName,pritestfile);
447 r=TheFs.Rename(pritestfile,pritestfile1);
448 test(r==KErrNone || r==KErrAlreadyExists);
450 r=TheFs.Entry(pritestfile1,entry);
453 r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
456 r=TheFs.Delete(pritestfile1);
462 LOCAL_C void systemRFiletest()
464 //RFile testing with session path set to //system//
469 r=TheFs.SetSessionPath(systestname);
472 r=file1.Temp(TheFs,systestname,fromTemp,EFileWrite);
473 test(r==KErrPermissionDenied);
476 TBuf<25> sysfilename;
477 sysfilename.Append(systestname);
478 sysfilename.Append(KFileSys);
480 r=file1.Create(TheFs,sysfilename,EFileWrite);
481 test(r==KErrPermissionDenied);
483 r=file1.Open(TheFs,sysfilename,EFileWrite);
484 test(r==KErrPermissionDenied);
487 r=file1.Open(TheFs, KSysBinFile, EFileShareReadersOnly | EFileRead | EFileReadBuffered);
491 r=file1.Open(TheFs, KSysBinFile, EFileStreamText | EFileReadBuffered | EFileReadAheadOn);
495 r=file1.Open(TheFs, KSysBinFile, EFileStreamText | EFileShareReadersOnly);
499 r=file1.Open(TheFs,sysfilename,EFileRead);
500 test(r==KErrNone || r==KErrNotFound);
502 r=file1.Replace(TheFs,sysfilename,EFileWrite);
503 test(r==KErrPermissionDenied);
505 TFindFile finder(TheFs);
507 r=finder.FindWildByDir(KWildFile, KWildPath, dir);
509 test.Printf(_L("T_DCALLFILES: test find wildcards r = %d (expected KErrNone)\n"), r);
510 test(r==KErrNone || r==KErrNotFound);
515 LOCAL_C void resourceRFiletest()
517 //RFile testing with session path set to //resource//
521 r=TheFs.SetSessionPath(restestname);
524 r=file1.Temp(TheFs,restestname,fromTemp,EFileWrite);
525 test(r==KErrPermissionDenied);
528 r=file1.Create(TheFs,KFileRes,EFileWrite);
529 test(r==KErrPermissionDenied);
532 r=file1.Open(TheFs,KFileRes,EFileWrite);
533 test(r==KErrPermissionDenied);
536 r=file1.Open(TheFs,KFileRes,EFileRead|EFileShareReadersOnly);
537 test(r==KErrNone || r==KErrNotFound);
540 r=file1.Open(TheFs,KFileRes,EFileShareReadersOrWriters|EFileRead);
541 test(r==KErrNone || r==KErrNotFound);
544 r=file1.Open(TheFs,KFileRes,EFileShareReadersOrWriters|EFileWrite);
545 test(r==KErrPermissionDenied);
548 r=file1.Open(TheFs,KFileRes,EFileShareReadersOnly);
549 test(r==KErrNone || r==KErrNotFound);
551 r=file1.ChangeMode(EFileShareExclusive); //this is not illegal though will prevent shared access to resource which is nit my fault but may be desirable to prevent
554 //this operation is prevented as you can not open a file for write access in the resource directory
555 r=file1.Rename(KFileRes3);
556 test(r==KErrPermissionDenied);
559 r=file1.Replace(TheFs,KFileRes,EFileWrite);
560 test(r==KErrPermissionDenied);
566 LOCAL_C void privateFalseIDRFiletest()
568 //RFile testing with session path set to //Private//FalseID
572 r=TheFs.SetSessionPath(pritestfalseidname);
575 r=file1.Temp(TheFs,pritestfalseidname,fromTemp,EFileWrite);
579 r=file1.Create(TheFs,KFilePri,EFileWrite);
583 r=file1.Open(TheFs,KFilePri,EFileWrite);
587 r=file1.Open(TheFs,KFilePri,EFileRead);
591 r=file1.Replace(TheFs,KFilePri,EFileWrite);
594 r=file1.Rename(KFilePri3);
595 test(r==KErrNone || r== KErrAlreadyExists);
601 LOCAL_C void privateRFiletest()
603 //RFile testing with session path set to //Private//
607 r=TheFs.SetSessionPath(pritestname);
610 r=file1.Temp(TheFs,pritestname,fromTemp,EFileWrite);
614 r=file1.Create(TheFs,KFilePri,EFileWrite);
618 r=file1.Open(TheFs,KFilePri,EFileWrite);
622 r=file1.Open(TheFs,KFilePri,EFileRead);
626 r=file1.Replace(TheFs,KFilePri,EFileWrite);
629 r=file1.Rename(KFilePri3);
630 test(r==KErrNone || r== KErrAlreadyExists);
635 LOCAL_C void privateSIDRFiletest()
640 //Rfile Testing with session path set to //Private//UID//
642 r=TheFs.SetSessionToPrivate(gTheDriveNum);
645 r=file1.Temp(TheFs,theprivatepath,fromTemp,EFileWrite);
649 r=file1.Create(TheFs,KFilePri,EFileWrite);
653 r=file1.Open(TheFs,KFilePri,EFileWrite);
657 r=file1.Open(TheFs,KFilePri,EFileRead);
661 r=file1.Replace(TheFs,KFilePri,EFileWrite);
664 r=file1.Rename(KFilePri3);
665 test(r==KErrNone || r==KErrAlreadyExists);
671 LOCAL_C void RDirtest()
678 dirNameBuf = KSystemPath;
679 dirNameBuf[0]=(TText)gDriveToTest;
680 r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
681 test(r==KErrNone || r==KErrNotFound);
684 r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
690 dirNameBuf=KPrivateFalseID;
691 dirNameBuf[0]=(TText)gDriveToTest;
692 r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
695 r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
700 dirNameBuf=KPrivatePath;
701 dirNameBuf[0]=(TText)gDriveToTest;
702 r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
705 r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
710 TheFs.PrivatePath(dirNameBuf);
711 dirNameBuf.Insert(0,_L("?:"));
712 dirNameBuf[0]=(TText)gDriveToTest;
713 r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
716 r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
721 dirNameBuf=KResourcePath;
722 dirNameBuf[0]=(TText)gDriveToTest;
723 r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
724 test(r==KErrNone || r==KErrNotFound);
726 r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
736 LOCAL_C void testAllFiles()
738 // Test with only AllFiles Capability
741 r=TheFs.FileSystemName(fsname,gTheDriveNum);
743 r=TheFs.DismountFileSystem(fsname,gTheDriveNum);
744 test(r==KErrPermissionDenied);
745 // r=TheFs.RemoveFileSystem(fsname); //can not test due to bug else where fix exists
746 // test(r==KErrPermissionDenied);
747 // r=TheFs.AddFileSystem(fsname);
748 // test(r==KErrPermissionDenied);
749 r=TheFs.MountFileSystem(fsname,gTheDriveNum);
750 test(r==KErrPermissionDenied);
751 r=TheFs.SetDriveName(gTheDriveNum,KDriveName);
752 test(r==KErrPermissionDenied);
753 // r=TheFs.SetVolumeLabel(KVolLable, gTheDriveNum);
754 // test(r==KErrNone);
760 privatefalseIDRFstest();
765 privateSIDRFiletest();
766 privateFalseIDRFiletest();
768 test(aStat1 == KRequestPending);
769 TheFs.NotifyChangeCancel(aStat1);
770 test(aStat1==KErrCancel);
772 test(aStat4 == KRequestPending);
773 TheFs.NotifyChangeCancel(aStat4);
774 test(aStat4==KErrCancel);
776 User::WaitForRequest(aStat2);
777 User::WaitForRequest(aStat3);
779 test(aStat2==KErrNone);
780 test(aStat3==KErrNone);
783 r=TheFs.SetSessionPath(systestname);
786 //Test RRawDisk class
787 r=rawdisk.Open(TheFs,gTheDriveNum);
788 test(r==KErrPermissionDenied);
790 r=format.Open(TheFs,driveBuf,EHighDensity,count);
791 test(r==KErrPermissionDenied);
795 driveBuf[0]=(TText)gDriveToTest;
796 r=TheFs.ScanDrive(driveBuf);
797 test(r==KErrPermissionDenied);
798 r=TheFs.CheckDisk(driveBuf);
799 test(r==KErrPermissionDenied);
802 LOCAL_C void TestCaps()
804 // test format etc that require certain capabilities
807 #ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
808 const char myDiagMsg[] = "Capability Check Failure";
809 #endif //!__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
810 r=RProcess().HasCapability(ECapabilityAllFiles, __PLATSEC_DIAGNOSTIC_STRING(myDiagMsg));
813 driveBuf[0]=(TText)gDriveToTest;
814 r=TheFs.SessionPath(temp);
817 test.Printf(_L("Session path: %S"),&temp);
819 r=TheFs.CreatePrivatePath(gTheDriveNum);
820 test(r==KErrNone || r== KErrAlreadyExists);
823 r=TheFs.PrivatePath(tempPri);
825 theprivatepath = _L("?:");
826 theprivatepath.Append(tempPri);
830 TFileName thesessionpath;
831 r=TheFs.SetSessionToPrivate(gTheDriveNum);
833 r=TheFs.SessionPath(thesessionpath);
835 test(thesessionpath == theprivatepath);
840 LOCAL_C void ScanDir(const TDesC& aName, CDirScan::TScanDirection aDirection, TInt aError)
842 CDirScan* scanner = NULL;
843 TRAP(r, scanner = CDirScan::NewL(TheFs));
844 test(r == KErrNone && scanner);
846 TRAP(r, scanner->SetScanDataL(aName,KEntryAttDir,ESortByName|EAscending,aDirection));
849 CDir *entryList=NULL;
852 TRAP(r, scanner->NextL(entryList));
856 TInt count=entryList->Count();
859 TEntry data=(*entryList)[count];
860 TBuf<KMaxFileName> path=scanner->AbbreviatedPath();
862 dirName.Append(data.iName);
863 test.Printf(_L(" %S\n"),&dirName);
873 The following test, tests CFileMan and CDirScan API on folders private and sys
874 to confirm that any operation on these folders for any app with incorrect capability
875 returns KErrPermissionDenied. This test step was added as a result of DEF051428
876 ("PlatSec: Incorrect errors returned by f32")
878 LOCAL_C void TestCaging()
880 CFileMan* fMan=CFileMan::NewL(TheFs);
885 // Checking the private path
886 TBuf<30> privatepath;
887 r=TheFs.PrivatePath(privatepath);
888 test.Printf(_L("Private Path is=%S"),&privatepath);
890 r = TheFs.MkDir(_L("\\Caged\\"));
891 test(r==KErrNone || r==KErrAlreadyExists);
893 CDir* entryCount=NULL;
894 r=TheFs.GetDir(_L("\\*.*"),KEntryAttNormal,ESortNone,entryCount);
896 TInt rootCount= entryCount->Count();
903 CDir* entryCount2=NULL;
904 r=fMan->Copy(_L("\\sys\\"),_L("\\Caged\\"));
905 test(r == KErrNotFound);
906 r=fMan->Copy(_L("\\*"),_L("\\Caged\\"));
909 r=TheFs.GetDir(_L("\\Caged\\*.*"),KEntryAttNormal,ESortNone,entryCount2);
911 TInt cagedCount= entryCount2->Count();
913 test(cagedCount==rootCount);
919 r=fMan->Copy(_L("\\private\\two\\moo"),_L("\\private\\two\\mew"));
920 test(r == KErrPathNotFound);
922 // Create a test file
924 r = testFile.Replace(TheFs, _L("\\capTest"),EFileWrite);
925 test(r==KErrNone || r==KErrAlreadyExists);
930 name.Append(_L("privateFile.tst"));
932 r = privateFile.Replace(TheFs, name,EFileWrite);
933 test(r==KErrNone || r==KErrAlreadyExists);
937 r=fMan->Copy(_L("\\capTest"),_L("\\private\\to\\moo"));
938 test(r == KErrPathNotFound);
939 r=fMan->Copy(_L("\\capTest"),_L("\\sys\\bin\\moo"));
940 test(r == KErrPermissionDenied);
941 r=fMan->Copy(_L("\\sys\\bin\\capTest"),_L("\\sys\\bin\\moo"));
942 test(r == KErrPathNotFound);
943 r=fMan->Copy(_L("\\sys\\*"),_L("\\"));
944 test (r==KErrNone || r==KErrNotFound);
945 r=fMan->Copy(name,_L("\\sys\\"));
946 test(r==KErrPermissionDenied);
949 r=fMan->Move(_L("\\capTest"),_L("\\private\\wst\\moo"), CFileMan::ERecurse); // Recurse flag needed as destination path does not exist.
951 r=fMan->Move(_L("\\sys\\bin\\capTest"),_L("\\sys\\bin\\moo"));
952 test(r == KErrPathNotFound);
953 r=fMan->Move(_L("\\sys\\*"),_L("\\"));
954 test (r==KErrNone || r==KErrNotFound);
955 r=fMan->Move(name,_L("\\sys\\"));
956 test(r==KErrPermissionDenied);
957 r=fMan->Move(_L("\\private\\two\\moo"),_L("\\private\\one\\moo"));
958 test(r == KErrPathNotFound);
959 r=fMan->Move(_L("\\private\\two\\moo.."),_L("\\private\\one\\moo"));
960 test(r == KErrPathNotFound);
961 r=fMan->Move(_L("\\private\\two\\moo"),_L("\\private\\one\\moo.."));
962 test(r == KErrPathNotFound);
963 r=fMan->Move(name,_L("\\privateFile.tst"));
965 r=fMan->Move(_L("\\privateFile.tst"),name);
970 r=fMan->Attribs(_L("\\private\\two\\moo"),KEntryAttReadOnly,0,TTime(0));
971 test(r == KErrPathNotFound);
972 r=fMan->Attribs(_L("\\private\\moo"),KEntryAttReadOnly,0,TTime(0));
973 test(r == KErrNotFound);
974 r=fMan->Attribs(name,KEntryAttReadOnly,0,TTime(0));
976 r=fMan->Attribs(name,0,KEntryAttReadOnly,TTime(0));
980 r=fMan->RmDir(_L("\\private\\"));
982 // put it back where it was
983 r = TheFs.MkDirAll(_L("\\private\\00000001\\"));
985 r=fMan->RmDir(_L("\\private\\two\\"));
986 test(r == KErrPathNotFound);
987 r=fMan->RmDir(_L("\\private\\tw?\\"));
988 test(r == KErrBadName);
989 r=fMan->RmDir(_L("\\sys\\"));
990 test(r == KErrPermissionDenied);
993 r=fMan->Rename(_L("\\private\\two\\moo"),_L("\\private\\two\\mew"));
994 test(r == KErrPathNotFound);
997 r=fMan->Delete(_L("\\private\\two\\test"));
998 test(r == KErrPathNotFound);
999 r=fMan->Delete(_L("\\private\\moo"));
1000 test(r == KErrNotFound);
1002 //Something that actually exists in Private
1003 r=fMan->Rename(name,_L("\\private\\00000001\\moo"));
1004 test(r == KErrNotFound); //deleted the file previously
1005 r=fMan->Rename(_L("\\private\\00000001\\moo"),name);
1006 test(r == KErrNotFound);
1007 r=fMan->Copy(name,_L("\\private\\00000001\\moo"));
1008 test(r == KErrNotFound);
1009 r=fMan->Delete(_L("\\private\\00000001\\moo"));
1010 test(r == KErrNotFound);
1012 // Clean up the test data
1013 r=fMan->RmDir(_L("\\Caged\\"));
1014 test(r == KErrNone);
1015 r=fMan->Delete(_L("\\capTest"));
1016 test(r == KErrNone || KErrNotFound);
1021 ScanDir(_L("\\"), CDirScan::EScanUpTree, KErrNone);
1022 ScanDir(_L("\\"), CDirScan::EScanDownTree, KErrNone);
1023 ScanDir(_L("\\private\\"), CDirScan::EScanDownTree, KErrNone);
1024 ScanDir(_L("\\private\\"), CDirScan::EScanUpTree, KErrNone);
1025 ScanDir(_L("\\sys\\"), CDirScan::EScanDownTree, KErrNone);
1026 ScanDir(_L("\\sys\\"), CDirScan::EScanUpTree,KErrNone);
1029 LOCAL_C void CleanupL()
1034 test.Next(_L("Delete test directory"));
1035 CFileMan* fMan=CFileMan::NewL(TheFs);
1036 TInt r=fMan->RmDir(gSessionPath);
1041 GLDEF_C void CallTestsL(/*TChar aDriveLetter*/)
1046 if(!PlatSec::IsCapabilityEnforced(ECapabilityAllFiles))
1048 test.Printf(_L("Capability ECapabilityAllFiles not enabled - leaving t_dcallfiles"));
1049 test.Printf(_L("\n")); // Prevent overwrite by next print
1053 TurnAllocFailureOff();
1054 TheFs.CharToDrive(gDriveToTest,gTheDriveNum);
1057 sesspath=_L("?:\\");
1058 sesspath[0] = (TText)gDriveToTest;
1060 TInt r= TheFs.SetSessionPath(sesspath);
1065 cmd[0] = (TText)gDriveToTest;
1067 r=tp.Create(_L("clean_prepdc.exe"),sesspath);
1074 User::WaitForRequest(ps);
1077 //check double mode ie that Defpath still works
1083 r=fs1.SessionPath(sesspath);
1085 test.Printf(_L("session1 Path=%S"),&sesspath);
1087 TBuf<30> privatepath;
1088 r=fs1.SetSessionToPrivate(gTheDriveNum);
1090 r=fs1.PrivatePath(privatepath);
1092 r=privatepath.Compare(KExpectedPrivatePath());
1094 r=fs1.SessionPath(sesspath);
1096 r=privatepath.Compare(sesspath.Mid(KPathPosition));
1098 r=fs1.CreatePrivatePath(gTheDriveNum);
1104 r=fs2.SessionPath(sesspath);
1106 test.Printf(_L("session2 Path=%S"),&sesspath);
1113 test.Printf(_L("No of files open=%d"), TheFs.ResourceCount());