sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // N.B. Before running this test on WINS, ensure that the estart.txt file contains sl@0: // nothing but EFAT32 i.e. no EFAT - otherwise the FAT16 file system will be used sl@0: // On target ensure that the FAT32 filesystem is in the ROM instead of the FAT16 file system sl@0: // This test expects the following files to be present before running the test: sl@0: // size name sl@0: // 2147483647 \F32-TST\File2GBMinusOne.txt sl@0: // 2147483648 \F32-TST\File2GB.txt sl@0: // 3221225472 \F32-TST\File3GB.txt sl@0: // 4294967295 \F32-TST\File4GBMinusOne.txt // may be absent on an 8GB disk sl@0: // For verification purposes, Every 4 bytes of each file contains the current position, e.g. sl@0: // 0000: 00 00 00 00 sl@0: // 0004: 04 00 00 00 sl@0: // 0008: 08 00 00 00 sl@0: // .. etc sl@0: // These files can be created using the BigFileWriter tool in f32test/tool sl@0: // If this test is run on the emulator and the __MOUNT_RAW_EXT__ macro is defined (see below) then sl@0: // the T_RAWEXT file system extension will be loaded; this extension allows reading and writing to sl@0: // a windows disk in "raw" format, thus allowing direct access to a windows disk. see f32test/ext/t_rawext sl@0: // for more details. sl@0: // sl@0: // sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include "t_server.h" sl@0: sl@0: sl@0: GLDEF_D RTest test(_L("T_BIGFILE")); sl@0: sl@0: #ifdef __WINS__ sl@0: // enable this macro to mount the RAWEXT.FXT file system extension to test on a particular windows drive sl@0: #define __MOUNT_RAW_EXT__ sl@0: #endif sl@0: sl@0: #ifdef __MOUNT_RAW_EXT__ sl@0: _LIT(KExtName,"RAWEXT"); sl@0: sl@0: _LIT(KFAT32FName,"EFAT32"); sl@0: _LIT(KFATName,"FAT"); sl@0: sl@0: TFullName gOldFsName; sl@0: #endif sl@0: sl@0: TInt gDrive; sl@0: TBool gNTFS=EFalse; sl@0: sl@0: const TUint K1Kb = 1 << 10; sl@0: //const TUint K1Mb = 1 << 20; sl@0: const TUint K1Gb = 1 << 30; sl@0: const TUint K2Gb = 0x80000000; sl@0: const TUint K2GbMinusOne = 0x7FFFFFFF; sl@0: const TUint K3Gb = 0xC0000000; sl@0: const TUint K4GbMinusOne = 0xFFFFFFFF; sl@0: const TUint KPosMask = 0xFFFFFFFC; sl@0: sl@0: //const TUint KBigFileSizeSigned = KMaxTInt32; // 2Gb -1 sl@0: //const TUint KBigFileSizeUnsigned = KMaxTUint32; // 4Gb -1 sl@0: sl@0: const TInt KBufSize = (256 * K1Kb); sl@0: HBufC8* gBuf = NULL; sl@0: TPtr8 gBufPtr(NULL, 0, 0); sl@0: sl@0: sl@0: _LIT(KFile2GBMinusOne, "File2GBMinusOne.txt"); sl@0: _LIT(KFile2GB, "File2GB.txt"); sl@0: _LIT(KFile3GB, "File3GB.txt"); sl@0: _LIT(KFile4GBMinusOne, "File4GBMinusOne.txt"); sl@0: TInt gFilesInDirectory = 4; sl@0: sl@0: sl@0: // return ETrue if the specifiled file is present sl@0: TBool FilePresent(const TDesC& aFileName) sl@0: { sl@0: TEntry entry; sl@0: TInt r = TheFs.Entry(aFileName, entry); sl@0: return (r == KErrNone ? (TBool)ETrue : (TBool)EFalse); sl@0: } sl@0: sl@0: class CFileManObserver : public CBase, public MFileManObserver sl@0: { sl@0: public: sl@0: CFileManObserver(CFileMan* aFileMan); sl@0: sl@0: TControl NotifyFileManStarted(); sl@0: TControl NotifyFileManOperation(); sl@0: TControl NotifyFileManEnded(); sl@0: private: sl@0: CFileMan* iFileMan; sl@0: public: sl@0: TInt iNotifyEndedSuccesses; sl@0: TInt iNotifyEndedFailures; sl@0: }; sl@0: sl@0: CFileManObserver::CFileManObserver(CFileMan* aFileMan) sl@0: { sl@0: __DECLARE_NAME(_S("CFileManObserver")); sl@0: iFileMan=aFileMan; sl@0: } sl@0: sl@0: MFileManObserver::TControl CFileManObserver::NotifyFileManStarted() sl@0: { sl@0: TInt lastError = iFileMan->GetLastError(); sl@0: TFileName fileName = iFileMan->CurrentEntry().iName; sl@0: test.Printf(_L("NotifyFileManStarted(): Error %d File %S\n"),lastError, &fileName); sl@0: return(MFileManObserver::EContinue); sl@0: } sl@0: sl@0: MFileManObserver::TControl CFileManObserver::NotifyFileManOperation() sl@0: { sl@0: TInt lastError = iFileMan->GetLastError(); sl@0: TFileName fileName = iFileMan->CurrentEntry().iName; sl@0: test.Printf(_L("NotifyFileManOperation(): Error %d File %S\n"),lastError, &fileName); sl@0: return(MFileManObserver::EContinue); sl@0: } sl@0: sl@0: MFileManObserver::TControl CFileManObserver::NotifyFileManEnded() sl@0: { sl@0: TInt lastError = iFileMan->GetLastError(); sl@0: TFileName fileName = iFileMan->CurrentEntry().iName; sl@0: test.Printf(_L("NotifyFileManEnded(): Error %d File %S\n"),lastError, &fileName); sl@0: if (lastError == KErrNone) sl@0: iNotifyEndedSuccesses++; sl@0: else sl@0: iNotifyEndedFailures++; sl@0: return(MFileManObserver::EContinue); sl@0: } sl@0: sl@0: sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_BIGFILE-0001 sl@0: //! @SYMTestType CIT sl@0: //! @SYMTestCaseDesc Test that 2GB-1 file can be opened and read sl@0: //! @SYMTestActions Open the file, seek to end-1K and read some data. Verify the results sl@0: //! @SYMTestExpectedResults Should succeed sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void OpenAndRead2GBMinusOne() sl@0: { sl@0: RFile f; sl@0: TEntry entry; sl@0: TUint testSize; sl@0: TUint size; sl@0: TUint testPos; sl@0: TInt r; sl@0: sl@0: TPtr8 bufPtr = gBuf->Des(); sl@0: bufPtr.SetLength(bufPtr.MaxLength()); sl@0: sl@0: const TFileName fname = KFile2GBMinusOne(); sl@0: sl@0: test.Next(_L("2GBMinusOne File: Open")); sl@0: sl@0: r = f.Open(TheFs, fname, EFileRead); sl@0: test(r==KErrNone); sl@0: sl@0: testSize = K2GbMinusOne; sl@0: sl@0: test.Next(_L("2GBMinusOne File: Read")); sl@0: sl@0: r=f.Size((TInt&) size); sl@0: test(r==KErrNone); sl@0: test(size == testSize); sl@0: sl@0: r = TheFs.Entry(fname, entry); sl@0: test(r==KErrNone); sl@0: test ((TUint) entry.iSize == testSize); sl@0: sl@0: // seek to just below 2GB sl@0: testPos = (K2GbMinusOne - K1Kb) & KPosMask; sl@0: r = f.Seek(ESeekStart, (TInt&) testPos); sl@0: test(r==KErrNone); sl@0: sl@0: r = f.Read(bufPtr); sl@0: test(r==KErrNone); sl@0: sl@0: TUint posRead = * ((TUint*) &bufPtr[0]); sl@0: test.Printf(_L("position read %08X, expected %08X\n"), posRead, testPos); sl@0: test(posRead == testPos); sl@0: sl@0: f.Close(); sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_BIGFILE-0002 sl@0: //! @SYMTestType CIT sl@0: //! @SYMTestCaseDesc Test that attempting to open a 2GB file fails sl@0: //! @SYMTestActions Open the file sl@0: //! @SYMTestExpectedResults KErrToBig sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void Open2GB() sl@0: { sl@0: RFile f; sl@0: TEntry entry; sl@0: TUint testSize; sl@0: TInt r; sl@0: sl@0: TPtr8 bufPtr = gBuf->Des(); sl@0: bufPtr.SetLength(bufPtr.MaxLength()); sl@0: sl@0: const TFileName fname = KFile2GB(); sl@0: testSize = K2Gb; sl@0: sl@0: test.Next(_L("2GB File: Test the size with RFs::Entry")); sl@0: r = TheFs.Entry(fname, entry); sl@0: test(r==KErrNone); sl@0: test ((TUint) entry.iSize == testSize); sl@0: sl@0: test.Next(_L("2GB File: Attempt to open (should fail with KErrToBig)")); sl@0: sl@0: r = f.Open(TheFs, fname, EFileRead); sl@0: test(r==KErrTooBig); sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_BIGFILE-0003 sl@0: //! @SYMTestType CIT sl@0: //! @SYMTestCaseDesc Test that attempting to open a 2GB file fails sl@0: //! @SYMTestActions Open the file sl@0: //! @SYMTestExpectedResults KErrToBig sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void Open3GB() sl@0: { sl@0: RFile f; sl@0: TEntry entry; sl@0: TUint testSize; sl@0: TInt r; sl@0: sl@0: TPtr8 bufPtr = gBuf->Des(); sl@0: bufPtr.SetLength(bufPtr.MaxLength()); sl@0: sl@0: const TFileName fname = KFile3GB(); sl@0: testSize = K3Gb; sl@0: sl@0: test.Next(_L("3GB File: Test the size with RFs::Entry")); sl@0: r = TheFs.Entry(fname, entry); sl@0: test(r==KErrNone); sl@0: test ((TUint) entry.iSize == testSize); sl@0: sl@0: test.Next(_L("3GB File: Attempt to open (should fail with KErrToBig)")); sl@0: sl@0: r = f.Open(TheFs, fname, EFileRead); sl@0: test(r==KErrTooBig); sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_BIGFILE-0004 sl@0: //! @SYMTestType CIT sl@0: //! @SYMTestCaseDesc Test that attempting to open a 4GB file fails sl@0: //! @SYMTestActions Open the file sl@0: //! @SYMTestExpectedResults KErrToBig sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void Open4GB() sl@0: { sl@0: RFile f; sl@0: TEntry entry; sl@0: TUint testSize; sl@0: TInt r; sl@0: sl@0: TPtr8 bufPtr = gBuf->Des(); sl@0: bufPtr.SetLength(bufPtr.MaxLength()); sl@0: sl@0: const TFileName fname = KFile4GBMinusOne(); sl@0: testSize = K4GbMinusOne; sl@0: sl@0: test.Next(_L("4GB File: Test the size with RFs::Entry")); sl@0: r = TheFs.Entry(fname, entry); sl@0: sl@0: test(r==KErrNone); sl@0: test ((TUint) entry.iSize == testSize); sl@0: sl@0: test.Next(_L("4GB File: Attempt to open (should fail with KErrToBig)")); sl@0: sl@0: r = f.Open(TheFs, fname, EFileRead); sl@0: test(r==KErrTooBig); sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_BIGFILE-0005 sl@0: //! @SYMTestType CIT sl@0: //! @SYMTestCaseDesc Attempt to append to the end of a 2GB-1 file sl@0: //! @SYMTestActions Open the file, seek to end and write one byte sl@0: //! @SYMTestExpectedResults RFile::Write(0 returns KErrToBig sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void Extend2GBMinusOne() sl@0: { sl@0: RFile f; sl@0: TEntry entry; sl@0: TUint testSize; sl@0: TUint size; sl@0: TUint testPos; sl@0: TInt r; sl@0: sl@0: TPtr8 bufPtr = gBuf->Des(); sl@0: bufPtr.SetLength(bufPtr.MaxLength()); sl@0: sl@0: const TFileName fname = KFile2GBMinusOne(); sl@0: testSize = K2GbMinusOne; sl@0: sl@0: test.Next(_L("2GBMinusOne File: Open")); sl@0: sl@0: r = f.Open(TheFs, fname, EFileRead | EFileWrite); sl@0: test(r==KErrNone); sl@0: sl@0: sl@0: test.Next(_L("2GBMinusOne File: Attempt to extend")); sl@0: sl@0: r=f.Size((TInt&) size); sl@0: test(r==KErrNone); sl@0: test(size == testSize); sl@0: sl@0: r = TheFs.Entry(fname, entry); sl@0: test(r==KErrNone); sl@0: test ((TUint) entry.iSize == testSize); sl@0: sl@0: // seek to end sl@0: testPos = 0; sl@0: r = f.Seek(ESeekEnd, (TInt&) testPos); sl@0: test(r==KErrNone); sl@0: sl@0: bufPtr.SetLength(1); sl@0: r = f.Write(bufPtr); sl@0: test(r==KErrTooBig); sl@0: sl@0: f.Close(); sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_BIGFILE-0006 sl@0: //! @SYMTestType CIT sl@0: //! @SYMTestCaseDesc Check that deleting a large file frees cluster properly sl@0: //! @SYMTestActions Delete the passed file name, call RFs::CheckDisk sl@0: //! On windows, we could run chkdsk utility sl@0: //! @SYMTestExpectedResults RFs::CheckDisk returns success sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void DeleteLargeFile(const TDesC& aFileName) sl@0: { sl@0: test.Next(_L("Delete large file")); sl@0: test.Printf(_L("Deleting %S\n"), &aFileName); sl@0: sl@0: TInt r = TheFs.Delete(aFileName); sl@0: test(r==KErrNone); sl@0: sl@0: CheckDisk(); sl@0: } sl@0: sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_BIGFILE-0007 sl@0: //! @SYMTestType CIT sl@0: //! @SYMTestCaseDesc Check that we can get a valid directory listing of a directory sl@0: //! containing large files using RDir and then CDir sl@0: //! @SYMTestActions Open the directory using RDir and examine the results sl@0: //! On windows, we could run chkdsk utility sl@0: //! @SYMTestExpectedResults The expected number of files should exist with the correct sizes sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void ReadDirectory() sl@0: { sl@0: test.Next(_L("Read a directory containing large files using RDir")); sl@0: sl@0: RDir dir; sl@0: TInt r = dir.Open(TheFs, _L("*.*"), KEntryAttNormal); sl@0: test (r == KErrNone); sl@0: sl@0: TEntryArray entryArray; sl@0: r = dir.Read(entryArray); sl@0: test (r == KErrEof); sl@0: sl@0: test(entryArray.Count() == gFilesInDirectory); sl@0: sl@0: TInt n; sl@0: for (n=0; nCount() == gFilesInDirectory); sl@0: for (n=0; nCount(); n++) sl@0: { sl@0: TEntry entry; sl@0: entry=(*dirList)[n]; sl@0: // test.Printf(_L("#%d: %08X %d %S"), n, entry.iSize, entry.iSize, &entry.iName); sl@0: if (entry.iName.MatchF(KFile2GBMinusOne()) == 0) sl@0: { sl@0: test((TUint) entry.iSize == K2GbMinusOne); sl@0: test(n == 0); // test entry has been sorted correctly (i.e. according to size) sl@0: } sl@0: else if (entry.iName.MatchF(KFile2GB()) == 0) sl@0: { sl@0: test((TUint) entry.iSize == K2Gb); sl@0: test(n == 1); sl@0: } sl@0: else if (entry.iName.MatchF(KFile3GB()) == 0) sl@0: { sl@0: test((TUint) entry.iSize == K3Gb); sl@0: test(n == 2); sl@0: } sl@0: else if (entry.iName.MatchF(KFile4GBMinusOne()) == 0) sl@0: { sl@0: test((TUint) entry.iSize == K4GbMinusOne); sl@0: test(n == 3); sl@0: } sl@0: else sl@0: test(EFalse); sl@0: } sl@0: sl@0: delete dirList; sl@0: sl@0: sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_BIGFILE-0008 sl@0: //! @SYMTestType CIT sl@0: //! @SYMTestCaseDesc Check that we can a move a directory containing large files sl@0: //! Using CFileMan::Move() sl@0: //! @SYMTestActions Use CFileMan::Move() to move files from one directory to another sl@0: //! @SYMTestExpectedResults The files should be moved correctly sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void MoveDirectory() sl@0: { sl@0: test.Next(_L("Move a directory containing large files")); sl@0: sl@0: CFileMan* fileMan = CFileMan::NewL(TheFs); sl@0: test(fileMan != NULL); sl@0: sl@0: TPath filePathOld = gSessionPath; sl@0: filePathOld+= _L("*.*"); sl@0: TPath filePathNew = _L("?:\\TEST\\"); sl@0: TChar driveLetter; sl@0: TInt r=TheFs.DriveToChar(gDrive,driveLetter); sl@0: test(r==KErrNone); sl@0: filePathNew[0] = (TText) driveLetter; sl@0: sl@0: // move to new directory sl@0: r = fileMan->Move(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite); sl@0: test(r == KErrNone); sl@0: sl@0: // then move back again sl@0: r = fileMan->Move(filePathNew, filePathOld); sl@0: test(r == KErrNone); sl@0: sl@0: delete fileMan; sl@0: } sl@0: sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_BIGFILE-0009 sl@0: //! @SYMTestType CIT sl@0: //! @SYMTestCaseDesc Check that we can copy a directory containing large file(s) sl@0: //! Using CFileMan::Copy() sl@0: //! @SYMTestActions Use CFileMan::Copy() to copy files from one directory to another sl@0: //! @SYMTestExpectedResults The files should be copied correctly sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void CopyDirectory() sl@0: { sl@0: test.Next(_L("Copy a directory containing large files")); sl@0: CFileMan* fileMan = CFileMan::NewL(TheFs); sl@0: test(fileMan != NULL); sl@0: sl@0: CFileManObserver* observer = new CFileManObserver(fileMan); sl@0: test(observer != NULL); sl@0: sl@0: TPath filePathOld = gSessionPath; sl@0: filePathOld+= _L("*.*"); sl@0: TPath filePathNew = _L("?:\\TEST\\"); sl@0: TChar driveLetter; sl@0: TInt r = TheFs.DriveToChar(gDrive,driveLetter); sl@0: test(r == KErrNone); sl@0: filePathNew[0] = (TText) driveLetter; sl@0: sl@0: // create some small files in the source directory sl@0: // so that there is a combination of small files and one large files sl@0: RFile file; sl@0: _LIT(KFileSmall1, "FileSmallOne.txt"); sl@0: _LIT(KFileSmall2, "FileSmallTwo.txt"); sl@0: _LIT(KFileSmall3, "FileSmallThree.txt"); sl@0: r = file.Create(TheFs, KFileSmall1(), EFileWrite | EFileShareAny); sl@0: test(r == KErrNone); sl@0: r = file.Write(_L8("1")); sl@0: test(r == KErrNone); sl@0: file.Close(); sl@0: sl@0: r = file.Create(TheFs, KFileSmall2(), EFileWrite | EFileShareAny); sl@0: test(r == KErrNone); sl@0: r = file.Write(_L8("12")); sl@0: test(r == KErrNone); sl@0: file.Close(); sl@0: sl@0: r = file.Create(TheFs, KFileSmall3(), EFileWrite | EFileShareAny); sl@0: test(r == KErrNone); sl@0: r = file.Write(_L8("123")); sl@0: test(r == KErrNone); sl@0: file.Close(); sl@0: sl@0: // copy to new directory sl@0: r = fileMan->Copy(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite); sl@0: test(r == KErrNone || r == KErrTooBig); sl@0: sl@0: sl@0: // check SMALL files have been copied sl@0: RDir dir; sl@0: r = dir.Open(TheFs, filePathNew, KEntryAttNormal); sl@0: test (r == KErrNone); sl@0: TEntryArray entryArray; sl@0: r = dir.Read(entryArray); sl@0: test (r == KErrEof); sl@0: test(entryArray.Count() == 3); sl@0: dir.Close(); sl@0: sl@0: // then delete the new directory sl@0: r = fileMan->Delete(filePathNew); sl@0: test(r == KErrNone); sl@0: sl@0: sl@0: // attempt to copy to new directory again - this time with an observer sl@0: fileMan->SetObserver(observer); sl@0: r = fileMan->Copy(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite); sl@0: test(r == KErrNone || r == KErrTooBig); sl@0: sl@0: // test that 3 small files were copied and 1 or 2 large files failed to copy sl@0: // (For 8 GB disk, the 4GB file is missing) sl@0: test(observer->iNotifyEndedSuccesses == 3); sl@0: test(observer->iNotifyEndedFailures == 1 || observer->iNotifyEndedFailures == 2); sl@0: sl@0: // check SMALL files have been copied sl@0: r = dir.Open(TheFs, filePathNew, KEntryAttNormal); sl@0: test (r == KErrNone); sl@0: r = dir.Read(entryArray); sl@0: test (r == KErrEof); sl@0: test(entryArray.Count() == 3); sl@0: dir.Close(); sl@0: sl@0: // then delete the new directory sl@0: r = fileMan->Delete(filePathNew); sl@0: test(r == KErrNone); sl@0: sl@0: delete observer; sl@0: delete fileMan; sl@0: } sl@0: sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_BIGFILE-000A sl@0: //! @SYMTestType CIT sl@0: //! @SYMTestCaseDesc Check that CDirScan works correctly with a directory containing large file(s) sl@0: //! @SYMTestActions Use CFileMan::Copy() to copy files from one directory to another sl@0: //! @SYMTestExpectedResults The files should be copied correctly sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: TInt ScanDir(const TDesC& aName, CDirScan::TScanDirection aDirection, TInt aError) sl@0: { sl@0: TInt r; sl@0: TFileName dirName; sl@0: sl@0: CDirScan* scanner = NULL; sl@0: TRAP(r, scanner = CDirScan::NewL(TheFs)); sl@0: test(r == KErrNone && scanner); sl@0: sl@0: TRAP(r, scanner->SetScanDataL(aName,KEntryAttDir,ESortByName|EAscending,aDirection)); sl@0: test(r == KErrNone); sl@0: sl@0: CDir *entryList=NULL; sl@0: TInt filesFound = 0; sl@0: for (;;) sl@0: { sl@0: TRAP(r, scanner->NextL(entryList)); sl@0: test(r == aError); sl@0: if (entryList==NULL) sl@0: break; sl@0: TInt count = entryList->Count(); sl@0: while (count--) sl@0: { sl@0: TEntry data=(*entryList)[count]; sl@0: TBuf path=scanner->AbbreviatedPath(); sl@0: dirName = path; sl@0: dirName.Append(data.iName); sl@0: test.Printf(_L(" %S\n"),&dirName); sl@0: filesFound++; sl@0: } sl@0: sl@0: delete entryList; sl@0: entryList=NULL; sl@0: } sl@0: delete scanner; sl@0: sl@0: return filesFound; sl@0: } sl@0: sl@0: sl@0: sl@0: GLDEF_C void CallTestsL() sl@0: // sl@0: // Do tests relative to the session path sl@0: // sl@0: { sl@0: sl@0: #if defined(__WINS__) sl@0: if (gSessionPath[0]=='C') sl@0: gNTFS=ETrue; sl@0: else sl@0: gNTFS=EFalse; sl@0: #endif sl@0: sl@0: // don't test on NTFS sl@0: if (gNTFS) sl@0: { sl@0: test.Printf(_L("Skipping test: Drive is NTFS\n")); sl@0: return; sl@0: } sl@0: sl@0: TInt r; sl@0: sl@0: r = TheFs.CharToDrive(gDriveToTest, gDrive); sl@0: test(r==KErrNone); sl@0: sl@0: #ifdef __MOUNT_RAW_EXT__ sl@0: r=TheFs.FileSystemName(gOldFsName, gDrive); sl@0: test(r==KErrNone); sl@0: sl@0: if (gOldFsName.CompareF(KFATName) != 0) sl@0: { sl@0: test.Printf(_L("Skipping test: Not a FAT drive\n")); sl@0: return; sl@0: } sl@0: sl@0: r = TheFs.AddExtension(KExtName); sl@0: test(r==KErrNone || r==KErrAlreadyExists); sl@0: r = TheFs.MountExtension(KExtName, gDrive); sl@0: test(r==KErrNone || r==KErrAlreadyExists); sl@0: #endif sl@0: sl@0: TVolumeInfo vi; sl@0: test((r = TheFs.Volume(vi, gDrive)) == KErrNone); sl@0: test.Printf(_L("vi.iSize = %ld\n"), vi.iSize); sl@0: sl@0: // don't test if media sise is less than 7GB sl@0: if (vi.iSize < TInt64(K1Gb) * TInt64(7)) sl@0: { sl@0: test.Printf(_L("Skipping test: Drive is not big enough\n")); sl@0: } sl@0: if (!FilePresent(KFile2GB())) sl@0: { sl@0: test.Printf(_L("Skipping test: Test files not present on drive\n")); sl@0: } sl@0: else sl@0: { sl@0: gBuf = HBufC8::NewL(KBufSize); sl@0: if (gBuf == NULL) sl@0: User::Leave(KErrNoMemory); sl@0: gBufPtr = gBuf->Des(); sl@0: sl@0: sl@0: TInt r; sl@0: sl@0: // Test that RFs::CheckDisk() succeeds with large files present sl@0: CheckDisk(); sl@0: sl@0: test.Next(_L("Scan Drive")); sl@0: r = TheFs.ScanDrive(gSessionPath); sl@0: test (r == KErrNone); sl@0: sl@0: // NB the 4GB file will not be present unless the disk is > 8GB (because it doesn't fit) sl@0: if (!FilePresent(KFile4GBMinusOne())) sl@0: gFilesInDirectory--; sl@0: sl@0: // test CDirScan sl@0: // the number of files & directories found should be 5 or 4 sl@0: TInt filesFound = ScanDir(_L("\\"), CDirScan::EScanUpTree, KErrNone); sl@0: test (filesFound == gFilesInDirectory+1); sl@0: filesFound = ScanDir(_L("\\"), CDirScan::EScanDownTree, KErrNone); sl@0: test (filesFound == gFilesInDirectory+1); sl@0: sl@0: OpenAndRead2GBMinusOne(); sl@0: Open2GB(); sl@0: Open3GB(); sl@0: sl@0: // the 4GB file will not be present unless the disk is > 8GB sl@0: if (FilePresent(KFile4GBMinusOne())) sl@0: Open4GB(); sl@0: sl@0: Extend2GBMinusOne(); sl@0: sl@0: ReadDirectory(); sl@0: sl@0: MoveDirectory(); sl@0: sl@0: sl@0: // delete the 2 smaller files to make some space sl@0: DeleteLargeFile(KFile2GB()); sl@0: DeleteLargeFile(KFile2GBMinusOne()); sl@0: sl@0: CopyDirectory(); sl@0: sl@0: // delete the 3GB file and check the disk sl@0: DeleteLargeFile(KFile3GB()); sl@0: sl@0: if (FilePresent(KFile4GBMinusOne())) sl@0: DeleteLargeFile(KFile4GBMinusOne()); sl@0: sl@0: // Finally check that we can format the drive... sl@0: Format (gDrive); sl@0: } sl@0: sl@0: #ifdef __MOUNT_RAW_EXT__ sl@0: r = TheFs.DismountExtension(KExtName, gDrive); sl@0: test(r==KErrNone); sl@0: sl@0: r = TheFs.RemoveExtension(KExtName); sl@0: test(r==KErrNone); sl@0: sl@0: #endif sl@0: sl@0: delete gBuf; gBuf = NULL; sl@0: } sl@0: