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