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