99 TheFs.SetErrorCondition(-47,5); |
99 TheFs.SetErrorCondition(-47,5); |
100 TDriveInfo drive; |
100 TDriveInfo drive; |
101 for (TInt i=0;i<5;i++) |
101 for (TInt i=0;i<5;i++) |
102 { |
102 { |
103 TInt r=TheFs.Drive(drive); |
103 TInt r=TheFs.Drive(drive); |
104 test_KErrNone(r); |
104 test(r==KErrNone); |
105 } |
105 } |
106 TInt r=TheFs.MkDirAll(_L("alskdjfl")); |
106 TInt r=TheFs.MkDirAll(_L("alskdjfl")); |
107 test_Value(r, r == -47); |
107 test(r==-47); |
108 r=TheFs.MkDirAll(_L("alskdjfl")); |
108 r=TheFs.MkDirAll(_L("alskdjfl")); |
109 test_Value(r, r == -47); |
109 test(r==-47); |
110 TheFs.SetErrorCondition(KErrNone); |
110 TheFs.SetErrorCondition(KErrNone); |
111 r=TheFs.Drive(drive); |
111 r=TheFs.Drive(drive); |
112 test_KErrNone(r); |
112 test(r==KErrNone); |
113 #endif |
113 #endif |
114 // |
114 // |
115 test.Next(_L("Create LOCTEST files")); |
115 test.Next(_L("Create LOCTEST files")); |
116 Mf(_L("\\F32-TST\\LOCTEST\\FILE1.AAA")); |
116 Mf(_L("\\F32-TST\\LOCTEST\\FILE1.AAA")); |
117 Mf(_L("\\F32-TST\\LOCTEST\\FILE2.BBB")); |
117 Mf(_L("\\F32-TST\\LOCTEST\\FILE2.BBB")); |
283 |
283 |
284 |
284 |
285 TInt r=TheFs.AddFileSystem(_L("CFAFSDLY")); |
285 TInt r=TheFs.AddFileSystem(_L("CFAFSDLY")); |
286 test.Printf(_L("Add remote file system\n")); |
286 test.Printf(_L("Add remote file system\n")); |
287 test.Printf(_L("AddFileSystem returned %d\n"),r); |
287 test.Printf(_L("AddFileSystem returned %d\n"),r); |
288 test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
288 test (r==KErrNone || r==KErrAlreadyExists); |
289 |
289 |
290 |
290 |
291 r=TheFs.MountFileSystem(_L("DELAYFS"),EDriveQ); |
291 r=TheFs.MountFileSystem(_L("DELAYFS"),EDriveQ); |
292 |
292 |
293 |
293 |
294 test.Printf(_L("Mount remote file system\n")); |
294 test.Printf(_L("Mount remote file system\n")); |
295 test.Printf(_L("MountFileSystem returned %d\n"),r); |
295 test.Printf(_L("MountFileSystem returned %d\n"),r); |
296 test_Value(r, r == KErrNone || r==KErrCorrupt || r==KErrNotReady || r==KErrAlreadyExists); |
296 test(r==KErrNone || r==KErrCorrupt || r==KErrNotReady || r==KErrAlreadyExists); |
297 |
297 |
298 |
298 |
299 Mf(_L("Q:\\F32-TST\\LOCTEST\\BIN\\FINDFILE.AAA")); |
299 Mf(_L("Q:\\F32-TST\\LOCTEST\\BIN\\FINDFILE.AAA")); |
300 |
300 |
301 } |
301 } |
324 { |
324 { |
325 test.Next(_L("Test FindByPath")); |
325 test.Next(_L("Test FindByPath")); |
326 |
326 |
327 TAutoClose<RFs> fs; |
327 TAutoClose<RFs> fs; |
328 TInt r=fs.iObj.Connect(); |
328 TInt r=fs.iObj.Connect(); |
329 test_KErrNone(r); |
329 test(r==KErrNone); |
330 TFindFile finder(fs.iObj); |
330 TFindFile finder(fs.iObj); |
331 TPtrC path=gPath1; |
331 TPtrC path=gPath1; |
332 r=finder.FindByPath(_L("file1.aaa"),&path); |
332 r=finder.FindByPath(_L("file1.aaa"),&path); |
333 test_KErrNone(r); |
333 test(r==KErrNone); |
334 TParse fileParse; |
334 TParse fileParse; |
335 fileParse.Set(finder.File(),NULL,NULL); |
335 fileParse.Set(finder.File(),NULL,NULL); |
336 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN1\\")); |
336 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN1\\")); |
337 test(fileParse.NameAndExt()==_L("file1.aaa")); |
337 test(fileParse.NameAndExt()==_L("file1.aaa")); |
338 r=finder.Find(); |
338 r=finder.Find(); |
339 test_Value(r, r == KErrNotFound); |
339 test(r==KErrNotFound); |
340 |
340 |
341 |
341 |
342 path.Set(gPath2); |
342 path.Set(gPath2); |
343 r=finder.FindByPath(_L("file1.aaa"),&path); |
343 r=finder.FindByPath(_L("file1.aaa"),&path); |
344 test_KErrNone(r); |
344 test(r==KErrNone); |
345 fileParse.Set(finder.File(),NULL,NULL); |
345 fileParse.Set(finder.File(),NULL,NULL); |
346 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN1\\")); |
346 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN1\\")); |
347 test(fileParse.NameAndExt()==_L("file1.aaa")); |
347 test(fileParse.NameAndExt()==_L("file1.aaa")); |
348 r=finder.Find(); |
348 r=finder.Find(); |
349 test_KErrNone(r); |
349 test(r==KErrNone); |
350 fileParse.Set(finder.File(),NULL,NULL); |
350 fileParse.Set(finder.File(),NULL,NULL); |
351 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN1\\BIN4\\")); |
351 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN1\\BIN4\\")); |
352 test(fileParse.NameAndExt()==_L("file1.aaa")); |
352 test(fileParse.NameAndExt()==_L("file1.aaa")); |
353 r=finder.Find(); |
353 r=finder.Find(); |
354 test_Value(r, r == KErrNotFound); |
354 test(r==KErrNotFound); |
355 // |
355 // |
356 test.Next(_L("Test FindByDir")); |
356 test.Next(_L("Test FindByDir")); |
357 TPtrC dir=_L("\\F32-TST\\LOCTEST\\BIN2\\"); |
357 TPtrC dir=_L("\\F32-TST\\LOCTEST\\BIN2\\"); |
358 r=finder.FindByDir(_L("file2.bbb"),dir); |
358 r=finder.FindByDir(_L("file2.bbb"),dir); |
359 test_KErrNone(r); |
359 test(r==KErrNone); |
360 TFileName defaultPath; |
360 TFileName defaultPath; |
361 r=TheFs.SessionPath(defaultPath); |
361 r=TheFs.SessionPath(defaultPath); |
362 defaultPath.SetLength(2); |
362 defaultPath.SetLength(2); |
363 test_KErrNone(r); |
363 test(r==KErrNone); |
364 fileParse.Set(finder.File(),NULL,NULL); |
364 fileParse.Set(finder.File(),NULL,NULL); |
365 test(fileParse.Drive()==defaultPath); |
365 test(fileParse.Drive()==defaultPath); |
366 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN2\\")); |
366 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN2\\")); |
367 test(_L("file2.bbb").MatchF(fileParse.NameAndExt())!=KErrNotFound); // MatchF only sees wildcards in its argument |
367 test(_L("file2.bbb").MatchF(fileParse.NameAndExt())!=KErrNotFound); // MatchF only sees wildcards in its argument |
368 r=finder.Find(); |
368 r=finder.Find(); |
387 { |
387 { |
388 |
388 |
389 test.Next(_L("Test extremes")); |
389 test.Next(_L("Test extremes")); |
390 TAutoClose<RFs> fs; |
390 TAutoClose<RFs> fs; |
391 TInt r=fs.iObj.Connect(); |
391 TInt r=fs.iObj.Connect(); |
392 test_KErrNone(r); |
392 test(r==KErrNone); |
393 TBuf<4> temp=_L(""); |
393 TBuf<4> temp=_L(""); |
394 TFindFile finder(fs.iObj); |
394 TFindFile finder(fs.iObj); |
395 r=finder.FindByPath(_L("file1.aaa"),&temp); |
395 r=finder.FindByPath(_L("file1.aaa"),&temp); |
396 test_Value(r, r == KErrNotFound); |
396 test(r==KErrNotFound); |
397 r=finder.Find(); |
397 r=finder.Find(); |
398 test_Value(r, r == KErrNotFound); |
398 test(r==KErrNotFound); |
399 // |
399 // |
400 TPtrC path=_L("blarg.7"); |
400 TPtrC path=_L("blarg.7"); |
401 r=finder.FindByPath(_L(""),&path); |
401 r=finder.FindByPath(_L(""),&path); |
402 test_Value(r, r == KErrArgument); |
402 test(r==KErrArgument); |
403 r=finder.FindByPath(_L("*"),&path); |
403 r=finder.FindByPath(_L("*"),&path); |
404 test_Value(r, r == KErrNotFound); |
404 test(r==KErrNotFound); |
405 r=finder.FindByPath(_L("xmvid"),&path); |
405 r=finder.FindByPath(_L("xmvid"),&path); |
406 test_Value(r, r == KErrNotFound); |
406 test(r==KErrNotFound); |
407 r=finder.Find(); |
407 r=finder.Find(); |
408 test_Value(r, r == KErrNotFound); |
408 test(r==KErrNotFound); |
409 // |
409 // |
410 path.Set(_L("C:\\F32-TST\\LOCTEST\\BIN1\\;\\F32-TST\\LOCTEST\\BIN2\\;Z:\\F32-TST\\LOCTEST\\BIN1\\BIN4\\;\\F32-TST\\LOCTEST\\BIN3\\;")); |
410 path.Set(_L("C:\\F32-TST\\LOCTEST\\BIN1\\;\\F32-TST\\LOCTEST\\BIN2\\;Z:\\F32-TST\\LOCTEST\\BIN1\\BIN4\\;\\F32-TST\\LOCTEST\\BIN3\\;")); |
411 r=finder.FindByPath(_L(""),&path); |
411 r=finder.FindByPath(_L(""),&path); |
412 test_Value(r, r == KErrArgument); |
412 test(r==KErrArgument); |
413 r=finder.FindByPath(_L("xyz.abc"),&path); |
413 r=finder.FindByPath(_L("xyz.abc"),&path); |
414 test_Value(r, r == KErrNotFound); |
414 test(r==KErrNotFound); |
415 r=finder.Find(); |
415 r=finder.Find(); |
416 test_Value(r, r == KErrNotFound); |
416 test(r==KErrNotFound); |
417 |
417 |
418 test.Next(_L("Test FindByDir with empty file spec")); |
418 test.Next(_L("Test FindByDir with empty file spec")); |
419 TPtrC dir2=_L("\\F32-TST\\LOCTEST\\"); |
419 TPtrC dir2=_L("\\F32-TST\\LOCTEST\\"); |
420 r=finder.FindByDir(_L(""),dir2); |
420 r=finder.FindByDir(_L(""),dir2); |
421 test_Value(r, r == KErrArgument); |
421 test(r==KErrArgument); |
422 |
422 |
423 } |
423 } |
424 |
424 |
425 LOCAL_C void Test3() |
425 LOCAL_C void Test3() |
426 // |
426 // |
434 TInt r=TheFs.SessionPath(defaultPath); |
434 TInt r=TheFs.SessionPath(defaultPath); |
435 defaultPath.SetLength(2); |
435 defaultPath.SetLength(2); |
436 // |
436 // |
437 TAutoClose<RFs> fs; |
437 TAutoClose<RFs> fs; |
438 r=fs.iObj.Connect(); |
438 r=fs.iObj.Connect(); |
439 test_KErrNone(r); |
439 test(r==KErrNone); |
440 TFindFile finder(fs.iObj); |
440 TFindFile finder(fs.iObj); |
441 r=finder.FindByPath(_L("file1.aaa"),&path); |
441 r=finder.FindByPath(_L("file1.aaa"),&path); |
442 test_Value(r, r == KErrNotFound); |
442 test(r==KErrNotFound); |
443 r=finder.Find(); |
443 r=finder.Find(); |
444 test_Value(r, r == KErrNotFound); |
444 test(r==KErrNotFound); |
445 // |
445 // |
446 path.Set(_L("\\F32-TST\\LOCTEST\\BIN2\\")); |
446 path.Set(_L("\\F32-TST\\LOCTEST\\BIN2\\")); |
447 r=finder.FindByPath(_L("file2.bbb"),&path); |
447 r=finder.FindByPath(_L("file2.bbb"),&path); |
448 test_KErrNone(r); |
448 test(r==KErrNone); |
449 TParse fileParse; |
449 TParse fileParse; |
450 fileParse.Set(finder.File(),NULL,NULL); |
450 fileParse.Set(finder.File(),NULL,NULL); |
451 test(fileParse.Drive()==defaultPath); |
451 test(fileParse.Drive()==defaultPath); |
452 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN2\\")); |
452 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN2\\")); |
453 test(fileParse.NameAndExt()==_L("file2.bbb")); |
453 test(fileParse.NameAndExt()==_L("file2.bbb")); |
454 r=finder.Find(); |
454 r=finder.Find(); |
455 test_Value(r, r == KErrNotFound || r==KErrNone); |
455 test(r==KErrNotFound || r==KErrNone); |
456 if (r==KErrNone) |
456 if (r==KErrNone) |
457 { |
457 { |
458 fileParse.Set(finder.File(),NULL,NULL); |
458 fileParse.Set(finder.File(),NULL,NULL); |
459 test(fileParse.Drive()!=defaultPath); |
459 test(fileParse.Drive()!=defaultPath); |
460 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN2\\")); |
460 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN2\\")); |
461 test(fileParse.NameAndExt()==_L("file2.bbb")); |
461 test(fileParse.NameAndExt()==_L("file2.bbb")); |
462 r=finder.Find(); |
462 r=finder.Find(); |
463 test_Value(r, r == KErrNotFound); |
463 test(r==KErrNotFound); |
464 } |
464 } |
465 // |
465 // |
466 path.Set(_L("C:\\F32-TST\\LOCTEST\\BIN1\\;;\\F32-TST\\LOCTEST\\BIN2\\;Z:\\F32-TST\\LOCTEST\\BIN1\\BIN4\\;\\F32-TST\\LOCTEST\\BIN3\\;")); |
466 path.Set(_L("C:\\F32-TST\\LOCTEST\\BIN1\\;;\\F32-TST\\LOCTEST\\BIN2\\;Z:\\F32-TST\\LOCTEST\\BIN1\\BIN4\\;\\F32-TST\\LOCTEST\\BIN3\\;")); |
467 r=finder.FindByPath(_L("xyz.abc"),&path); |
467 r=finder.FindByPath(_L("xyz.abc"),&path); |
468 test_Value(r, r == KErrNotFound); |
468 test(r==KErrNotFound); |
469 r=finder.Find(); |
469 r=finder.Find(); |
470 test_Value(r, r == KErrNotFound); |
470 test(r==KErrNotFound); |
471 // |
471 // |
472 r=finder.FindByPath(_L("file2.bbb"),&path); |
472 r=finder.FindByPath(_L("file2.bbb"),&path); |
473 test_KErrNone(r); |
473 test(r==KErrNone); |
474 fileParse.Set(finder.File(),NULL,NULL); |
474 fileParse.Set(finder.File(),NULL,NULL); |
475 test(fileParse.Drive()==defaultPath); |
475 test(fileParse.Drive()==defaultPath); |
476 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN2\\")); |
476 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN2\\")); |
477 test(fileParse.NameAndExt()==_L("file2.bbb")); |
477 test(fileParse.NameAndExt()==_L("file2.bbb")); |
478 r=finder.Find(); |
478 r=finder.Find(); |
479 test_Value(r, r == KErrNotFound || r==KErrNone); |
479 test(r==KErrNotFound || r==KErrNone); |
480 if (r==KErrNone) |
480 if (r==KErrNone) |
481 { |
481 { |
482 fileParse.Set(finder.File(),NULL,NULL); |
482 fileParse.Set(finder.File(),NULL,NULL); |
483 test(fileParse.Drive()!=defaultPath); |
483 test(fileParse.Drive()!=defaultPath); |
484 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN2\\")); |
484 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN2\\")); |
485 test(fileParse.NameAndExt()==_L("file2.bbb")); |
485 test(fileParse.NameAndExt()==_L("file2.bbb")); |
486 r=finder.Find(); |
486 r=finder.Find(); |
487 test_Value(r, r == KErrNotFound); |
487 test(r==KErrNotFound); |
488 } |
488 } |
489 } |
489 } |
490 |
490 |
491 LOCAL_C void Test4() |
491 LOCAL_C void Test4() |
492 // |
492 // |
529 path=fileParse.FullName(); |
529 path=fileParse.FullName(); |
530 test(path==_L("C:\\F32-TST\\LOCTEST\\BIN1\\*.aaa")); |
530 test(path==_L("C:\\F32-TST\\LOCTEST\\BIN1\\*.aaa")); |
531 delete dir; |
531 delete dir; |
532 |
532 |
533 r=finder.FindWild(dir); |
533 r=finder.FindWild(dir); |
534 test_Value(r, r == KErrNotFound); |
534 test(r==KErrNotFound); |
535 r=finder.FindWild(dir); |
535 r=finder.FindWild(dir); |
536 test_Value(r, r == KErrNotFound); |
536 test(r==KErrNotFound); |
537 |
537 |
538 r=finder.FindWildByPath(_L("*FILE.AAA*"), &gPath1, dir); |
538 r=finder.FindWildByPath(_L("*FILE.AAA*"), &gPath1, dir); |
539 test_KErrNone(r); |
539 test(r==KErrNone); |
540 test(dir->Count()==1); |
540 test(dir->Count()==1); |
541 entry=(*dir)[0]; |
541 entry=(*dir)[0]; |
542 test(entry.iName.MatchF(_L("FILE.AAA"))!=KErrNotFound); |
542 test(entry.iName.MatchF(_L("FILE.AAA"))!=KErrNotFound); |
543 delete dir; |
543 delete dir; |
544 |
544 |
545 r=finder.FindWildByPath(_L("*FILE.AAA"), &gPath1, dir); |
545 r=finder.FindWildByPath(_L("*FILE.AAA"), &gPath1, dir); |
546 test_KErrNone(r); |
546 test(r==KErrNone); |
547 test(dir->Count()==1); |
547 test(dir->Count()==1); |
548 entry=(*dir)[0]; |
548 entry=(*dir)[0]; |
549 test(entry.iName.MatchF(_L("FILE.AAA"))!=KErrNotFound); |
549 test(entry.iName.MatchF(_L("FILE.AAA"))!=KErrNotFound); |
550 delete dir; |
550 delete dir; |
551 |
551 |
552 r=finder.FindWildByPath(_L("FILE.AAA*"), &gPath1, dir); |
552 r=finder.FindWildByPath(_L("FILE.AAA*"), &gPath1, dir); |
553 test_KErrNone(r); |
553 test(r==KErrNone); |
554 test(dir->Count()==1); |
554 test(dir->Count()==1); |
555 entry=(*dir)[0]; |
555 entry=(*dir)[0]; |
556 test(entry.iName.MatchF(_L("FILE.AAA"))!=KErrNotFound); |
556 test(entry.iName.MatchF(_L("FILE.AAA"))!=KErrNotFound); |
557 delete dir; |
557 delete dir; |
558 |
558 |
559 |
559 |
560 r=finder.FindWildByPath(_L("CONFUSED.DOG"), &gPath1, dir); |
560 r=finder.FindWildByPath(_L("CONFUSED.DOG"), &gPath1, dir); |
561 test_KErrNone(r); |
561 test(r==KErrNone); |
562 test(dir->Count()==1); |
562 test(dir->Count()==1); |
563 entry=(*dir)[0]; |
563 entry=(*dir)[0]; |
564 test(entry.iName.MatchF(_L("CONFUSED.DOG"))!=KErrNotFound); |
564 test(entry.iName.MatchF(_L("CONFUSED.DOG"))!=KErrNotFound); |
565 delete dir; |
565 delete dir; |
566 |
566 |
567 r=finder.FindWildByPath(_L("*CONFUSED.DOG"), &gPath1, dir); |
567 r=finder.FindWildByPath(_L("*CONFUSED.DOG"), &gPath1, dir); |
568 test_KErrNone(r); |
568 test(r==KErrNone); |
569 test(dir->Count()==1); |
569 test(dir->Count()==1); |
570 entry=(*dir)[0]; |
570 entry=(*dir)[0]; |
571 test(entry.iName.MatchF(_L("CONFUSED.DOG"))!=KErrNotFound); |
571 test(entry.iName.MatchF(_L("CONFUSED.DOG"))!=KErrNotFound); |
572 delete dir; |
572 delete dir; |
573 r=finder.FindWildByPath(_L("CONFUSED.DOG*"), &gPath1, dir); |
573 r=finder.FindWildByPath(_L("CONFUSED.DOG*"), &gPath1, dir); |
574 test_KErrNone(r); |
574 test(r==KErrNone); |
575 test(dir->Count()==1); |
575 test(dir->Count()==1); |
576 entry=(*dir)[0]; |
576 entry=(*dir)[0]; |
577 test(entry.iName.MatchF(_L("CONFUSED.DOG"))!=KErrNotFound); |
577 test(entry.iName.MatchF(_L("CONFUSED.DOG"))!=KErrNotFound); |
578 delete dir; |
578 delete dir; |
579 r=finder.FindWildByPath(_L("*CONFUSED.DOG*"), &gPath1, dir); |
579 r=finder.FindWildByPath(_L("*CONFUSED.DOG*"), &gPath1, dir); |
580 test_KErrNone(r); |
580 test(r==KErrNone); |
581 test(dir->Count()==1); |
581 test(dir->Count()==1); |
582 entry=(*dir)[0]; |
582 entry=(*dir)[0]; |
583 test(entry.iName.MatchF(_L("CONFUSED.DOG"))!=KErrNotFound); |
583 test(entry.iName.MatchF(_L("CONFUSED.DOG"))!=KErrNotFound); |
584 delete dir; |
584 delete dir; |
585 } |
585 } |
612 delete dir; |
612 delete dir; |
613 |
613 |
614 r=finder.FindWild(dir); |
614 r=finder.FindWild(dir); |
615 if (r==KErrNotFound) |
615 if (r==KErrNotFound) |
616 return; |
616 return; |
617 test_KErrNone(r); |
617 test(r==KErrNone); |
618 entry=(*dir)[0]; |
618 entry=(*dir)[0]; |
619 test(entry.iName.MatchF(_L("FILE3.CCC"))!=KErrNotFound); |
619 test(entry.iName.MatchF(_L("FILE3.CCC"))!=KErrNotFound); |
620 fileParse.Set(finder.File(),NULL,NULL); |
620 fileParse.Set(finder.File(),NULL,NULL); |
621 path=fileParse.FullName(); |
621 path=fileParse.FullName(); |
622 test(path.CompareF(tpath)==0); |
622 test(path.CompareF(tpath)==0); |
623 delete dir; |
623 delete dir; |
624 |
624 |
625 r=finder.FindWild(dir); |
625 r=finder.FindWild(dir); |
626 test_Value(r, r == KErrNotFound); |
626 test(r==KErrNotFound); |
627 r=finder.FindWild(dir); |
627 r=finder.FindWild(dir); |
628 test_Value(r, r == KErrNotFound); |
628 test(r==KErrNotFound); |
629 } |
629 } |
630 |
630 |
631 LOCAL_C void Test6() |
631 LOCAL_C void Test6() |
632 // |
632 // |
633 // Test file not found |
633 // Test file not found |
674 |
674 |
675 { |
675 { |
676 |
676 |
677 TAutoClose<RFs> fs; |
677 TAutoClose<RFs> fs; |
678 TInt r=fs.iObj.Connect(); |
678 TInt r=fs.iObj.Connect(); |
679 test_KErrNone(r); |
679 test(r==KErrNone); |
680 TFindFile finder(fs.iObj); |
680 TFindFile finder(fs.iObj); |
681 TPtrC path=gPath4; |
681 TPtrC path=gPath4; |
682 r=finder.FindByPath(_L("findfile.aaa"),&path); |
682 r=finder.FindByPath(_L("findfile.aaa"),&path); |
683 |
683 |
684 TParse fileParse; |
684 TParse fileParse; |
685 |
685 |
686 test.Next(_L("Test FindByPath without specifying any mask")); |
686 test.Next(_L("Test FindByPath without specifying any mask")); |
687 |
687 |
688 if (removableFlag == 1) |
688 if (removableFlag == 1) |
689 { |
689 { |
690 test_KErrNone(r); |
690 test(r==KErrNone); |
691 fileParse.Set(finder.File(),NULL,NULL); |
691 fileParse.Set(finder.File(),NULL,NULL); |
692 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN\\")); |
692 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN\\")); |
693 test(fileParse.NameAndExt()==_L("findfile.aaa")); //The filename.aaa in the removable Drive |
693 test(fileParse.NameAndExt()==_L("findfile.aaa")); //The filename.aaa in the removable Drive |
694 r=finder.Find(); |
694 r=finder.Find(); |
695 test_Value(r, r == KErrNotFound); //remote drives are excluded by default |
695 test(r==KErrNotFound); //remote drives are excluded by default |
696 |
696 |
697 } |
697 } |
698 else |
698 else |
699 test_Value(r, r == KErrNotFound); |
699 test(r==KErrNotFound); |
700 |
700 |
701 |
701 |
702 |
702 |
703 test.Next(_L("Search for the specified file in all Drives, including remotes ones \n")); |
703 test.Next(_L("Search for the specified file in all Drives, including remotes ones \n")); |
704 |
704 |
705 |
705 |
706 r=finder.SetFindMask( KDriveAttAll) ; |
706 r=finder.SetFindMask( KDriveAttAll) ; |
707 test_KErrNone(r); |
707 test(r==KErrNone); |
708 r=finder.FindByPath(_L("findfile.aaa"),&path); |
708 r=finder.FindByPath(_L("findfile.aaa"),&path); |
709 test_KErrNone(r); |
709 test(r==KErrNone); |
710 fileParse.Set(finder.File(),NULL,NULL); |
710 fileParse.Set(finder.File(),NULL,NULL); |
711 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN\\")); |
711 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN\\")); |
712 test(fileParse.NameAndExt()==_L("findfile.aaa")); //either the remote or removable one. |
712 test(fileParse.NameAndExt()==_L("findfile.aaa")); //either the remote or removable one. |
713 r=finder.Find(); |
713 r=finder.Find(); |
714 |
714 |
715 |
715 |
716 if (removableFlag == 1) |
716 if (removableFlag == 1) |
717 { |
717 { |
718 test_KErrNone(r); |
718 test(r==KErrNone); |
719 |
719 |
720 fileParse.Set(finder.File(),NULL,NULL); |
720 fileParse.Set(finder.File(),NULL,NULL); |
721 |
721 |
722 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN\\")); |
722 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN\\")); |
723 test(fileParse.NameAndExt()==_L("findfile.aaa")); //either the remote or removable one. |
723 test(fileParse.NameAndExt()==_L("findfile.aaa")); //either the remote or removable one. |
724 |
724 |
725 r=finder.Find(); |
725 r=finder.Find(); |
726 test_Value(r, r == KErrNotFound); |
726 test(r==KErrNotFound); |
727 } |
727 } |
728 else |
728 else |
729 { |
729 { |
730 test_Value(r, r == KErrNotFound); |
730 test(r==KErrNotFound); |
731 |
731 |
732 } |
732 } |
733 |
733 |
734 |
734 |
735 test.Next(_L("Search exclusively in remote drives \n")); |
735 test.Next(_L("Search exclusively in remote drives \n")); |
736 |
736 |
737 r=finder.SetFindMask( KDriveAttExclusive| KDriveAttRemote); |
737 r=finder.SetFindMask( KDriveAttExclusive| KDriveAttRemote); |
738 test_KErrNone(r); |
738 test(r==KErrNone); |
739 r=finder.FindByPath(_L("findfile.aaa"),&path); |
739 r=finder.FindByPath(_L("findfile.aaa"),&path); |
740 test_KErrNone(r); |
740 test(r==KErrNone); |
741 fileParse.Set(finder.File(),NULL,NULL); |
741 fileParse.Set(finder.File(),NULL,NULL); |
742 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN\\")); |
742 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN\\")); |
743 test(fileParse.NameAndExt()==_L("findfile.aaa")); |
743 test(fileParse.NameAndExt()==_L("findfile.aaa")); |
744 r=finder.Find(); |
744 r=finder.Find(); |
745 test_Value(r, r == KErrNotFound); |
745 test(r==KErrNotFound); |
746 |
746 |
747 |
747 |
748 test.Next(_L("Search excluding removables and remote \n")); |
748 test.Next(_L("Search excluding removables and remote \n")); |
749 |
749 |
750 r=finder.SetFindMask( KDriveAttExclude | KDriveAttRemovable |KDriveAttRemote ); |
750 r=finder.SetFindMask( KDriveAttExclude | KDriveAttRemovable |KDriveAttRemote ); |
751 test_KErrNone(r); |
751 test(r==KErrNone); |
752 r=finder.FindByPath(_L("findfile.aaa"),&path); |
752 r=finder.FindByPath(_L("findfile.aaa"),&path); |
753 test_Value(r, r == KErrNotFound); //filename.aaa exists in the remote drive and if present to the removable one |
753 test(r==KErrNotFound); //filename.aaa exists in the remote drive and if present to the removable one |
754 |
754 |
755 |
755 |
756 test.Next(_L("Search in Internal Drives \n")); |
756 test.Next(_L("Search in Internal Drives \n")); |
757 |
757 |
758 r=finder.SetFindMask(KDriveAttInternal ) ; |
758 r=finder.SetFindMask(KDriveAttInternal ) ; |
759 test_KErrNone(r); |
759 test(r==KErrNone); |
760 r=finder.FindByPath(_L("findfile.aaa"),&path); |
760 r=finder.FindByPath(_L("findfile.aaa"),&path); |
761 test_Value(r, r == KErrNotFound); //filename.aaa exists only in the Removable drive and the remote one. |
761 test(r==KErrNotFound); //filename.aaa exists only in the Removable drive and the remote one. |
762 |
762 |
763 |
763 |
764 } |
764 } |
765 |
765 |
766 |
766 |
787 test.Next(_L("Test SetFindMask with all mask combinations \n")); |
787 test.Next(_L("Test SetFindMask with all mask combinations \n")); |
788 |
788 |
789 |
789 |
790 TAutoClose<RFs> fs; |
790 TAutoClose<RFs> fs; |
791 TInt r=fs.iObj.Connect(); |
791 TInt r=fs.iObj.Connect(); |
792 test_KErrNone(r); |
792 test(r==KErrNone); |
793 TFindFile finder(fs.iObj); |
793 TFindFile finder(fs.iObj); |
794 TPtrC path=gPath4; |
794 TPtrC path=gPath4; |
795 TParse fileParse; |
795 TParse fileParse; |
796 |
796 |
797 |
797 |
798 r=finder.SetFindMask(KDriveAttAll) ; |
798 r=finder.SetFindMask(KDriveAttAll) ; |
799 test_KErrNone(r); |
799 test(r==KErrNone); |
800 r=finder.FindByPath(_L("findfile.aaa"),&path); |
800 r=finder.FindByPath(_L("findfile.aaa"),&path); |
801 test_KErrNone(r); |
801 test(r==KErrNone); |
802 fileParse.Set(finder.File(),NULL,NULL); |
802 fileParse.Set(finder.File(),NULL,NULL); |
803 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN\\")); |
803 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN\\")); |
804 test(fileParse.NameAndExt()==_L("findfile.aaa")); |
804 test(fileParse.NameAndExt()==_L("findfile.aaa")); |
805 |
805 |
806 |
806 |
836 // test.Printf(_L("Expected Result : %d \n"), testAtt == 0 ? testCombinations[matchIdx].iExpectedResultNoAtts : testCombinations[matchIdx].iExpectedResultWithAtts); |
836 // test.Printf(_L("Expected Result : %d \n"), testAtt == 0 ? testCombinations[matchIdx].iExpectedResultNoAtts : testCombinations[matchIdx].iExpectedResultWithAtts); |
837 // test.Printf(_L(" Actual Result : 0x%08x \n"), err); |
837 // test.Printf(_L(" Actual Result : 0x%08x \n"), err); |
838 |
838 |
839 // test.Printf(_L("\nTest mask : %d \n"),testCombinations[matchIdx].iMatchMask | testAtt ); |
839 // test.Printf(_L("\nTest mask : %d \n"),testCombinations[matchIdx].iMatchMask | testAtt ); |
840 |
840 |
841 test_Value(r, r == (testAtt == 0 ? testCombinations[matchIdx].iExpectedResultNoAtts : testCombinations[matchIdx].iExpectedResultWithAtts) ); |
841 test( r == (testAtt == 0 ? testCombinations[matchIdx].iExpectedResultNoAtts : testCombinations[matchIdx].iExpectedResultWithAtts) ); |
842 |
842 |
843 |
843 |
844 if (r== KErrNone) |
844 if (r== KErrNone) |
845 { |
845 { |
846 r = finder.FindByPath(_L("findfile.aaa"),&path); |
846 r = finder.FindByPath(_L("findfile.aaa"),&path); |
847 test_Value(r, r == KErrNone || r ==KErrNotFound); |
847 test (r== KErrNone || r ==KErrNotFound); |
848 } |
848 } |
849 |
849 |
850 } |
850 } |
851 } |
851 } |
852 |
852 |
897 { |
897 { |
898 |
898 |
899 test.Next(_L("FindByDir with wild filenames when a find mask is specified")); |
899 test.Next(_L("FindByDir with wild filenames when a find mask is specified")); |
900 |
900 |
901 TInt r=finder.SetFindMask(KDriveAttRemovable); |
901 TInt r=finder.SetFindMask(KDriveAttRemovable); |
902 test_KErrNone(r); |
902 test(r==KErrNone); |
903 r=finder.FindWildByDir(_L("FIND*"),_L("\\F32-TST\\LOCTEST\\BIN\\"),dir); |
903 r=finder.FindWildByDir(_L("FIND*"),_L("\\F32-TST\\LOCTEST\\BIN\\"),dir); |
904 test_KErrNone(r); |
904 test(r==KErrNone); |
905 count=dir->Count(); |
905 count=dir->Count(); |
906 test(count==1); |
906 test(count==1); |
907 entry=(*dir)[0]; |
907 entry=(*dir)[0]; |
908 test(entry.iName.MatchF(_L("FINDFILE.AAA"))!=KErrNotFound); |
908 test(entry.iName.MatchF(_L("FINDFILE.AAA"))!=KErrNotFound); |
909 delete dir; |
909 delete dir; |
910 |
910 |
911 r=finder.FindWild(dir); |
911 r=finder.FindWild(dir); |
912 test_Value(r, r == KErrNotFound); |
912 test(r==KErrNotFound); |
913 |
913 |
914 |
914 |
915 r=finder.SetFindMask(KDriveAttExclude| KDriveAttRemovable); |
915 r=finder.SetFindMask(KDriveAttExclude| KDriveAttRemovable); |
916 test_KErrNone(r); |
916 test(r==KErrNone); |
917 r=finder.FindWildByDir(_L("FIND*"),_L("\\F32-TST\\LOCTEST\\BIN\\"),dir); |
917 r=finder.FindWildByDir(_L("FIND*"),_L("\\F32-TST\\LOCTEST\\BIN\\"),dir); |
918 test_Value(r, r == KErrNotFound); |
918 test(r==KErrNotFound); |
919 |
919 |
920 |
920 |
921 test.Next(_L("Test FindByDir when a find mask is specified")); |
921 test.Next(_L("Test FindByDir when a find mask is specified")); |
922 |
922 |
923 |
923 |
924 TPtrC dir2=_L("\\F32-TST\\LOCTEST\\BIN\\"); |
924 TPtrC dir2=_L("\\F32-TST\\LOCTEST\\BIN\\"); |
925 |
925 |
926 r=finder.SetFindMask(KDriveAttExclude | KDriveAttRemote ); |
926 r=finder.SetFindMask(KDriveAttExclude | KDriveAttRemote ); |
927 test_KErrNone(r); |
927 test(r==KErrNone); |
928 r=finder.FindByDir(_L("findfile.aaa"),dir2); |
928 r=finder.FindByDir(_L("findfile.aaa"),dir2); |
929 test_KErrNone(r); |
929 test(r==KErrNone); |
930 |
930 |
931 r=finder.Find(); |
931 r=finder.Find(); |
932 test_Value(r, r == KErrNotFound); |
932 test(r==KErrNotFound); |
933 |
933 |
934 |
934 |
935 } |
935 } |
936 |
936 |
937 |
937 |
1024 //------------------------------------ |
1024 //------------------------------------ |
1025 test.Printf(_L("Test FindWildByPath failures\n")); |
1025 test.Printf(_L("Test FindWildByPath failures\n")); |
1026 |
1026 |
1027 __UHEAP_MARK; |
1027 __UHEAP_MARK; |
1028 nRes = finder.FindWildByPath(_L("*"), &gPath1, pDir); |
1028 nRes = finder.FindWildByPath(_L("*"), &gPath1, pDir); |
1029 test_KErrNone(nRes); |
1029 test(nRes == KErrNone); |
1030 test(pDir && pDir->Count() > 1); |
1030 test(pDir && pDir->Count() > 1); |
1031 delete pDir; |
1031 delete pDir; |
1032 |
1032 |
1033 |
1033 |
1034 for(cnt = 0; ;cnt++) |
1034 for(cnt = 0; ;cnt++) |
1035 { |
1035 { |
1036 nRes =TheFs.SetErrorCondition(KMyError, cnt); |
1036 nRes =TheFs.SetErrorCondition(KMyError, cnt); |
1037 test_KErrNone(nRes); |
1037 test(nRes == KErrNone); |
1038 |
1038 |
1039 pDir = (CDir*)0xaabbccdd; |
1039 pDir = (CDir*)0xaabbccdd; |
1040 nRes = finder.FindWildByPath(_L("*"), &gPath1, pDir); |
1040 nRes = finder.FindWildByPath(_L("*"), &gPath1, pDir); |
1041 |
1041 |
1042 //-- on error the memory allocated internally for CDir shall be freed and the pointer CDir* shall be set to NULL |
1042 //-- on error the memory allocated internally for CDir shall be freed and the pointer CDir* shall be set to NULL |
1068 //------------------------------------ |
1068 //------------------------------------ |
1069 test.Printf(_L("Test FindWildByDir failures\n")); |
1069 test.Printf(_L("Test FindWildByDir failures\n")); |
1070 |
1070 |
1071 __UHEAP_MARK; |
1071 __UHEAP_MARK; |
1072 nRes = finder.FindWildByDir(_L("*"), KPath, pDir); |
1072 nRes = finder.FindWildByDir(_L("*"), KPath, pDir); |
1073 test_KErrNone(nRes); |
1073 test(nRes == KErrNone); |
1074 test(pDir && pDir->Count() > 1); |
1074 test(pDir && pDir->Count() > 1); |
1075 delete pDir; |
1075 delete pDir; |
1076 |
1076 |
1077 for(cnt = 0; ;cnt++) |
1077 for(cnt = 0; ;cnt++) |
1078 { |
1078 { |
1079 nRes =TheFs.SetErrorCondition(KMyError, cnt); |
1079 nRes =TheFs.SetErrorCondition(KMyError, cnt); |
1080 test_KErrNone(nRes); |
1080 test(nRes == KErrNone); |
1081 |
1081 |
1082 pDir = (CDir*)0xaabbccdd; |
1082 pDir = (CDir*)0xaabbccdd; |
1083 nRes = finder.FindWildByDir(_L("*"), KPath, pDir); |
1083 nRes = finder.FindWildByDir(_L("*"), KPath, pDir); |
1084 |
1084 |
1085 //-- on error the memory allocated internally for CDir shall be freed and the pointer CDir* shall be set to NULL |
1085 //-- on error the memory allocated internally for CDir shall be freed and the pointer CDir* shall be set to NULL |