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