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