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