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