112 iFileMan=aFileMan; |
113 iFileMan=aFileMan; |
113 } |
114 } |
114 |
115 |
115 MFileManObserver::TControl CFileManObserver::NotifyFileManStarted() |
116 MFileManObserver::TControl CFileManObserver::NotifyFileManStarted() |
116 { |
117 { |
|
118 (void)MFileManObserver::NotifyFileManStarted(); |
117 TInt lastError = iFileMan->GetLastError(); |
119 TInt lastError = iFileMan->GetLastError(); |
118 TFileName fileName = iFileMan->CurrentEntry().iName; |
120 TFileName fileName = iFileMan->CurrentEntry().iName; |
119 test.Printf(_L("NotifyFileManStarted(): Error %d File %S\n"),lastError, &fileName); |
121 test.Printf(_L("NotifyFileManStarted(): Error %d File %S\n"),lastError, &fileName); |
120 return(MFileManObserver::EContinue); |
122 return(MFileManObserver::EContinue); |
121 } |
123 } |
122 |
124 |
123 MFileManObserver::TControl CFileManObserver::NotifyFileManOperation() |
125 MFileManObserver::TControl CFileManObserver::NotifyFileManOperation() |
124 { |
126 { |
|
127 (void)MFileManObserver::NotifyFileManOperation(); |
125 TInt lastError = iFileMan->GetLastError(); |
128 TInt lastError = iFileMan->GetLastError(); |
126 TFileName fileName = iFileMan->CurrentEntry().iName; |
129 TFileName fileName = iFileMan->CurrentEntry().iName; |
127 test.Printf(_L("NotifyFileManOperation(): Error %d File %S\n"),lastError, &fileName); |
130 test.Printf(_L("NotifyFileManOperation(): Error %d File %S\n"),lastError, &fileName); |
128 return(MFileManObserver::EContinue); |
131 return(MFileManObserver::EContinue); |
129 } |
132 } |
166 const TFileName fname = KFile2GBMinusOne(); |
169 const TFileName fname = KFile2GBMinusOne(); |
167 |
170 |
168 test.Next(_L("2GBMinusOne File: Open")); |
171 test.Next(_L("2GBMinusOne File: Open")); |
169 |
172 |
170 r = f.Open(TheFs, fname, EFileRead); |
173 r = f.Open(TheFs, fname, EFileRead); |
171 test(r==KErrNone); |
174 test_KErrNone(r); |
172 |
175 |
173 testSize = K2GbMinusOne; |
176 testSize = K2GbMinusOne; |
174 |
177 |
175 test.Next(_L("2GBMinusOne File: Read")); |
178 test.Next(_L("2GBMinusOne File: Read")); |
176 |
179 |
177 r=f.Size((TInt&) size); |
180 r=f.Size((TInt&) size); |
178 test(r==KErrNone); |
181 test_KErrNone(r); |
179 test(size == testSize); |
182 test(size == testSize); |
180 |
183 |
181 r = TheFs.Entry(fname, entry); |
184 r = TheFs.Entry(fname, entry); |
182 test(r==KErrNone); |
185 test_KErrNone(r); |
183 test ((TUint) entry.iSize == testSize); |
186 test ((TUint) entry.iSize == testSize); |
184 |
187 |
185 // seek to just below 2GB |
188 // seek to just below 2GB |
186 testPos = (K2GbMinusOne - K1Kb) & KPosMask; |
189 testPos = (K2GbMinusOne - K1Kb) & KPosMask; |
187 r = f.Seek(ESeekStart, (TInt&) testPos); |
190 r = f.Seek(ESeekStart, (TInt&) testPos); |
188 test(r==KErrNone); |
191 test_KErrNone(r); |
189 |
192 |
190 r = f.Read(bufPtr); |
193 r = f.Read(bufPtr); |
191 test(r==KErrNone); |
194 test_KErrNone(r); |
192 |
195 |
193 TUint posRead = * ((TUint*) &bufPtr[0]); |
196 TUint posRead = * ((TUint*) &bufPtr[0]); |
194 test.Printf(_L("position read %08X, expected %08X\n"), posRead, testPos); |
197 test.Printf(_L("position read %08X, expected %08X\n"), posRead, testPos); |
195 test(posRead == testPos); |
198 test(posRead == testPos); |
196 |
199 |
219 const TFileName fname = KFile2GB(); |
222 const TFileName fname = KFile2GB(); |
220 testSize = K2Gb; |
223 testSize = K2Gb; |
221 |
224 |
222 test.Next(_L("2GB File: Test the size with RFs::Entry")); |
225 test.Next(_L("2GB File: Test the size with RFs::Entry")); |
223 r = TheFs.Entry(fname, entry); |
226 r = TheFs.Entry(fname, entry); |
224 test(r==KErrNone); |
227 test_KErrNone(r); |
225 test ((TUint) entry.iSize == testSize); |
228 test ((TUint) entry.iSize == testSize); |
226 |
229 |
227 test.Next(_L("2GB File: Attempt to open (should fail with KErrToBig)")); |
230 test.Next(_L("2GB File: Attempt to open (should fail with KErrToBig)")); |
228 |
231 |
229 r = f.Open(TheFs, fname, EFileRead); |
232 r = f.Open(TheFs, fname, EFileRead); |
230 test(r==KErrTooBig); |
233 test_Value(r, r == KErrTooBig); |
231 } |
234 } |
232 |
235 |
233 //---------------------------------------------------------------------------------------------- |
236 //---------------------------------------------------------------------------------------------- |
234 //! @SYMTestCaseID PBASE-T_BIGFILE-0003 |
237 //! @SYMTestCaseID PBASE-T_BIGFILE-0003 |
235 //! @SYMTestType CIT |
238 //! @SYMTestType CIT |
252 const TFileName fname = KFile3GB(); |
255 const TFileName fname = KFile3GB(); |
253 testSize = K3Gb; |
256 testSize = K3Gb; |
254 |
257 |
255 test.Next(_L("3GB File: Test the size with RFs::Entry")); |
258 test.Next(_L("3GB File: Test the size with RFs::Entry")); |
256 r = TheFs.Entry(fname, entry); |
259 r = TheFs.Entry(fname, entry); |
257 test(r==KErrNone); |
260 test_KErrNone(r); |
258 test ((TUint) entry.iSize == testSize); |
261 test ((TUint) entry.iSize == testSize); |
259 |
262 |
260 test.Next(_L("3GB File: Attempt to open (should fail with KErrToBig)")); |
263 test.Next(_L("3GB File: Attempt to open (should fail with KErrToBig)")); |
261 |
264 |
262 r = f.Open(TheFs, fname, EFileRead); |
265 r = f.Open(TheFs, fname, EFileRead); |
263 test(r==KErrTooBig); |
266 test_Value(r, r == KErrTooBig); |
264 } |
267 } |
265 |
268 |
266 //---------------------------------------------------------------------------------------------- |
269 //---------------------------------------------------------------------------------------------- |
267 //! @SYMTestCaseID PBASE-T_BIGFILE-0004 |
270 //! @SYMTestCaseID PBASE-T_BIGFILE-0004 |
268 //! @SYMTestType CIT |
271 //! @SYMTestType CIT |
322 testSize = K2GbMinusOne; |
325 testSize = K2GbMinusOne; |
323 |
326 |
324 test.Next(_L("2GBMinusOne File: Open")); |
327 test.Next(_L("2GBMinusOne File: Open")); |
325 |
328 |
326 r = f.Open(TheFs, fname, EFileRead | EFileWrite); |
329 r = f.Open(TheFs, fname, EFileRead | EFileWrite); |
327 test(r==KErrNone); |
330 test_KErrNone(r); |
328 |
331 |
329 |
332 |
330 test.Next(_L("2GBMinusOne File: Attempt to extend")); |
333 test.Next(_L("2GBMinusOne File: Attempt to extend")); |
331 |
334 |
332 r=f.Size((TInt&) size); |
335 r=f.Size((TInt&) size); |
333 test(r==KErrNone); |
336 test_KErrNone(r); |
334 test(size == testSize); |
337 test(size == testSize); |
335 |
338 |
336 r = TheFs.Entry(fname, entry); |
339 r = TheFs.Entry(fname, entry); |
337 test(r==KErrNone); |
340 test_KErrNone(r); |
338 test ((TUint) entry.iSize == testSize); |
341 test ((TUint) entry.iSize == testSize); |
339 |
342 |
340 // seek to end |
343 // seek to end |
341 testPos = 0; |
344 testPos = 0; |
342 r = f.Seek(ESeekEnd, (TInt&) testPos); |
345 r = f.Seek(ESeekEnd, (TInt&) testPos); |
343 test(r==KErrNone); |
346 test_KErrNone(r); |
344 |
347 |
345 bufPtr.SetLength(1); |
348 bufPtr.SetLength(1); |
346 r = f.Write(bufPtr); |
349 r = f.Write(bufPtr); |
347 test(r==KErrTooBig); |
350 test_Value(r, r == KErrTooBig); |
348 |
351 |
349 f.Close(); |
352 f.Close(); |
350 } |
353 } |
351 |
354 |
352 //---------------------------------------------------------------------------------------------- |
355 //---------------------------------------------------------------------------------------------- |
481 TPath filePathOld = gSessionPath; |
484 TPath filePathOld = gSessionPath; |
482 filePathOld+= _L("*.*"); |
485 filePathOld+= _L("*.*"); |
483 TPath filePathNew = _L("?:\\TEST\\"); |
486 TPath filePathNew = _L("?:\\TEST\\"); |
484 TChar driveLetter; |
487 TChar driveLetter; |
485 TInt r=TheFs.DriveToChar(gDrive,driveLetter); |
488 TInt r=TheFs.DriveToChar(gDrive,driveLetter); |
486 test(r==KErrNone); |
489 test_KErrNone(r); |
487 filePathNew[0] = (TText) driveLetter; |
490 filePathNew[0] = (TText) driveLetter; |
488 |
491 |
489 // move to new directory |
492 // move to new directory |
490 r = fileMan->Move(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite); |
493 r = fileMan->Move(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite); |
491 test(r == KErrNone); |
494 test_KErrNone(r); |
492 |
495 |
493 // then move back again |
496 // then move back again |
494 r = fileMan->Move(filePathNew, filePathOld); |
497 r = fileMan->Move(filePathNew, filePathOld); |
495 test(r == KErrNone); |
498 test_KErrNone(r); |
496 |
499 |
497 delete fileMan; |
500 delete fileMan; |
498 } |
501 } |
499 |
502 |
500 |
503 |
520 TPath filePathOld = gSessionPath; |
523 TPath filePathOld = gSessionPath; |
521 filePathOld+= _L("*.*"); |
524 filePathOld+= _L("*.*"); |
522 TPath filePathNew = _L("?:\\TEST\\"); |
525 TPath filePathNew = _L("?:\\TEST\\"); |
523 TChar driveLetter; |
526 TChar driveLetter; |
524 TInt r = TheFs.DriveToChar(gDrive,driveLetter); |
527 TInt r = TheFs.DriveToChar(gDrive,driveLetter); |
525 test(r == KErrNone); |
528 test_KErrNone(r); |
526 filePathNew[0] = (TText) driveLetter; |
529 filePathNew[0] = (TText) driveLetter; |
527 |
530 |
528 // create some small files in the source directory |
531 // create some small files in the source directory |
529 // so that there is a combination of small files and one large files |
532 // so that there is a combination of small files and one large files |
530 RFile file; |
533 RFile file; |
531 _LIT(KFileSmall1, "FileSmallOne.txt"); |
534 _LIT(KFileSmall1, "FileSmallOne.txt"); |
532 _LIT(KFileSmall2, "FileSmallTwo.txt"); |
535 _LIT(KFileSmall2, "FileSmallTwo.txt"); |
533 _LIT(KFileSmall3, "FileSmallThree.txt"); |
536 _LIT(KFileSmall3, "FileSmallThree.txt"); |
534 r = file.Create(TheFs, KFileSmall1(), EFileWrite | EFileShareAny); |
537 r = file.Create(TheFs, KFileSmall1(), EFileWrite | EFileShareAny); |
535 test(r == KErrNone); |
538 test_KErrNone(r); |
536 r = file.Write(_L8("1")); |
539 r = file.Write(_L8("1")); |
537 test(r == KErrNone); |
540 test_KErrNone(r); |
538 file.Close(); |
541 file.Close(); |
539 |
542 |
540 r = file.Create(TheFs, KFileSmall2(), EFileWrite | EFileShareAny); |
543 r = file.Create(TheFs, KFileSmall2(), EFileWrite | EFileShareAny); |
541 test(r == KErrNone); |
544 test_KErrNone(r); |
542 r = file.Write(_L8("12")); |
545 r = file.Write(_L8("12")); |
543 test(r == KErrNone); |
546 test_KErrNone(r); |
544 file.Close(); |
547 file.Close(); |
545 |
548 |
546 r = file.Create(TheFs, KFileSmall3(), EFileWrite | EFileShareAny); |
549 r = file.Create(TheFs, KFileSmall3(), EFileWrite | EFileShareAny); |
547 test(r == KErrNone); |
550 test_KErrNone(r); |
548 r = file.Write(_L8("123")); |
551 r = file.Write(_L8("123")); |
549 test(r == KErrNone); |
552 test_KErrNone(r); |
550 file.Close(); |
553 file.Close(); |
551 |
554 |
552 // copy to new directory |
555 // copy to new directory |
553 r = fileMan->Copy(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite); |
556 r = fileMan->Copy(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite); |
554 test(r == KErrNone || r == KErrTooBig); |
557 test_Value(r, r == KErrNone || r == KErrTooBig); |
555 |
558 |
556 |
559 |
557 // check SMALL files have been copied |
560 // check SMALL files have been copied |
558 RDir dir; |
561 RDir dir; |
559 r = dir.Open(TheFs, filePathNew, KEntryAttNormal); |
562 r = dir.Open(TheFs, filePathNew, KEntryAttNormal); |
560 test (r == KErrNone); |
563 test_KErrNone(r); |
561 TEntryArray entryArray; |
564 TEntryArray entryArray; |
562 r = dir.Read(entryArray); |
565 r = dir.Read(entryArray); |
563 test (r == KErrEof); |
566 test_Value(r, r == KErrEof); |
564 test(entryArray.Count() == 3); |
567 test(entryArray.Count() == 3); |
565 dir.Close(); |
568 dir.Close(); |
566 |
569 |
567 // then delete the new directory |
570 // then delete the new directory |
568 r = fileMan->Delete(filePathNew); |
571 r = fileMan->Delete(filePathNew); |
569 test(r == KErrNone); |
572 test_KErrNone(r); |
570 |
573 |
571 |
574 |
572 // attempt to copy to new directory again - this time with an observer |
575 // attempt to copy to new directory again - this time with an observer |
573 fileMan->SetObserver(observer); |
576 fileMan->SetObserver(observer); |
574 r = fileMan->Copy(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite); |
577 r = fileMan->Copy(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite); |
575 test(r == KErrNone || r == KErrTooBig); |
578 test_Value(r, r == KErrNone || r == KErrTooBig); |
576 |
579 |
577 // test that 3 small files were copied and 1 or 2 large files failed to copy |
580 // test that 3 small files were copied and 1 or 2 large files failed to copy |
578 // (For 8 GB disk, the 4GB file is missing) |
581 // (For 8 GB disk, the 4GB file is missing) |
579 test(observer->iNotifyEndedSuccesses == 3); |
582 test(observer->iNotifyEndedSuccesses == 3); |
580 test(observer->iNotifyEndedFailures == 1 || observer->iNotifyEndedFailures == 2); |
583 test(observer->iNotifyEndedFailures == 1 || observer->iNotifyEndedFailures == 2); |
581 |
584 |
582 // check SMALL files have been copied |
585 // check SMALL files have been copied |
583 r = dir.Open(TheFs, filePathNew, KEntryAttNormal); |
586 r = dir.Open(TheFs, filePathNew, KEntryAttNormal); |
584 test (r == KErrNone); |
587 test_KErrNone(r); |
585 r = dir.Read(entryArray); |
588 r = dir.Read(entryArray); |
586 test (r == KErrEof); |
589 test_Value(r, r == KErrEof); |
587 test(entryArray.Count() == 3); |
590 test(entryArray.Count() == 3); |
588 dir.Close(); |
591 dir.Close(); |
589 |
592 |
590 // then delete the new directory |
593 // then delete the new directory |
591 r = fileMan->Delete(filePathNew); |
594 r = fileMan->Delete(filePathNew); |
592 test(r == KErrNone); |
595 test_KErrNone(r); |
593 |
596 |
594 delete observer; |
597 delete observer; |
595 delete fileMan; |
598 delete fileMan; |
596 } |
599 } |
597 |
600 |
667 } |
670 } |
668 |
671 |
669 TInt r; |
672 TInt r; |
670 |
673 |
671 r = TheFs.CharToDrive(gDriveToTest, gDrive); |
674 r = TheFs.CharToDrive(gDriveToTest, gDrive); |
672 test(r==KErrNone); |
675 test_KErrNone(r); |
673 |
676 |
674 #ifdef __MOUNT_RAW_EXT__ |
677 #ifdef __MOUNT_RAW_EXT__ |
675 r=TheFs.FileSystemName(gOldFsName, gDrive); |
678 r=TheFs.FileSystemName(gOldFsName, gDrive); |
676 test(r==KErrNone); |
679 test_KErrNone(r); |
677 |
680 |
678 if (gOldFsName.CompareF(KFATName) != 0) |
681 if (gOldFsName.CompareF(KFATName) != 0) |
679 { |
682 { |
680 test.Printf(_L("Skipping test: Not a FAT drive\n")); |
683 test.Printf(_L("Skipping test: Not a FAT drive\n")); |
681 return; |
684 return; |
682 } |
685 } |
683 |
686 |
684 r = TheFs.AddExtension(KExtName); |
687 r = TheFs.AddExtension(KExtName); |
685 test(r==KErrNone || r==KErrAlreadyExists); |
688 test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
686 r = TheFs.MountExtension(KExtName, gDrive); |
689 r = TheFs.MountExtension(KExtName, gDrive); |
687 test(r==KErrNone || r==KErrAlreadyExists); |
690 test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
688 #endif |
691 #endif |
689 |
692 |
690 TVolumeInfo vi; |
693 TVolumeInfo vi; |
691 test((r = TheFs.Volume(vi, gDrive)) == KErrNone); |
694 test((r = TheFs.Volume(vi, gDrive)) == KErrNone); |
692 test.Printf(_L("vi.iSize = %ld\n"), vi.iSize); |
695 test.Printf(_L("vi.iSize = %ld\n"), vi.iSize); |