130 |
128 |
131 oldName=KOldFile; |
129 oldName=KOldFile; |
132 oldName[0]=(TText)gDriveToTest; |
130 oldName[0]=(TText)gDriveToTest; |
133 |
131 |
134 r=TheFs.GetShortName(systestfile, shortfilename); |
132 r=TheFs.GetShortName(systestfile, shortfilename); |
135 test(r==KErrPermissionDenied); |
133 test_Value(r, r == KErrPermissionDenied); |
136 |
134 |
137 r=TheFs.GetLongName(systestfile1, longfilename); |
135 r=TheFs.GetLongName(systestfile1, longfilename); |
138 test(r==KErrPermissionDenied); |
136 test_Value(r, r == KErrPermissionDenied); |
139 |
137 |
140 r=file1.Create(TheFs,oldName,EFileWrite); |
138 r=file1.Create(TheFs,oldName,EFileWrite); |
141 test(r==KErrNone || r==KErrAlreadyExists); |
139 test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
142 file1.Close(); |
140 file1.Close(); |
143 |
141 |
144 r=TheFs.Replace(oldName,systestfile); |
142 r=TheFs.Replace(oldName,systestfile); |
145 test(r==KErrPermissionDenied); |
143 test_Value(r, r == KErrPermissionDenied); |
146 |
144 |
147 r=TheFs.Rename(systestfile,systestfile1); |
145 r=TheFs.Rename(systestfile,systestfile1); |
148 test(r==KErrPermissionDenied); |
146 test_Value(r, r == KErrPermissionDenied); |
149 |
147 |
150 r=TheFs.Entry(systestfile1,entry); |
148 r=TheFs.Entry(systestfile1,entry); |
151 test(r==KErrPermissionDenied); |
149 test_Value(r, r == KErrPermissionDenied); |
152 |
150 |
153 r=TheFs.SetEntry(systestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly); |
151 r=TheFs.SetEntry(systestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly); |
154 test(r==KErrPermissionDenied); |
152 test_Value(r, r == KErrPermissionDenied); |
155 |
153 |
156 r=TheFs.Delete(systestfile1); |
154 r=TheFs.Delete(systestfile1); |
157 test(r==KErrPermissionDenied); |
155 test_Value(r, r == KErrPermissionDenied); |
158 |
156 |
159 |
157 |
160 // DEF141257: Security Issue in File Server |
158 // DEF141257: Security Issue in File Server |
161 // Test that we can't access the system drive by preceding it with a dot character |
159 // Test that we can't access the system drive by preceding it with a dot character |
162 _LIT(KSystemPathDot, "?:\\.Sys\\"); |
160 _LIT(KSystemPathDot, "?:\\.Sys\\"); |
166 SysTestFileDot=KSystemPathDot; |
164 SysTestFileDot=KSystemPathDot; |
167 SysTestFileDot[0]=(TText)('A' + gTheDriveNum); |
165 SysTestFileDot[0]=(TText)('A' + gTheDriveNum); |
168 SysTestFileDot.Append(KFileSys); |
166 SysTestFileDot.Append(KFileSys); |
169 RFile file; |
167 RFile file; |
170 r = file.Replace(TheFs, SysTestFileDot, EFileWrite); |
168 r = file.Replace(TheFs, SysTestFileDot, EFileWrite); |
171 test(r==KErrPathNotFound); |
169 test_Value(r, r == KErrPathNotFound); |
172 |
170 |
173 // try creating a subst drive for "\.SYS"... |
171 // try creating a subst drive for "\.SYS"... |
174 TBuf<40> SysTestNameDot; |
172 TBuf<40> SysTestNameDot; |
175 SysTestNameDot=KSystemPathDot; |
173 SysTestNameDot=KSystemPathDot; |
176 SysTestNameDot[0]=(TText)('A' + gTheDriveNum); |
174 SysTestNameDot[0]=(TText)('A' + gTheDriveNum); |
177 r=TheFs.SetSubst(SysTestNameDot,EDriveA); |
175 r=TheFs.SetSubst(SysTestNameDot,EDriveA); |
178 test(r==KErrNone); |
176 test_KErrNone(r); |
179 |
177 |
180 // try creating a file using substituted drive... |
178 // try creating a file using substituted drive... |
181 TBuf<40> SubstTestFile = _L("A:\\"); |
179 TBuf<40> SubstTestFile = _L("A:\\"); |
182 SubstTestFile.Append(KFileSys); |
180 SubstTestFile.Append(KFileSys); |
183 |
181 |
184 r = file.Replace(TheFs, SubstTestFile, EFileWrite); |
182 r = file.Replace(TheFs, SubstTestFile, EFileWrite); |
185 test(r==KErrPathNotFound); |
183 test_Value(r, r == KErrPathNotFound); |
186 |
184 |
187 r = TheFs.SetSubst(_L(""),EDriveA); |
185 r = TheFs.SetSubst(_L(""),EDriveA); |
188 test(r==KErrNone); |
186 test_KErrNone(r); |
189 |
187 |
190 |
188 |
191 |
189 |
192 // try listing files in "\.SYS" |
190 // try listing files in "\.SYS" |
193 _LIT(KWildPathDot, "Z:\\.SYS\\"); |
191 _LIT(KWildPathDot, "Z:\\.SYS\\"); |
194 TFindFile finder(TheFs); |
192 TFindFile finder(TheFs); |
195 CDir* dir = NULL; |
193 CDir* dir = NULL; |
196 r=finder.FindWildByDir(KWildFile, KWildPathDot, dir); |
194 r=finder.FindWildByDir(KWildFile, KWildPathDot, dir); |
197 test(r==KErrNotFound); |
195 test_Value(r, r == KErrNotFound); |
198 delete dir; |
196 delete dir; |
199 |
197 |
200 // Deliberately create a directory called "\.SYS" |
198 // Deliberately create a directory called "\.SYS" |
201 // and verify shortname is NOT the same as "SYS" |
199 // and verify shortname is NOT the same as "SYS" |
202 mkdirname.Zero(); |
200 mkdirname.Zero(); |
203 mkdirname.Append(KSystemPathDot); |
201 mkdirname.Append(KSystemPathDot); |
204 mkdirname[0]=(TText)('A' + gTheDriveNum); |
202 mkdirname[0]=(TText)('A' + gTheDriveNum); |
205 r=TheFs.MkDirAll(mkdirname); |
203 r=TheFs.MkDirAll(mkdirname); |
206 test(r==KErrNone); |
204 test_KErrNone(r); |
207 |
205 |
208 r=TheFs.GetShortName(mkdirname, shortfilename); |
206 r=TheFs.GetShortName(mkdirname, shortfilename); |
209 test(r==KErrNone || r==KErrNotSupported); // short names not supported on LFFS |
207 test_Value(r, r == KErrNone || r==KErrNotSupported); // short names not supported on LFFS |
210 // r = shortfilename.Compare(_L("SYS~1")); |
208 // r = shortfilename.Compare(_L("SYS~1")); |
211 // test(r==KErrNone); |
209 // test_KErrNone(r); |
212 r = shortfilename.Compare(_L("SYS")); |
210 r = shortfilename.Compare(_L("SYS")); |
213 test (r != 0); |
211 test (r != 0); |
214 |
212 |
215 r = TheFs.RmDir(mkdirname); |
213 r = TheFs.RmDir(mkdirname); |
216 test(r==KErrNone); |
214 test_KErrNone(r); |
217 |
215 |
218 // Deliberately create a directory called "\..SYS" |
216 // Deliberately create a directory called "\..SYS" |
219 // and verify shortname is NOT the same as "SYS" |
217 // and verify shortname is NOT the same as "SYS" |
220 _LIT(KSystemPathDotDot, "?:\\..Sys\\"); |
218 _LIT(KSystemPathDotDot, "?:\\..Sys\\"); |
221 mkdirname.Zero(); |
219 mkdirname.Zero(); |
222 mkdirname.Append(KSystemPathDotDot); |
220 mkdirname.Append(KSystemPathDotDot); |
223 mkdirname[0]=(TText)('A' + gTheDriveNum); |
221 mkdirname[0]=(TText)('A' + gTheDriveNum); |
224 r=TheFs.MkDirAll(mkdirname); |
222 r=TheFs.MkDirAll(mkdirname); |
225 test(r==KErrNone); |
223 test_KErrNone(r); |
226 |
224 |
227 r=TheFs.GetShortName(mkdirname, shortfilename); |
225 r=TheFs.GetShortName(mkdirname, shortfilename); |
228 test(r==KErrNone || r==KErrNotSupported); // short names not supported on LFFS |
226 test_Value(r, r == KErrNone || r==KErrNotSupported); // short names not supported on LFFS |
229 // r = shortfilename.Compare(_L("_.SYS")); |
227 // r = shortfilename.Compare(_L("_.SYS")); |
230 // test(r==KErrNone); |
228 // test_KErrNone(r); |
231 r = shortfilename.Compare(_L("SYS")); |
229 r = shortfilename.Compare(_L("SYS")); |
232 test (r != 0); |
230 test (r != 0); |
233 |
231 |
234 r = TheFs.RmDir(mkdirname); |
232 r = TheFs.RmDir(mkdirname); |
235 test(r==KErrNone); |
233 test_KErrNone(r); |
236 } |
234 } |
237 |
235 |
238 |
236 |
239 LOCAL_C void resourceRFstest() |
237 LOCAL_C void resourceRFstest() |
240 // |
238 // |
247 |
245 |
248 mkdirname.Zero(); |
246 mkdirname.Zero(); |
249 mkdirname.Append(restestname); |
247 mkdirname.Append(restestname); |
250 mkdirname.Append(KMkDirSub); |
248 mkdirname.Append(KMkDirSub); |
251 r=TheFs.MkDirAll(mkdirname); |
249 r=TheFs.MkDirAll(mkdirname); |
252 test(r==KErrPermissionDenied); |
250 test_Value(r, r == KErrPermissionDenied); |
253 |
251 |
254 TheFs.RmDir(mkdirname); |
252 TheFs.RmDir(mkdirname); |
255 test(r==KErrPermissionDenied); |
253 test_Value(r, r == KErrPermissionDenied); |
256 |
254 |
257 // Change due to defect DEF099546 fix |
255 // Change due to defect DEF099546 fix |
258 // TCB capability is required for following operation. |
256 // TCB capability is required for following operation. |
259 r=TheFs.SetSubst(restestname,EDriveS); |
257 r=TheFs.SetSubst(restestname,EDriveS); |
260 //test(r==KErrNone); |
258 //test_KErrNone(r); |
261 test(r==KErrPermissionDenied); |
259 test_Value(r, r == KErrPermissionDenied); |
262 |
260 |
263 // SetSubst will fail. |
261 // SetSubst will fail. |
264 //r=TheFs.RealName(_L("S:\\File.XXX"),realName); |
262 //r=TheFs.RealName(_L("S:\\File.XXX"),realName); |
265 //test(r==KErrNone); |
263 //test_KErrNone(r); |
266 |
264 |
267 //r=TheFs.SetSubst(_L(""),EDriveS); |
265 //r=TheFs.SetSubst(_L(""),EDriveS); |
268 //test(r==KErrNone); |
266 //test_KErrNone(r); |
269 |
267 |
270 r=TheFs.SetSessionPath(restestname); |
268 r=TheFs.SetSessionPath(restestname); |
271 test(r==KErrNone); |
269 test_KErrNone(r); |
272 |
270 |
273 TheFs.NotifyChange(ENotifyAll,aStat4,restestname); |
271 TheFs.NotifyChange(ENotifyAll,aStat4,restestname); |
274 test(aStat4==KRequestPending); |
272 test(aStat4==KRequestPending); |
275 |
273 |
276 |
274 |
282 |
280 |
283 oldName=KOldFile; |
281 oldName=KOldFile; |
284 oldName[0]=(TText)gDriveToTest; |
282 oldName[0]=(TText)gDriveToTest; |
285 |
283 |
286 r=TheFs.GetShortName(restestfile, shortfilename); |
284 r=TheFs.GetShortName(restestfile, shortfilename); |
287 test(r==KErrNone || KErrPathNotFound); |
285 test(r == KErrNone || KErrPathNotFound); |
|
286 // test_Value(r, r == KErrNone || r == KErrPathNotFound); |
288 |
287 |
289 r=TheFs.GetLongName(restestfile1, longfilename); |
288 r=TheFs.GetLongName(restestfile1, longfilename); |
290 test(r==KErrNone || KErrPathNotFound); |
289 test(r == KErrNone || KErrPathNotFound); |
|
290 // test_Value(r, r == KErrNone || r == KErrPathNotFound); |
291 |
291 |
292 r=file1.Create(TheFs,oldName,EFileWrite); |
292 r=file1.Create(TheFs,oldName,EFileWrite); |
293 test(r==KErrNone || r==KErrAlreadyExists); |
293 test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
294 file1.Close(); |
294 file1.Close(); |
295 |
295 |
296 r=TheFs.Replace(oldName,restestfile); |
296 r=TheFs.Replace(oldName,restestfile); |
297 test(r==KErrPermissionDenied); |
297 test_Value(r, r == KErrPermissionDenied); |
298 |
298 |
299 r=TheFs.Rename(restestfile,restestfile1); |
299 r=TheFs.Rename(restestfile,restestfile1); |
300 test(r==KErrPermissionDenied); |
300 test_Value(r, r == KErrPermissionDenied); |
301 |
301 |
302 r=TheFs.Entry(restestfile1,entry); |
302 r=TheFs.Entry(restestfile1,entry); |
303 test(r==KErrNone || KErrPathNotFound); |
303 test(r == KErrNone || KErrPathNotFound); |
|
304 // test_Value(r, r == KErrNone || r == KErrPathNotFound); |
304 |
305 |
305 r=TheFs.SetEntry(restestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly); |
306 r=TheFs.SetEntry(restestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly); |
306 test(r==KErrPermissionDenied); |
307 test_Value(r, r == KErrPermissionDenied); |
307 |
308 |
308 r=TheFs.Delete(restestfile1); |
309 r=TheFs.Delete(restestfile1); |
309 test(r==KErrPermissionDenied); |
310 test_Value(r, r == KErrPermissionDenied); |
310 } |
311 } |
311 |
312 |
312 |
313 |
313 LOCAL_C void privateFalseIDRFstest() |
314 LOCAL_C void privateFalseIDRFstest() |
314 // |
315 // |
345 |
346 |
346 oldName=KOldFile; |
347 oldName=KOldFile; |
347 oldName[0]=(TText)gDriveToTest; |
348 oldName[0]=(TText)gDriveToTest; |
348 |
349 |
349 r=TheFs.GetShortName(pritestfile, shortfilename); |
350 r=TheFs.GetShortName(pritestfile, shortfilename); |
350 test(r==KErrPermissionDenied); |
351 test_Value(r, r == KErrPermissionDenied); |
351 |
352 |
352 r=TheFs.GetLongName(pritestfile1, longfilename); |
353 r=TheFs.GetLongName(pritestfile1, longfilename); |
353 test(r==KErrPermissionDenied); |
354 test_Value(r, r == KErrPermissionDenied); |
354 |
355 |
355 r=file1.Create(TheFs,oldName,EFileWrite); |
356 r=file1.Create(TheFs,oldName,EFileWrite); |
356 test(r==KErrNone || r==KErrAlreadyExists); |
357 test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
357 file1.Close(); |
358 file1.Close(); |
358 |
359 |
359 r=TheFs.Replace(oldName,pritestfile); |
360 r=TheFs.Replace(oldName,pritestfile); |
360 test(r==KErrPermissionDenied); |
361 test_Value(r, r == KErrPermissionDenied); |
361 |
362 |
362 r=TheFs.Rename(pritestfile,pritestfile1); |
363 r=TheFs.Rename(pritestfile,pritestfile1); |
363 test(r==KErrPermissionDenied); |
364 test_Value(r, r == KErrPermissionDenied); |
364 |
365 |
365 r=TheFs.Entry(pritestfile1,entry); |
366 r=TheFs.Entry(pritestfile1,entry); |
366 test(r==KErrPermissionDenied); |
367 test_Value(r, r == KErrPermissionDenied); |
367 |
368 |
368 r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly); |
369 r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly); |
369 test(r==KErrPermissionDenied); |
370 test_Value(r, r == KErrPermissionDenied); |
370 |
371 |
371 r=TheFs.Delete(pritestfile1); |
372 r=TheFs.Delete(pritestfile1); |
372 test(r==KErrPermissionDenied); |
373 test_Value(r, r == KErrPermissionDenied); |
373 |
374 |
374 } |
375 } |
375 |
376 |
376 |
377 |
377 |
378 |
411 |
412 |
412 oldName=KOldFile; |
413 oldName=KOldFile; |
413 oldName[0]=(TText)gDriveToTest; |
414 oldName[0]=(TText)gDriveToTest; |
414 |
415 |
415 r=TheFs.GetShortName(pritestfile, shortfilename); |
416 r=TheFs.GetShortName(pritestfile, shortfilename); |
416 test(r==KErrPermissionDenied); |
417 test_Value(r, r == KErrPermissionDenied); |
417 |
418 |
418 r=TheFs.GetLongName(pritestfile1, longfilename); |
419 r=TheFs.GetLongName(pritestfile1, longfilename); |
419 test(r==KErrPermissionDenied); |
420 test_Value(r, r == KErrPermissionDenied); |
420 |
421 |
421 r=file1.Create(TheFs,oldName,EFileWrite); |
422 r=file1.Create(TheFs,oldName,EFileWrite); |
422 test(r==KErrNone || r==KErrAlreadyExists); |
423 test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
423 file1.Close(); |
424 file1.Close(); |
424 |
425 |
425 r=TheFs.Replace(oldName,pritestfile); |
426 r=TheFs.Replace(oldName,pritestfile); |
426 test(r==KErrPermissionDenied); |
427 test_Value(r, r == KErrPermissionDenied); |
427 |
428 |
428 r=TheFs.Rename(pritestfile,pritestfile1); |
429 r=TheFs.Rename(pritestfile,pritestfile1); |
429 test(r==KErrPermissionDenied); |
430 test_Value(r, r == KErrPermissionDenied); |
430 |
431 |
431 r=TheFs.Entry(pritestfile1,entry); |
432 r=TheFs.Entry(pritestfile1,entry); |
432 test(r==KErrPermissionDenied); |
433 test_Value(r, r == KErrPermissionDenied); |
433 |
434 |
434 r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly); |
435 r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly); |
435 test(r==KErrPermissionDenied); |
436 test_Value(r, r == KErrPermissionDenied); |
436 |
437 |
437 r=TheFs.Delete(pritestfile1); |
438 r=TheFs.Delete(pritestfile1); |
438 test(r==KErrPermissionDenied); |
439 test_Value(r, r == KErrPermissionDenied); |
439 |
440 |
440 } |
441 } |
441 |
442 |
442 |
443 |
443 LOCAL_C void privateSIDRFstest() |
444 LOCAL_C void privateSIDRFstest() |
481 |
482 |
482 oldName=KOldFile; |
483 oldName=KOldFile; |
483 oldName[0]=(TText)gDriveToTest; |
484 oldName[0]=(TText)gDriveToTest; |
484 |
485 |
485 r=TheFs.GetShortName(pritestfile, shortfilename); |
486 r=TheFs.GetShortName(pritestfile, shortfilename); |
486 test(r==KErrNone || KErrPathNotFound); |
487 test(r == KErrNone || KErrPathNotFound); |
|
488 // test_Value(r, r == KErrNone || r == KErrPathNotFound); |
487 |
489 |
488 r=TheFs.GetLongName(pritestfile1, longfilename); |
490 r=TheFs.GetLongName(pritestfile1, longfilename); |
489 test(r==KErrNone || KErrPathNotFound); |
491 test(r == KErrNone || KErrPathNotFound); |
|
492 // test_Value(r, r == KErrNone || r == KErrPathNotFound); |
490 |
493 |
491 r=file1.Create(TheFs,oldName,EFileWrite); |
494 r=file1.Create(TheFs,oldName,EFileWrite); |
492 test(r==KErrNone || r==KErrAlreadyExists); |
495 test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
493 file1.Close(); |
496 file1.Close(); |
494 |
497 |
495 r=TheFs.Replace(oldName,pritestfile); |
498 r=TheFs.Replace(oldName,pritestfile); |
496 test(r==KErrNone); |
499 test_KErrNone(r); |
497 |
500 |
498 r=TheFs.Rename(pritestfile,pritestfile1); |
501 r=TheFs.Rename(pritestfile,pritestfile1); |
499 test(r==KErrNone || r==KErrAlreadyExists); |
502 test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
500 |
503 |
501 r=TheFs.Entry(pritestfile1,entry); |
504 r=TheFs.Entry(pritestfile1,entry); |
502 test(r==KErrNone); |
505 test_KErrNone(r); |
503 |
506 |
504 r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly); |
507 r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly); |
505 test(r==KErrNone); |
508 test_KErrNone(r); |
506 |
509 |
507 r=TheFs.Delete(pritestfile1); |
510 r=TheFs.Delete(pritestfile1); |
508 test(r==KErrNone); |
511 test_KErrNone(r); |
509 } |
512 } |
510 |
513 |
511 LOCAL_C void systemRFiletest() |
514 LOCAL_C void systemRFiletest() |
512 // |
515 // |
513 // |
516 // |
514 // |
517 // |
515 { |
518 { |
516 //RFile testing with session path set to //system// |
519 //RFile testing with session path set to //system// |
517 |
520 |
518 r=TheFs.SetSessionPath(systestname); |
521 r=TheFs.SetSessionPath(systestname); |
519 test(r==KErrPermissionDenied); |
522 test_Value(r, r == KErrPermissionDenied); |
520 |
523 |
521 r=file1.Temp(TheFs,systestname,fromTemp,EFileWrite); |
524 r=file1.Temp(TheFs,systestname,fromTemp,EFileWrite); |
522 test(r==KErrPermissionDenied); |
525 test_Value(r, r == KErrPermissionDenied); |
523 |
526 |
524 TBuf<25> sysfilename; |
527 TBuf<25> sysfilename; |
525 sysfilename.Append(systestname); |
528 sysfilename.Append(systestname); |
526 sysfilename.Append(KFileSys); |
529 sysfilename.Append(KFileSys); |
527 r=file1.Create(TheFs,sysfilename,EFileWrite); |
530 r=file1.Create(TheFs,sysfilename,EFileWrite); |
528 test(r==KErrPermissionDenied); |
531 test_Value(r, r == KErrPermissionDenied); |
529 |
532 |
530 r=file1.Open(TheFs,sysfilename,EFileWrite); |
533 r=file1.Open(TheFs,sysfilename,EFileWrite); |
531 test(r==KErrPermissionDenied); |
534 test_Value(r, r == KErrPermissionDenied); |
532 |
535 |
533 r=file1.Open(TheFs,sysfilename,EFileRead); |
536 r=file1.Open(TheFs,sysfilename,EFileRead); |
534 test(r==KErrPermissionDenied); |
537 test_Value(r, r == KErrPermissionDenied); |
535 |
538 |
536 r=file1.Replace(TheFs,sysfilename,EFileWrite); |
539 r=file1.Replace(TheFs,sysfilename,EFileWrite); |
537 test(r==KErrPermissionDenied); |
540 test_Value(r, r == KErrPermissionDenied); |
538 |
541 |
539 TFindFile finder(TheFs); |
542 TFindFile finder(TheFs); |
540 CDir* dir = NULL; |
543 CDir* dir = NULL; |
541 r=finder.FindWildByDir(KWildFile, KWildPath, dir); |
544 r=finder.FindWildByDir(KWildFile, KWildPath, dir); |
542 if (!(r==KErrPermissionDenied)) |
545 if (!(r==KErrPermissionDenied)) |
543 test.Printf(_L("T_DCDISKADMIN: test find wildcards r = %d (expected KErrPermissionDenied)\n"), r); |
546 test.Printf(_L("T_DCDISKADMIN: test find wildcards r = %d (expected KErrPermissionDenied)\n"), r); |
544 test(r==KErrPermissionDenied); |
547 test_Value(r, r == KErrPermissionDenied); |
545 delete dir; |
548 delete dir; |
546 } |
549 } |
547 |
550 |
548 LOCAL_C void resourceRFiletest() |
551 LOCAL_C void resourceRFiletest() |
549 // |
552 // |
550 // |
553 // |
551 // |
554 // |
552 { |
555 { |
553 //RFile testing with session path set to //resource// |
556 //RFile testing with session path set to //resource// |
554 r=TheFs.SetSessionPath(restestname); |
557 r=TheFs.SetSessionPath(restestname); |
555 test(r==KErrNone); |
558 test_KErrNone(r); |
556 |
559 |
557 r=file1.Temp(TheFs,restestname,fromTemp,EFileWrite); |
560 r=file1.Temp(TheFs,restestname,fromTemp,EFileWrite); |
558 test(r==KErrPermissionDenied); |
561 test_Value(r, r == KErrPermissionDenied); |
559 file1.Close(); |
562 file1.Close(); |
560 |
563 |
561 r=file1.Create(TheFs,KFileRes,EFileWrite); |
564 r=file1.Create(TheFs,KFileRes,EFileWrite); |
562 test(r==KErrPermissionDenied); |
565 test_Value(r, r == KErrPermissionDenied); |
563 file1.Close(); |
566 file1.Close(); |
564 |
567 |
565 r=file1.Open(TheFs,KFileRes,EFileWrite); |
568 r=file1.Open(TheFs,KFileRes,EFileWrite); |
566 test(r==KErrPermissionDenied); |
569 test_Value(r, r == KErrPermissionDenied); |
567 file1.Close(); |
570 file1.Close(); |
568 |
571 |
569 r=file1.Open(TheFs,KFileRes,EFileRead|EFileShareReadersOnly); |
572 r=file1.Open(TheFs,KFileRes,EFileRead|EFileShareReadersOnly); |
570 test(r==KErrNone || r==KErrPathNotFound); |
573 test_Value(r, r == KErrNone || r==KErrPathNotFound); |
571 file1.Close(); |
574 file1.Close(); |
572 |
575 |
573 r=file1.Open(TheFs,KFileRes,EFileShareReadersOrWriters|EFileRead); |
576 r=file1.Open(TheFs,KFileRes,EFileShareReadersOrWriters|EFileRead); |
574 test(r==KErrNone || r==KErrPathNotFound); |
577 test_Value(r, r == KErrNone || r==KErrPathNotFound); |
575 file1.Close(); |
578 file1.Close(); |
576 |
579 |
577 r=file1.Open(TheFs,KFileRes,EFileShareReadersOrWriters|EFileWrite); |
580 r=file1.Open(TheFs,KFileRes,EFileShareReadersOrWriters|EFileWrite); |
578 test(r==KErrPermissionDenied); |
581 test_Value(r, r == KErrPermissionDenied); |
579 file1.Close(); |
582 file1.Close(); |
580 |
583 |
581 r=file1.Open(TheFs,KFileRes,EFileShareReadersOnly); |
584 r=file1.Open(TheFs,KFileRes,EFileShareReadersOnly); |
582 test(r==KErrNone); |
585 test_KErrNone(r); |
583 |
586 |
584 r=file1.ChangeMode(EFileShareExclusive); |
587 r=file1.ChangeMode(EFileShareExclusive); |
585 test(r==KErrNone); |
588 test_KErrNone(r); |
586 |
589 |
587 //this operation is prevented as you can not open a file for write access in the resource directory |
590 //this operation is prevented as you can not open a file for write access in the resource directory |
588 r=file1.Rename(KFileRes3); |
591 r=file1.Rename(KFileRes3); |
589 test(r==KErrPermissionDenied || r==KErrAccessDenied); |
592 test_Value(r, r == KErrPermissionDenied || r==KErrAccessDenied); |
590 file1.Close(); |
593 file1.Close(); |
591 |
594 |
592 r=file1.Replace(TheFs,KFileRes,EFileWrite); |
595 r=file1.Replace(TheFs,KFileRes,EFileWrite); |
593 test(r==KErrPermissionDenied); |
596 test_Value(r, r == KErrPermissionDenied); |
594 file1.Close(); |
597 file1.Close(); |
595 |
598 |
596 } |
599 } |
597 |
600 |
598 |
601 |
600 // |
603 // |
601 //RFile testing with session path set to //Private//falseID |
604 //RFile testing with session path set to //Private//falseID |
602 // |
605 // |
603 { |
606 { |
604 r=TheFs.SetSessionPath(pritestfalseidname); |
607 r=TheFs.SetSessionPath(pritestfalseidname); |
605 test(r==KErrPermissionDenied); |
608 test_Value(r, r == KErrPermissionDenied); |
606 |
609 |
607 r=file1.Temp(TheFs,pritestfalseidname,fromTemp,EFileWrite); |
610 r=file1.Temp(TheFs,pritestfalseidname,fromTemp,EFileWrite); |
608 test(r==KErrPermissionDenied); |
611 test_Value(r, r == KErrPermissionDenied); |
609 |
612 |
610 TBuf<25> prifilename; |
613 TBuf<25> prifilename; |
611 prifilename.Append(pritestname); |
614 prifilename.Append(pritestname); |
612 prifilename.Append(KFileSys); |
615 prifilename.Append(KFileSys); |
613 |
616 |
614 r=file1.Create(TheFs,prifilename,EFileWrite); |
617 r=file1.Create(TheFs,prifilename,EFileWrite); |
615 test(r==KErrPermissionDenied); |
618 test_Value(r, r == KErrPermissionDenied); |
616 |
619 |
617 r=file1.Open(TheFs,prifilename,EFileWrite); |
620 r=file1.Open(TheFs,prifilename,EFileWrite); |
618 test(r==KErrPermissionDenied); |
621 test_Value(r, r == KErrPermissionDenied); |
619 |
622 |
620 r=file1.Open(TheFs,prifilename,EFileRead); |
623 r=file1.Open(TheFs,prifilename,EFileRead); |
621 test(r==KErrPermissionDenied); |
624 test_Value(r, r == KErrPermissionDenied); |
622 |
625 |
623 r=file1.Replace(TheFs,prifilename,EFileWrite); |
626 r=file1.Replace(TheFs,prifilename,EFileWrite); |
624 test(r==KErrPermissionDenied); |
627 test_Value(r, r == KErrPermissionDenied); |
625 } |
628 } |
626 |
629 |
627 |
630 |
628 LOCAL_C void privateRFiletest() |
631 LOCAL_C void privateRFiletest() |
629 // |
632 // |
630 //RFile testing with session path set to //Private// |
633 //RFile testing with session path set to //Private// |
631 // |
634 // |
632 { |
635 { |
633 r=TheFs.SetSessionPath(pritestname); |
636 r=TheFs.SetSessionPath(pritestname); |
634 test(r==KErrPermissionDenied); |
637 test_Value(r, r == KErrPermissionDenied); |
635 |
638 |
636 r=file1.Temp(TheFs,pritestname,fromTemp,EFileWrite); |
639 r=file1.Temp(TheFs,pritestname,fromTemp,EFileWrite); |
637 test(r==KErrPermissionDenied); |
640 test_Value(r, r == KErrPermissionDenied); |
638 |
641 |
639 TBuf<25> prifilename; |
642 TBuf<25> prifilename; |
640 prifilename.Append(pritestname); |
643 prifilename.Append(pritestname); |
641 prifilename.Append(KFileSys); |
644 prifilename.Append(KFileSys); |
642 |
645 |
643 r=file1.Create(TheFs,prifilename,EFileWrite); |
646 r=file1.Create(TheFs,prifilename,EFileWrite); |
644 test(r==KErrPermissionDenied); |
647 test_Value(r, r == KErrPermissionDenied); |
645 |
648 |
646 r=file1.Open(TheFs,prifilename,EFileWrite); |
649 r=file1.Open(TheFs,prifilename,EFileWrite); |
647 test(r==KErrPermissionDenied); |
650 test_Value(r, r == KErrPermissionDenied); |
648 |
651 |
649 r=file1.Open(TheFs,prifilename,EFileRead); |
652 r=file1.Open(TheFs,prifilename,EFileRead); |
650 test(r==KErrPermissionDenied); |
653 test_Value(r, r == KErrPermissionDenied); |
651 |
654 |
652 r=file1.Replace(TheFs,prifilename,EFileWrite); |
655 r=file1.Replace(TheFs,prifilename,EFileWrite); |
653 test(r==KErrPermissionDenied); |
656 test_Value(r, r == KErrPermissionDenied); |
654 } |
657 } |
655 |
658 |
656 |
659 |
657 LOCAL_C void privateSIDRFiletest() |
660 LOCAL_C void privateSIDRFiletest() |
658 // |
661 // |
659 //Rfile Testing with session path set to //Private//UID// |
662 //Rfile Testing with session path set to //Private//UID// |
660 // |
663 // |
661 { |
664 { |
662 r=TheFs.SetSessionToPrivate(gTheDriveNum); |
665 r=TheFs.SetSessionToPrivate(gTheDriveNum); |
663 test(r==KErrNone); |
666 test_KErrNone(r); |
664 |
667 |
665 r=file1.Temp(TheFs,theprivatepath,fromTemp,EFileWrite); |
668 r=file1.Temp(TheFs,theprivatepath,fromTemp,EFileWrite); |
666 test(r==KErrNone); |
669 test_KErrNone(r); |
667 file1.Close(); |
670 file1.Close(); |
668 |
671 |
669 r=file1.Create(TheFs,KFilePri,EFileWrite); |
672 r=file1.Create(TheFs,KFilePri,EFileWrite); |
670 test(r==KErrNone || r==KErrAlreadyExists); |
673 test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
671 file1.Close(); |
674 file1.Close(); |
672 |
675 |
673 r=file1.Open(TheFs,KFilePri,EFileWrite); |
676 r=file1.Open(TheFs,KFilePri,EFileWrite); |
674 test(r==KErrNone); |
677 test_KErrNone(r); |
675 file1.Close(); |
678 file1.Close(); |
676 |
679 |
677 r=file1.Open(TheFs,KFilePri,EFileRead); |
680 r=file1.Open(TheFs,KFilePri,EFileRead); |
678 test(r==KErrNone); |
681 test_KErrNone(r); |
679 file1.Close(); |
682 file1.Close(); |
680 |
683 |
681 r=file1.Replace(TheFs,KFilePri,EFileWrite); |
684 r=file1.Replace(TheFs,KFilePri,EFileWrite); |
682 test(r==KErrNone); |
685 test_KErrNone(r); |
683 |
686 |
684 r=file1.Rename(KFilePri3); |
687 r=file1.Rename(KFilePri3); |
685 test(r==KErrNone || r==KErrAlreadyExists); |
688 test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
686 file1.Close(); |
689 file1.Close(); |
687 } |
690 } |
688 |
691 |
689 |
692 |
690 LOCAL_C void RDirtest() |
693 LOCAL_C void RDirtest() |
695 //system |
698 //system |
696 dirNameBuf.Zero(); |
699 dirNameBuf.Zero(); |
697 dirNameBuf = KSystemPath; |
700 dirNameBuf = KSystemPath; |
698 dirNameBuf[0]=(TText)gDriveToTest; |
701 dirNameBuf[0]=(TText)gDriveToTest; |
699 r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal); |
702 r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal); |
700 test(r==KErrPermissionDenied); |
703 test_Value(r, r == KErrPermissionDenied); |
701 dir.Close(); |
704 dir.Close(); |
702 r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries); |
705 r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries); |
703 test(r==KErrPermissionDenied); |
706 test_Value(r, r == KErrPermissionDenied); |
704 dirNameBuf.Zero(); |
707 dirNameBuf.Zero(); |
705 delete dirEntries; |
708 delete dirEntries; |
706 //Private//falseid |
709 //Private//falseid |
707 dirNameBuf=KPrivateFalseID; |
710 dirNameBuf=KPrivateFalseID; |
708 dirNameBuf[0]=(TText)gDriveToTest; |
711 dirNameBuf[0]=(TText)gDriveToTest; |
709 r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal); |
712 r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal); |
710 test(r==KErrPermissionDenied); |
713 test_Value(r, r == KErrPermissionDenied); |
711 dir.Close(); |
714 dir.Close(); |
712 r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries); |
715 r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries); |
713 test(r==KErrPermissionDenied); |
716 test_Value(r, r == KErrPermissionDenied); |
714 dirNameBuf.Zero(); |
717 dirNameBuf.Zero(); |
715 delete dirEntries; |
718 delete dirEntries; |
716 //Private |
719 //Private |
717 dirNameBuf=KPrivatePath; |
720 dirNameBuf=KPrivatePath; |
718 dirNameBuf[0]=(TText)gDriveToTest; |
721 dirNameBuf[0]=(TText)gDriveToTest; |
719 r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal); |
722 r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal); |
720 test(r==KErrPermissionDenied); |
723 test_Value(r, r == KErrPermissionDenied); |
721 dir.Close(); |
724 dir.Close(); |
722 r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries); |
725 r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries); |
723 test(r==KErrPermissionDenied); |
726 test_Value(r, r == KErrPermissionDenied); |
724 dirNameBuf.Zero(); |
727 dirNameBuf.Zero(); |
725 delete dirEntries; |
728 delete dirEntries; |
726 //Private/uid |
729 //Private/uid |
727 TheFs.PrivatePath(dirNameBuf); |
730 TheFs.PrivatePath(dirNameBuf); |
728 dirNameBuf.Insert(0,_L("?:")); |
731 dirNameBuf.Insert(0,_L("?:")); |
729 dirNameBuf[0]=(TText)gDriveToTest; |
732 dirNameBuf[0]=(TText)gDriveToTest; |
730 r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal); |
733 r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal); |
731 test(r==KErrNone); |
734 test_KErrNone(r); |
732 dir.Close(); |
735 dir.Close(); |
733 r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries); |
736 r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries); |
734 test(r==KErrNone); |
737 test_KErrNone(r); |
735 dirNameBuf.Zero(); |
738 dirNameBuf.Zero(); |
736 delete dirEntries; |
739 delete dirEntries; |
737 //Resource |
740 //Resource |
738 dirNameBuf=KResourcePath; |
741 dirNameBuf=KResourcePath; |
739 dirNameBuf[0]=(TText)gDriveToTest; |
742 dirNameBuf[0]=(TText)gDriveToTest; |
740 r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal); |
743 r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal); |
741 test(r==KErrNone || r==KErrPathNotFound || r==KErrNotFound); |
744 test_Value(r, r == KErrNone || r==KErrPathNotFound || r==KErrNotFound); |
742 r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries); |
745 r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries); |
743 test(r==KErrNone || r==KErrPathNotFound || r==KErrNotFound); |
746 test_Value(r, r == KErrNone || r==KErrPathNotFound || r==KErrNotFound); |
744 dir.Close(); |
747 dir.Close(); |
745 delete dirEntries; |
748 delete dirEntries; |
746 } |
749 } |
747 |
750 |
748 |
751 |
787 test(aStat1==KErrPermissionDenied); |
790 test(aStat1==KErrPermissionDenied); |
788 test(aStat2==KErrPermissionDenied); |
791 test(aStat2==KErrPermissionDenied); |
789 test(aStat3==KErrNone); |
792 test(aStat3==KErrNone); |
790 |
793 |
791 r=TheFs.SetSessionPath(systestname); |
794 r=TheFs.SetSessionPath(systestname); |
792 test(r==KErrPermissionDenied); |
795 test_Value(r, r == KErrPermissionDenied); |
793 |
796 |
794 //Test RRawDisk class |
797 //Test RRawDisk class |
795 r=rawdisk.Open(TheFs,gTheDriveNum); |
798 r=rawdisk.Open(TheFs,gTheDriveNum); |
796 test(r==KErrPermissionDenied); |
799 test_Value(r, r == KErrPermissionDenied); |
797 rawdisk.Close(); |
800 rawdisk.Close(); |
798 |
801 |
799 RDirtest(); |
802 RDirtest(); |
800 |
803 |
801 #ifdef __WINS__ |
804 #ifdef __WINS__ |
802 if (User::UpperCase(driveBuf[0]) != 'C') |
805 if (User::UpperCase(driveBuf[0]) != 'C') |
803 #endif |
806 #endif |
804 { |
807 { |
805 //Test RFormat class |
808 //Test RFormat class |
806 r=format.Open(TheFs,driveBuf,EHighDensity,count); |
809 r=format.Open(TheFs,driveBuf,EHighDensity,count); |
807 test(r==KErrNone); |
810 test_KErrNone(r); |
808 |
811 |
809 while(count) |
812 while(count) |
810 { |
813 { |
811 TInt r=format.Next(count); |
814 TInt r=format.Next(count); |
812 test(r==KErrNone); |
815 test_KErrNone(r); |
813 } |
816 } |
814 format.Close(); |
817 format.Close(); |
815 } |
818 } |
816 |
819 |
817 driveBuf[0]=(TText)gDriveToTest; |
820 driveBuf[0]=(TText)gDriveToTest; |
818 r=TheFs.ScanDrive(driveBuf); |
821 r=TheFs.ScanDrive(driveBuf); |
819 test(r==KErrNone || r==KErrNotSupported); |
822 test_Value(r, r == KErrNone || r==KErrNotSupported); |
820 r=TheFs.CheckDisk(driveBuf); |
823 r=TheFs.CheckDisk(driveBuf); |
821 test(r==KErrNone || r==KErrNotSupported); |
824 test_Value(r, r == KErrNone || r==KErrNotSupported); |
822 } |
825 } |
823 |
826 |
824 |
827 |
825 |
828 |
826 LOCAL_C void TestCaps() |
829 LOCAL_C void TestCaps() |