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