sl@0: // Copyright (c) 1996-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: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include "t_server.h" sl@0: #include "t_chlffs.h" sl@0: sl@0: GLDEF_D RTest test(_L("T_FMAN")); sl@0: sl@0: LOCAL_D CFileMan* gFileMan=NULL; sl@0: LOCAL_D TBool gAsynch=EFalse; sl@0: LOCAL_D TRequestStatus gStat; sl@0: LOCAL_D TBool testingInvalidPathLengths; sl@0: sl@0: class CFileManObserver : public CBase, public MFileManObserver sl@0: { sl@0: public: sl@0: CFileManObserver(CFileMan* aFileMan); sl@0: TControl NotifyFileManEnded(); sl@0: private: sl@0: CFileMan* iFileMan; sl@0: }; sl@0: sl@0: LOCAL_D CFileManObserver* gObserver; sl@0: sl@0: CFileManObserver::CFileManObserver(CFileMan* aFileMan) sl@0: // sl@0: // Constructor sl@0: // sl@0: { sl@0: __DECLARE_NAME(_S("CFileManObserver")); sl@0: iFileMan=aFileMan; sl@0: } sl@0: sl@0: MFileManObserver::TControl CFileManObserver::NotifyFileManEnded() sl@0: // sl@0: // Called back after each FMan tick sl@0: // sl@0: { sl@0: TInt lastError=iFileMan->GetLastError(); sl@0: if (lastError!=KErrNone && lastError!=KErrBadName) sl@0: { sl@0: TFileName fileName=iFileMan->CurrentEntry().iName; sl@0: if (gAsynch==EFalse) sl@0: test.Printf(_L("CurrentEntry is %S\n"),&fileName); sl@0: test(lastError==KErrAlreadyExists); sl@0: test(fileName.MatchF(_L("PIPE1.PLP"))!=KErrNotFound || fileName.MatchF(_L("FOUR"))!=KErrNotFound || fileName.MatchF(_L("File*.TXT"))!=KErrNotFound || fileName.MatchF(_L("ah"))!=KErrNotFound || fileName.MatchF(_L("a"))!=KErrNotFound); sl@0: } sl@0: return(MFileManObserver::EContinue); sl@0: } sl@0: sl@0: LOCAL_C void WaitForSuccess() sl@0: // sl@0: // Wait for gStat to complete with KErrNone sl@0: // sl@0: { sl@0: User::WaitForRequest(gStat); sl@0: test(gStat==KErrNone); sl@0: } sl@0: sl@0: LOCAL_C void WaitForResult(TInt aResult) sl@0: // sl@0: // Wait for gStat to complete with aResult sl@0: // sl@0: { sl@0: User::WaitForRequest(gStat); sl@0: test(gStat==aResult); sl@0: } sl@0: sl@0: LOCAL_C void TestResult(TInt aReturnVal, TInt aExpectedAsynchReturnStatus=KErrNone, TInt aExpectedSynchReturn=KErrNone) sl@0: // sl@0: // Test the result, wait for an asynchronous call sl@0: // sl@0: { sl@0: if (!gAsynch) sl@0: test(aReturnVal==aExpectedAsynchReturnStatus); sl@0: else sl@0: { sl@0: test(aReturnVal==aExpectedSynchReturn); sl@0: WaitForResult(aExpectedAsynchReturnStatus); sl@0: } sl@0: } sl@0: sl@0: LOCAL_C void RmDir(const TDesC& aDirName) sl@0: // sl@0: // Remove a directory sl@0: // sl@0: { sl@0: gFileMan->Attribs(aDirName, 0, KEntryAttReadOnly, 0, CFileMan::ERecurse); sl@0: TInt r=gFileMan->RmDir(aDirName); sl@0: test(r==KErrNone || r==KErrNotFound || r==KErrPathNotFound); sl@0: } sl@0: sl@0: LOCAL_C void Compare(const TDesC& aDir1,const TDesC& aDir2) sl@0: // sl@0: // Test that the contents of two directories are identical sl@0: // sl@0: { sl@0: CDirScan* scanDir1=CDirScan::NewL(TheFs); sl@0: scanDir1->SetScanDataL(aDir1,KEntryAttMaskSupported,ESortByName); sl@0: CDirScan* scanDir2=CDirScan::NewL(TheFs); sl@0: scanDir2->SetScanDataL(aDir2,KEntryAttMaskSupported,ESortByName); sl@0: sl@0: FOREVER sl@0: { sl@0: CDir* entryList1; sl@0: CDir* entryList2; sl@0: sl@0: scanDir1->NextL(entryList1); sl@0: scanDir2->NextL(entryList2); sl@0: sl@0: if (entryList1==NULL || entryList2==NULL) sl@0: { sl@0: test(entryList1==NULL && entryList2==NULL); sl@0: break; sl@0: } sl@0: sl@0: TFileName abbPath1=scanDir1->AbbreviatedPath(); sl@0: TFileName abbPath2=scanDir2->AbbreviatedPath(); sl@0: test(abbPath1==abbPath2); sl@0: sl@0: TInt count1=entryList1->Count(); sl@0: TInt count2=entryList2->Count(); sl@0: test(count1==count2); sl@0: sl@0: while(count1--) sl@0: { sl@0: TEntry entry1=(*entryList1)[count1]; sl@0: TEntry entry2=(*entryList2)[count1]; sl@0: test(entry1.iName==entry2.iName); sl@0: test(entry1.iAtt==entry2.iAtt); sl@0: } sl@0: sl@0: delete entryList1; sl@0: delete entryList2; sl@0: } sl@0: sl@0: delete scanDir1; sl@0: delete scanDir2; sl@0: } sl@0: sl@0: LOCAL_C void SetupDirectories(TBool aCreateFiles, TFileName* aDestOtherDrive) sl@0: // sl@0: // Set up a directory structure and files to test copying/moving across drives sl@0: // sl@0: { sl@0: TInt err = KErrNone; sl@0: sl@0: TFileName sourceName = _L("\\F32-TST\\TFMAN\\source\\"); sl@0: TFileName sourceNameSubDir = _L("\\F32-TST\\TFMAN\\source\\subdir\\"); sl@0: TFileName sourceCompare = _L("\\F32-TST\\TFMAN\\compare\\"); sl@0: TFileName sourceCompareSubDir = _L("\\F32-TST\\TFMAN\\compare\\subdir\\"); sl@0: TFileName destSameDrive = _L("\\F32-TST\\TFMAN\\dest\\"); // Target destination on the same drive sl@0: sl@0: if(aDestOtherDrive) sl@0: { sl@0: #if !defined(__WINS__) sl@0: *aDestOtherDrive = gSessionPath[0] == 'C' ? _L("D:\\F32-TST\\TFMAN\\dest\\") : _L("C:\\F32-TST\\TFMAN\\dest\\"); sl@0: #else sl@0: *aDestOtherDrive = gSessionPath[0] == 'C' ? _L("Y:\\F32-TST\\TFMAN\\dest\\") : _L("C:\\F32-TST\\TFMAN\\dest\\"); sl@0: #endif sl@0: err = TheFs.MkDirAll(*aDestOtherDrive); sl@0: test(err == KErrNone || err == KErrAlreadyExists); sl@0: } sl@0: sl@0: err = TheFs.MkDirAll(sourceName); sl@0: test(err == KErrNone || err == KErrAlreadyExists); sl@0: sl@0: err = TheFs.MkDirAll(sourceCompare); sl@0: test(err == KErrNone || err == KErrAlreadyExists); sl@0: sl@0: err = TheFs.MkDirAll(destSameDrive); sl@0: test(err == KErrNone || err == KErrAlreadyExists); sl@0: sl@0: if(aCreateFiles) sl@0: { sl@0: err = TheFs.MkDirAll(sourceNameSubDir); sl@0: test(err == KErrNone || err == KErrAlreadyExists); sl@0: sl@0: err = TheFs.MkDirAll(sourceCompareSubDir); sl@0: test(err == KErrNone || err == KErrAlreadyExists); sl@0: sl@0: for(TInt i=0; i<5; i++) sl@0: { sl@0: // Create a test file to be copied sl@0: TFileName name = sourceName; sl@0: name.Append(_L("File")); sl@0: name.AppendNum(i); sl@0: name.Append(_L(".TXT")); sl@0: sl@0: RFile file; sl@0: err = file.Create(TheFs,name,EFileRead|EFileWrite); sl@0: test(err == KErrNone || err == KErrAlreadyExists); sl@0: file.Close(); sl@0: sl@0: // ...and another to compare against sl@0: name = sourceCompare; sl@0: name.Append(_L("File")); sl@0: name.AppendNum(i); sl@0: name.Append(_L(".TXT")); sl@0: sl@0: err = file.Create(TheFs,name,EFileRead|EFileWrite); sl@0: test(err == KErrNone || err == KErrAlreadyExists); sl@0: file.Close(); sl@0: } sl@0: } sl@0: } sl@0: sl@0: TBool CheckIfShortPathsAreSupported() sl@0: { sl@0: TBool ret = EFalse; sl@0: TBuf<1+8+3+1+4> buf; sl@0: _LIT(KTestFile, "\\longname1\\file"); sl@0: RmDir(_L("\\longname1\\")); sl@0: MakeFile(KTestFile); sl@0: TInt err = TheFs.GetShortName(_L("\\longname1\\"), buf); sl@0: if(err == KErrNone) sl@0: { sl@0: buf.Insert(0, _L("\\")); sl@0: buf.Append(_L("\\file")); sl@0: err = TheFs.Delete(buf); sl@0: test(err == KErrNone); sl@0: ret = ETrue; sl@0: } sl@0: RmDir(_L("\\longname1\\")); sl@0: return ret; sl@0: } sl@0: sl@0: LOCAL_C void TestDelete() sl@0: // sl@0: // Test files are deleted sl@0: // sl@0: { sl@0: test.Next(_L("Test delete - Set up files and start deleting")); sl@0: sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EMPTY\\")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE2.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE3.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\FILE4.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EXE1.BIN")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\EXE2.BIN")); sl@0: sl@0: TInt r; sl@0: // absolute path for code warrior two more than wins (\epoc32\winscw\c vs \epoc32\wins\c) sl@0: #if defined(__WINSCW__) sl@0: _LIT(KLongName1,"\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffd"); sl@0: #else sl@0: _LIT(KLongName1,"\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa"); sl@0: #endif sl@0: sl@0: _LIT(KInvalidLongName,"\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdffdsa23asdffdsa24asdffdsa25asdffdsa"); sl@0: _LIT(KInvalidLongPath, "\\F32-TST\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\0495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\middle.gif"); sl@0: if (testingInvalidPathLengths) sl@0: // Create a path of greater 256 characters by renaming a directory and check it can be sl@0: // manipulated (tests fix to F32) sl@0: { sl@0: // One long directory name - makes paths invalid sl@0: MakeDir(_L("\\TEST\\LONG\\NAME\\ABCDE")); sl@0: MakeDir(_L("\\TEST\\LONG\\NAME\\ABCDE\\DIRECTORY1DIRECTORY2DIRECTORY3DIRECTORY4\\")); sl@0: MakeFile(_L("\\TEST\\LONG\\NAME\\ABCDE\\ELEPHANT01ELEPHANT02ELEPHANT03ELEPHANT04")); sl@0: MakeFile(_L("\\TEST\\LONG\\NAME\\ABCDE\\FILEFILE01FILEFILE02FILEFILE03FILEFILE04")); sl@0: TFileName name1(KLongName1); sl@0: r=gFileMan->Rename(_L("\\TEST\\LONG"),name1,CFileMan::EOverWrite); sl@0: test(r==KErrNone); sl@0: // Two long directory names - makes paths invalid sl@0: MakeDir(_L("\\TEST\\LONG\\NAME\\FGHIJ")); sl@0: MakeDir(_L("\\TEST\\LONG\\NAME\\FGHIJ\\DIRECTORY1DIRECTORY2DIRECTORY3DIRECTORY4\\")); sl@0: MakeFile(_L("\\TEST\\LONG\\NAME\\FGHIJ\\ELEPHANT01ELEPHANT02ELEPHANT03ELEPHANT04")); sl@0: MakeFile(_L("\\TEST\\LONG\\NAME\\FGHIJ\\FILEFILE01FILEFILE02FILEFILE03FILEFILE04")); sl@0: sl@0: // Testing invalid long file name (i.e. >256) sl@0: r=gFileMan->Rename(_L("\\TEST\\LONG"),KInvalidLongName,CFileMan::EOverWrite); sl@0: test(r==KErrBadName); sl@0: sl@0: // Testing invalid long path (i.e. >256) sl@0: r=gFileMan->Rename(_L("\\TEST\\LONG"),KInvalidLongPath,CFileMan::EOverWrite); sl@0: test(r==KErrBadName); sl@0: sl@0: r=gFileMan->Rename(_L("\\TEST\\LONG"),_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds"),CFileMan::EOverWrite); sl@0: test(r==KErrNone); sl@0: } sl@0: sl@0: //testing invalid source path at the beginning: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Delete(_L(":C\\F32-TST\\TFMAN\\DELDIR\\*.TXT")); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Delete(_L(":C\\F32-TST\\TFMAN\\DELDIR\\*.TXT"),0,gStat); sl@0: } sl@0: TestResult(r,KErrBadName,KErrBadName); sl@0: sl@0: //testing invalid source path at the middle: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\:DELDIR\\*.TXT")); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\:DELDIR\\*.TXT"),0,gStat); sl@0: } sl@0: TestResult(r,KErrBadName,KErrNone); sl@0: sl@0: //testing invalid source path at the end: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\DELDIR\\:*.TXT")); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\DELDIR\\:*.TXT"),0,gStat); sl@0: } sl@0: TestResult(r,KErrBadName,KErrNone); sl@0: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\DELDIR\\*.TXT")); sl@0: TestResult(r); sl@0: if (testingInvalidPathLengths) sl@0: { sl@0: TFileName name1(KLongName1); sl@0: name1+=_L("\\NAME\\ABCDE\\*.*"); sl@0: r=gFileMan->Delete(name1); sl@0: test(r==KErrNone); sl@0: sl@0: r=gFileMan->Delete(_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds\\NAME\\FGHIJ\\*.*")); sl@0: test(r==KErrNone); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: gFileMan->Delete(_L("\\F32-TST\\TFMAN\\DELDIR\\*.TXT"),0,gStat); sl@0: WaitForSuccess(); sl@0: if (testingInvalidPathLengths) sl@0: { sl@0: TFileName name1(KLongName1); sl@0: name1+=_L("\\NAME\\ABCDE\\*.*"); sl@0: r=gFileMan->Delete(name1,0,gStat); sl@0: WaitForSuccess(); sl@0: test(r==KErrNone); sl@0: sl@0: r=gFileMan->Delete(_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds\\NAME\\FGHIJ\\*.*"),0,gStat); sl@0: WaitForSuccess(); sl@0: test(r==KErrNone); sl@0: } sl@0: } sl@0: sl@0: test.Next(_L("Check files are deleted")); sl@0: RmDir(_L("\\F32-TST\\TFMAN\\After\\")); sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\AFTER\\DELDIR\\DELTEST\\EMPTY\\")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\DELDIR\\DELTEST\\EXE1.BIN")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\DELDIR\\DELTEST\\FILE4.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\DELDIR\\EXE2.BIN")); sl@0: Compare(_L("\\F32-TST\\TFMAN\\DELDIR\\*"),_L("\\F32-TST\\TFMAN\\AFTER\\DELDIR\\*")); sl@0: sl@0: if (testingInvalidPathLengths) sl@0: { sl@0: r=gFileMan->RmDir(_L("\\TEST\\")); sl@0: test(r==KErrNone); sl@0: } sl@0: sl@0: /** sl@0: Test wild card matching in short file names sl@0: Note this test is only run on FAT file systems as 'short file names' are only sl@0: supported by FAT. sl@0: DEF130113: TTG: sl@0: */ sl@0: TInt theDrive; sl@0: r=TheFs.CharToDrive(gDriveToTest,theDrive); sl@0: test(r==KErrNone); sl@0: TFSName f; sl@0: r = TheFs.FileSystemName(f, theDrive); sl@0: test(r == KErrNone || r == KErrNotFound); sl@0: if (f.FindF(_L("Fat")) == 0 ) sl@0: { sl@0: test.Next(_L("Test wild card matching in short file names")); sl@0: MakeFile(_L("abcdefghi.txt")); sl@0: TInt err = gFileMan->Delete(_L("ABCDEF~*")); sl@0: test(err == KErrNone); sl@0: MakeFile(_L("abcdefghi.txt")); sl@0: err = gFileMan->Delete(_L("ABCDEF~*.TXT")); sl@0: test(err == KErrNone); sl@0: MakeFile(_L("abcdefghi.txt")); sl@0: err = gFileMan->Delete(_L("ABCDEF~*.?XT")); sl@0: test(err == KErrNone); sl@0: MakeFile(_L("abcdefghi.txt")); sl@0: err = gFileMan->Delete(_L("ABCDEF~1.*")); sl@0: test(err == KErrNone); sl@0: } sl@0: } sl@0: sl@0: LOCAL_C void TestCopy() sl@0: // sl@0: // Test copy sl@0: // sl@0: { sl@0: test.Next(_L("Test copy")); sl@0: RmDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\*")); sl@0: sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\")); sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EMPTY\\")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\NewDir\\ABC.DEF")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE2.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE3.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\FILE4.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EXE1.BIN")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\EXE2.BIN")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA1.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA2.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA3.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA4.TXT")); sl@0: sl@0: test.Next(_L("Test copy files to the same directory")); sl@0: TInt r; sl@0: sl@0: if (testingInvalidPathLengths) sl@0: // Create a path of greater than 256 characters by renaming a directory and sl@0: // check it can be manipulated (tests fix to F32) sl@0: { sl@0: MakeDir(_L("\\START\\LONG\\")); sl@0: MakeDir(_L("\\FINISH\\")); sl@0: MakeFile(_L("\\START\\LONG\\ABCDEFGH01ABCDEFGH01ABCDEFGH01ABCDEFGH01.txt")); sl@0: MakeFile(_L("\\START\\LONG\\ELEPHANT01ELEPHANT02ELEPHANT03ELEPHANT04.txt")); sl@0: MakeFile(_L("\\START\\LONG\\DINOSAUR01DINOSAUR02DINOSAUR03DINOSAUR04.txt")); sl@0: MakeFile(_L("\\START\\LONG\\FILEFILE01FILEFILE02FILEFILE03FILEFILE04.txt")); sl@0: r=gFileMan->Rename(_L("\\START\\LONG"),_L("\\START\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff"),CFileMan::EOverWrite); sl@0: test(r==KErrNone); sl@0: MakeDir(_L("\\START\\ASDFFDSA\\")); sl@0: } sl@0: sl@0: //testing invalid source path at the beginning: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Copy(_L(":C:\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Copy(_L(":C:\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0,gStat); sl@0: } sl@0: TestResult(r,KErrBadName,KErrBadName); sl@0: sl@0: //testing invalid target path at the beginning: sl@0: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L(":C:\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L(":C:\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0,gStat); sl@0: } sl@0: TestResult(r,KErrBadName,KErrBadName); sl@0: sl@0: //testing invalid source path at the middle: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\:DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\:DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0,gStat); sl@0: } sl@0: TestResult(r,KErrBadName,KErrNone); sl@0: sl@0: //testing invalid target path at the middle: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\:DELDIR\\rumba?.txt"),0); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\:DELDIR\\rumba?.txt"),0,gStat); sl@0: } sl@0: TestResult(r,KErrBadName,KErrNone); sl@0: sl@0: //testing invalid source path at the end: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\:file?.txt"),_L("\\F32-TST\\TFMAN\\:DELDIR\\rumba?.txt"),0); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\:file?.txt"),_L("\\F32-TST\\TFMAN\\:DELDIR\\rumba?.txt"),0,gStat); sl@0: } sl@0: TestResult(r,KErrBadName,KErrNone); sl@0: sl@0: //testing invalid target path at the end: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\:DELDIR\\:rumba?.txt"),0); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\:DELDIR\\:rumba?.txt"),0,gStat); sl@0: } sl@0: TestResult(r,KErrBadName,KErrNone); sl@0: sl@0: if (!gAsynch) sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0); sl@0: else sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0,gStat); sl@0: TestResult(r,KErrAlreadyExists); sl@0: sl@0: if (!gAsynch) sl@0: r = gFileMan->Delete(_L("\\F32-TST\\TFMAN\\DELDIR\\rumba.txt"),0); sl@0: else sl@0: r = gFileMan->Delete(_L("\\F32-TST\\TFMAN\\DELDIR\\rumba.txt"),0,gStat); sl@0: TestResult(r,KErrNone); sl@0: sl@0: if (!gAsynch) sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\file1.txt"),0); sl@0: else sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\file1.txt"),0,gStat); sl@0: TestResult(r,KErrAlreadyExists); sl@0: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\*.TXT"),_L("\\F32-TST\\TFMAN\\COPYDIR\\")); sl@0: test(r==KErrNone); sl@0: if (testingInvalidPathLengths) sl@0: { sl@0: test.Next(_L("Test invalid length paths")); sl@0: r=gFileMan->Copy(_L("\\START\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\*.*"),_L("\\FINISH\\")); sl@0: test(r==KErrNone); sl@0: r=gFileMan->RmDir(_L("\\START\\")); sl@0: test(r==KErrNone); sl@0: r=gFileMan->RmDir(_L("\\FINISH\\")); sl@0: test(r==KErrNone); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\*.TXT"),_L("\\F32-TST\\TFMAN\\COPYDIR\\"),0,gStat); sl@0: WaitForSuccess(); sl@0: test(r==KErrNone); sl@0: if (testingInvalidPathLengths) sl@0: { sl@0: test.Next(_L("Test invalid length paths (Asynch)")); sl@0: r=gFileMan->Copy(_L("\\START\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\*.*"),_L("\\FINISH\\"),0,gStat); sl@0: WaitForSuccess(); sl@0: test(r==KErrNone); sl@0: r=gFileMan->RmDir(_L("\\START\\"),gStat); sl@0: WaitForSuccess(); sl@0: test(r==KErrNone); sl@0: r=gFileMan->RmDir(_L("\\FINISH\\"),gStat); sl@0: WaitForSuccess(); sl@0: test(r==KErrNone); sl@0: } sl@0: } sl@0: sl@0: if (!gAsynch) sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\NewDir\\*.*"),_L("\\F32-TST\\TFMAN\\COPYDIR\\")); sl@0: else sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\NewDir\\*.*"),_L("\\F32-TST\\TFMAN\\COPYDIR\\"),0,gStat); sl@0: TestResult(r); sl@0: sl@0: test.Next(_L("Check files have been copied")); sl@0: RmDir(_L("\\F32-TST\\TFMAN\\after\\")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FILE1.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FILE2.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FILE3.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\RUMBA1.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\RUMBA2.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\RUMBA3.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\RUMBA4.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\ABC.DEF")); sl@0: Compare(_L("\\F32-TST\\TFMAN\\AFTER\\*"),_L("\\F32-TST\\TFMAN\\COPYDIR\\*")); sl@0: sl@0: TFileName fn = _L("Z:\\TEST\\T_FSRV.CPP"); sl@0: fn[0] = gExeFileName[0]; sl@0: if (!gAsynch) sl@0: r=gFileMan->Copy(fn,_L("\\F32-TST\\TFMAN\\COPYDIR\\")); sl@0: else sl@0: r=gFileMan->Copy(fn,_L("\\F32-TST\\TFMAN\\COPYDIR\\"),0,gStat); sl@0: TestResult(KErrNone); sl@0: sl@0: TEntry entry; sl@0: r=TheFs.Entry(_L("\\F32-TST\\TFMAN\\COPYDIR\\T_FSRV.CPP"),entry); sl@0: test(r==KErrNone); sl@0: test(entry.iName.MatchF(_L("T_FSRV.CPP"))!=KErrNotFound); sl@0: #if defined (__WINS__) sl@0: test(entry.iAtt==KEntryAttArchive); sl@0: #else sl@0: if (!IsTestingLFFS()) sl@0: test(entry.iAtt==KEntryAttReadOnly); sl@0: else sl@0: test(entry.iAtt&KEntryAttReadOnly); // ??? sl@0: #endif sl@0: r=TheFs.SetAtt(_L("\\F32-TST\\TFMAN\\COPYDIR\\T_FSRV.CPP"),0,KEntryAttReadOnly); sl@0: test(r==KErrNone); sl@0: sl@0: r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\AFTER\\RUMBA?.TXT")); sl@0: test(r==KErrNone); sl@0: r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA?.TXT")); sl@0: test(r==KErrNone); sl@0: } sl@0: sl@0: LOCAL_C void TestDEF121663_Setup(TFileName& aSrcPath) sl@0: { sl@0: RmDir(aSrcPath); sl@0: MakeDir(aSrcPath); sl@0: sl@0: for(TInt index=0; index<10; index++) sl@0: { sl@0: TFileName fileName; sl@0: fileName.Copy(aSrcPath); sl@0: fileName.Append(_L("FILE_"));fileName.AppendNum(index);fileName.Append(_L(".TXT")); sl@0: MakeFile(fileName, _L8("Some Data")); sl@0: } sl@0: } sl@0: sl@0: LOCAL_C void TestDEF121663() sl@0: { sl@0: test.Next(_L("Test moving directory to its subdirectory (DEF121663)")); sl@0: sl@0: gFileMan->SetObserver(NULL); sl@0: TInt err = 0; sl@0: TFileName srcPath = _L("C:\\TestDEF121663\\"); sl@0: sl@0: TestDEF121663_Setup(srcPath); sl@0: if(!gAsynch) sl@0: { sl@0: err = gFileMan->Move(_L("C:\\TestDEF121663"),_L("C:\\TestDEF121663\\TestDEF121663"),CFileMan::EOverWrite); sl@0: } sl@0: else sl@0: { sl@0: err = gFileMan->Move(_L("C:\\TestDEF121663"),_L("C:\\TestDEF121663\\TestDEF121663"),CFileMan::EOverWrite, gStat); sl@0: } sl@0: TestResult(err,KErrInUse,KErrInUse); sl@0: sl@0: TestDEF121663_Setup(srcPath); sl@0: if(!gAsynch) sl@0: { sl@0: err = gFileMan->Move(_L("C:\\TestDEF121663\\"),_L("C:\\TestDEF121663\\TestDEF121663\\"),CFileMan::EOverWrite); sl@0: } sl@0: else sl@0: { sl@0: err = gFileMan->Move(_L("C:\\TestDEF121663\\"),_L("C:\\TestDEF121663\\TestDEF121663\\"),CFileMan::EOverWrite, gStat); sl@0: } sl@0: TestResult(err,KErrPathNotFound); sl@0: sl@0: TestDEF121663_Setup(srcPath); sl@0: if(!gAsynch) sl@0: { sl@0: err = gFileMan->Move(_L("C:\\TestDEF121663\\"),_L("C:\\TestDEF121663\\TestDEF121663"),CFileMan::EOverWrite); sl@0: } sl@0: else sl@0: { sl@0: err = gFileMan->Move(_L("C:\\TestDEF121663\\"),_L("C:\\TestDEF121663\\TestDEF121663"),CFileMan::EOverWrite, gStat); sl@0: } sl@0: TestResult(err,KErrPathNotFound); sl@0: sl@0: TestDEF121663_Setup(srcPath); sl@0: if(!gAsynch) sl@0: { sl@0: err = gFileMan->Move(_L("C:\\TestDEF121663"),_L("C:\\TestDEF121663\\TestDEF121663\\"),CFileMan::ERecurse|CFileMan::EOverWrite); sl@0: } sl@0: else sl@0: { sl@0: err = gFileMan->Move(_L("C:\\TestDEF121663"),_L("C:\\TestDEF121663\\TestDEF121663\\"),CFileMan::ERecurse|CFileMan::EOverWrite, gStat); sl@0: } sl@0: TestResult(err,KErrInUse,KErrInUse); sl@0: sl@0: TestDEF121663_Setup(srcPath); sl@0: if(!gAsynch) sl@0: { sl@0: err = gFileMan->Move(_L("C:\\TestDEF121663"),_L("C:\\TestDEF121663\\TestDEF121663"),CFileMan::ERecurse); sl@0: } sl@0: else sl@0: { sl@0: err = gFileMan->Move(_L("C:\\TestDEF121663"),_L("C:\\TestDEF121663\\TestDEF121663"),CFileMan::ERecurse, gStat); sl@0: } sl@0: TestResult(err,KErrInUse,KErrInUse); sl@0: sl@0: gFileMan->SetObserver(gObserver); sl@0: // remove previous dirs sl@0: RmDir(_L("C:\\TestDEF121663\\")); sl@0: } sl@0: sl@0: // Test moving directories where source and target have matching subdirectory structures sl@0: LOCAL_C void TestDEF123575() sl@0: { sl@0: test.Next(_L("Test moving directories with matching subdirectory structures (DEF123575)")); sl@0: TFileName srcPath; sl@0: TFileName destPath; sl@0: TInt err; sl@0: //setup the initial directory structure sl@0: srcPath = _L("\\F32-TST\\DEF123575\\SRCDIR\\CommonDIR\\temp\\temp1.1\\"); sl@0: destPath = _L("\\F32-TST\\DEF123575\\DSTDIR\\CommonDIR\\temp\\temp1.1\\"); sl@0: MakeDir(srcPath); sl@0: MakeDir(destPath); sl@0: MakeFile(_L("\\F32-TST\\DEF123575\\SRCDIR\\CommonDIR\\temp\\temp1.1\\FILE1.TXT")); sl@0: sl@0: srcPath = _L("\\F32-TST\\DEF123575\\SRCDIR\\CommonDIR"); sl@0: destPath = _L("\\F32-TST\\DEF123575\\DSTDIR\\"); sl@0: if(!gAsynch) sl@0: { sl@0: err = gFileMan->Move(srcPath,destPath,CFileMan::EOverWrite); sl@0: } sl@0: else sl@0: { sl@0: err = gFileMan->Move(srcPath,destPath,CFileMan::EOverWrite, gStat); sl@0: } sl@0: TestResult(err,KErrNone,KErrNone); sl@0: sl@0: //test that source directory is empty after move sl@0: MakeDir(_L("\\F32-TST\\DEF123575\\AFTER\\")); sl@0: Compare(_L("\\F32-TST\\DEF123575\\SRCDIR\\*"),_L("\\F32-TST\\DEF123575\\AFTER\\*")); sl@0: //test that the files have been moved to the destination directory sl@0: MakeDir(_L("\\F32-TST\\DEF123575\\AFTER\\CommonDIR\\temp\\temp1.1\\")); sl@0: MakeFile(_L("\\F32-TST\\DEF123575\\AFTER\\CommonDIR\\temp\\temp1.1\\FILE1.TXT")); sl@0: Compare(_L("\\F32-TST\\DEF123575\\DSTDIR\\*"),_L("\\F32-TST\\DEF123575\\AFTER\\*")); sl@0: sl@0: //delete the entire directory structure sl@0: RmDir(_L("\\F32-TST\\DEF123575\\*")); sl@0: } sl@0: sl@0: LOCAL_C void TestDEF125570() sl@0: { sl@0: test.Next(_L("Test move when trg has at least one of the src dirs (DEF125570)")); sl@0: gFileMan->SetObserver(NULL); sl@0: TInt err = KErrNone; sl@0: TFileName srcPath = _L("C:\\TestDEF125570\\src\\"); sl@0: TFileName trgPath = _L("C:\\TestDEF125570\\trg\\"); sl@0: sl@0: // remove previous dirs sl@0: RmDir(srcPath); sl@0: RmDir(trgPath); sl@0: sl@0: //create src sl@0: MakeDir(_L("C:\\TestDEF125570\\src\\DIR1\\")); sl@0: MakeFile(_L("C:\\TestDEF125570\\src\\DIR1\\File1.txt"),_L8("FILE PATH : C:\\TestDEF125570\\SRC\\DIR1\\File1.txt")); sl@0: MakeFile(_L("C:\\TestDEF125570\\src\\DIR1\\File2.txt"),_L8("FILE PATH : C:\\TestDEF125570\\SRC\\DIR1\\File2.txt")); sl@0: MakeDir(_L("C:\\TestDEF125570\\src\\DIR1\\DIR11\\")); sl@0: MakeFile(_L("C:\\TestDEF125570\\src\\DIR1\\DIR11\\File1.txt"),_L8("FILE PATH : C:\\TestDEF125570\\SRC\\DIR1\\DIR11\\File1.txt")); sl@0: MakeFile(_L("C:\\TestDEF125570\\src\\DIR1\\DIR11\\File2.txt"),_L8("FILE PATH : C:\\TestDEF125570\\SRC\\DIR1\\DIR11\\File2.txt")); sl@0: MakeDir(_L("C:\\TestDEF125570\\src\\DIR2\\")); sl@0: MakeFile(_L("C:\\TestDEF125570\\src\\DIR2\\File1.txt"),_L8("FILE PATH : C:\\TestDEF125570\\SRC\\DIR2\\File1.txt")); sl@0: MakeFile(_L("C:\\TestDEF125570\\src\\DIR2\\File2.txt"),_L8("FILE PATH : C:\\TestDEF125570\\SRC\\DIR2\\File2.txt")); sl@0: MakeDir(_L("C:\\TestDEF125570\\src\\DIR2\\DIR12\\")); sl@0: MakeFile(_L("C:\\TestDEF125570\\src\\DIR2\\DIR12\\File1.txt"),_L8("FILE PATH : C:\\TestDEF125570\\SRC\\DIR2\\DIR12\\File1.txt")); sl@0: MakeFile(_L("C:\\TestDEF125570\\src\\DIR2\\DIR12\\File2.txt"),_L8("FILE PATH : C:\\TestDEF125570\\SRC\\DIR2\\DIR12\\File2.txt")); sl@0: sl@0: //trg has at least one of the src subfolders sl@0: MakeDir(_L("C:\\TestDEF125570\\trg\\DIR2\\")); sl@0: MakeFile(_L("C:\\TestDEF125570\\trg\\DIR2\\File1.txt"),_L8("FILE PATH : C:\\TestDEF125570\\TRG\\DIR2\\File1.txt")); sl@0: MakeFile(_L("C:\\TestDEF125570\\trg\\DIR2\\File2.txt"),_L8("FILE PATH : C:\\TestDEF125570\\TRG\\DIR2\\File2.txt")); sl@0: sl@0: if(!gAsynch) sl@0: err = gFileMan->Move(srcPath, trgPath, CFileMan::ERecurse|CFileMan::EOverWrite); sl@0: else sl@0: err = gFileMan->Move(srcPath, trgPath, CFileMan::ERecurse|CFileMan::EOverWrite, gStat); sl@0: TestResult(err); sl@0: gFileMan->SetObserver(gObserver); sl@0: // remove previous dirs sl@0: RmDir(_L("C:\\TestDEF125570\\")); sl@0: } sl@0: sl@0: LOCAL_C void TestDEF130404() sl@0: { sl@0: test.Printf(_L("Test move when the src doesn't fully exist (DEF130404)")); sl@0: sl@0: TInt r = 0; sl@0: TFileName trgPath; sl@0: trgPath.Format(_L("%c:\\TestDEF130404\\Trg\\"), (TUint8)gDriveToTest); sl@0: TFileName srcPath; sl@0: srcPath.Format(_L("C:\\TestDEF130404\\Src\\DIR1\\"), (TUint8)gDriveToTest); sl@0: sl@0: // clean up before testing sl@0: RmDir(srcPath); sl@0: RmDir(trgPath); sl@0: sl@0: MakeDir(srcPath); sl@0: srcPath.Append(_L("NODIR\\*.*")); sl@0: MakeDir(trgPath); sl@0: sl@0: if(!gAsynch) sl@0: r = gFileMan->Move(srcPath, trgPath, 0); sl@0: else sl@0: r = gFileMan->Move(srcPath, trgPath, 0, gStat); sl@0: TestResult(r,KErrPathNotFound); sl@0: sl@0: // clean up before leaving sl@0: trgPath.Format(_L("%c:\\TestDEF130404\\"), (TUint8)gDriveToTest); sl@0: RmDir(trgPath); sl@0: RmDir(_L("C:\\TestDEF130404\\")); sl@0: } sl@0: sl@0: sl@0: /** sl@0: This is to test that moving files to overwrite folders with the same names sl@0: and moving folders (directories) to overwrite files with the same names sl@0: across drives return proper error codes sl@0: */ sl@0: void TestPDEF137716() sl@0: { sl@0: // Do not run tests if we cannot move across different drives sl@0: if (gSessionPath[0]=='C') sl@0: return; sl@0: sl@0: // Move FILE to overwrite FOLDER -------------------------------------------------------- sl@0: test.Next(_L("Test moving files to overwrite folders with the same names")); sl@0: gFileMan->SetObserver(NULL); sl@0: sl@0: _LIT(KFixedTargetTestFolder, "\\PDEF137716\\"); sl@0: _LIT(KFileToDirTargetCreatePath, "\\PDEF137716\\FileToDir_Target\\ITEM\\"); sl@0: _LIT(KFileToDirTargetNameWild, "\\PDEF137716\\FileToDir_Target\\"); sl@0: sl@0: _LIT(KFixedSourceTestFolder, "C:\\PDEF137716\\"); sl@0: _LIT(KFileToDirSourceName, "C:\\PDEF137716\\FileToDir_Source\\ITEM"); sl@0: _LIT(KFileToDirSourceNameWild, "C:\\PDEF137716\\FileToDir_Source\\"); sl@0: sl@0: RmDir(KFixedTargetTestFolder); sl@0: RmDir(KFixedSourceTestFolder); sl@0: MakeDir(KFileToDirTargetCreatePath); sl@0: MakeFile(KFileToDirSourceName); sl@0: TInt err = KErrNone; sl@0: sl@0: if(!gAsynch) sl@0: { sl@0: err = gFileMan->Move(KFileToDirSourceName, KFileToDirTargetNameWild, 0); sl@0: } sl@0: else sl@0: { sl@0: err = gFileMan->Move(KFileToDirSourceName, KFileToDirTargetNameWild, 0, gStat); sl@0: } sl@0: TestResult(err,KErrAccessDenied); sl@0: sl@0: RmDir(KFixedTargetTestFolder); sl@0: RmDir(KFixedSourceTestFolder); sl@0: MakeDir(KFileToDirTargetCreatePath); sl@0: MakeFile(KFileToDirSourceName); sl@0: if(!gAsynch) sl@0: { sl@0: err = gFileMan->Move(KFileToDirSourceName, KFileToDirTargetNameWild, CFileMan::EOverWrite); sl@0: } sl@0: else sl@0: { sl@0: err = gFileMan->Move(KFileToDirSourceName, KFileToDirTargetNameWild, CFileMan::EOverWrite, gStat); sl@0: } sl@0: TestResult(err,KErrAccessDenied); sl@0: sl@0: RmDir(KFixedTargetTestFolder); sl@0: RmDir(KFixedSourceTestFolder); sl@0: MakeDir(KFileToDirTargetCreatePath); sl@0: MakeFile(KFileToDirSourceName); sl@0: if(!gAsynch) sl@0: { sl@0: err = gFileMan->Move(KFileToDirSourceNameWild, KFileToDirTargetNameWild, 0); sl@0: } sl@0: else sl@0: { sl@0: err = gFileMan->Move(KFileToDirSourceNameWild, KFileToDirTargetNameWild, 0, gStat); sl@0: } sl@0: TestResult(err,KErrAccessDenied); sl@0: sl@0: RmDir(KFixedTargetTestFolder); sl@0: RmDir(KFixedSourceTestFolder); sl@0: MakeDir(KFileToDirTargetCreatePath); sl@0: MakeFile(KFileToDirSourceName); sl@0: if(!gAsynch) sl@0: { sl@0: err = gFileMan->Move(KFileToDirSourceNameWild, KFileToDirTargetNameWild, CFileMan::EOverWrite); sl@0: } sl@0: else sl@0: { sl@0: err = gFileMan->Move(KFileToDirSourceNameWild, KFileToDirTargetNameWild, CFileMan::EOverWrite, gStat); sl@0: } sl@0: TestResult(err,KErrAccessDenied); sl@0: sl@0: sl@0: // Move FOLDER to overwrite FILE -------------------------------------------------------- sl@0: test.Next(_L("Test moving folders to overwrite files with the same names")); sl@0: sl@0: _LIT(KDirToFileTargetName, "\\PDEF137716\\DirToFile_Target\\ITEM"); sl@0: _LIT(KDirToFileTargetNameWild, "\\PDEF137716\\DirToFile_Target\\"); sl@0: sl@0: _LIT(KDirToFileSourceName, "C:\\PDEF137716\\DirToFile_Source\\ITEM"); sl@0: _LIT(KDirToFileSourceNameWild, "C:\\PDEF137716\\DirToFile_Source\\"); sl@0: sl@0: _LIT(KDirToFileSourceCreatePath, "C:\\PDEF137716\\DirToFile_Source\\ITEM\\"); sl@0: sl@0: RmDir(KFixedTargetTestFolder); sl@0: RmDir(KFixedSourceTestFolder); sl@0: MakeFile(KDirToFileTargetName); sl@0: MakeDir(KDirToFileSourceCreatePath); sl@0: if(!gAsynch) sl@0: { sl@0: err = gFileMan->Move(KDirToFileSourceName, KDirToFileTargetName, 0); sl@0: } sl@0: else sl@0: { sl@0: err = gFileMan->Move(KDirToFileSourceName, KDirToFileTargetName, 0, gStat); sl@0: } sl@0: TestResult(err,KErrAccessDenied,KErrAccessDenied); sl@0: sl@0: RmDir(KFixedTargetTestFolder); sl@0: RmDir(KFixedSourceTestFolder); sl@0: MakeFile(KDirToFileTargetName); sl@0: MakeDir(KDirToFileSourceCreatePath); sl@0: if(!gAsynch) sl@0: { sl@0: err = gFileMan->Move(KDirToFileSourceName, KDirToFileTargetName, CFileMan::EOverWrite); sl@0: } sl@0: else sl@0: { sl@0: err = gFileMan->Move(KDirToFileSourceName, KDirToFileTargetName, CFileMan::EOverWrite, gStat); sl@0: } sl@0: TestResult(err,KErrAccessDenied,KErrAccessDenied); sl@0: sl@0: RmDir(KFixedTargetTestFolder); sl@0: RmDir(KFixedSourceTestFolder); sl@0: MakeFile(KDirToFileTargetName); sl@0: MakeDir(KDirToFileSourceCreatePath); sl@0: if(!gAsynch) sl@0: { sl@0: err = gFileMan->Move(KDirToFileSourceName, KDirToFileTargetNameWild, 0); sl@0: } sl@0: else sl@0: { sl@0: err = gFileMan->Move(KDirToFileSourceName, KDirToFileTargetNameWild, 0, gStat); sl@0: } sl@0: TestResult(err,KErrAccessDenied,KErrAccessDenied); sl@0: sl@0: RmDir(KFixedTargetTestFolder); sl@0: RmDir(KFixedSourceTestFolder); sl@0: MakeFile(KDirToFileTargetName); sl@0: MakeDir(KDirToFileSourceCreatePath); sl@0: if(!gAsynch) sl@0: { sl@0: err = gFileMan->Move(KDirToFileSourceName, KDirToFileTargetNameWild, CFileMan::EOverWrite); sl@0: } sl@0: else sl@0: { sl@0: err = gFileMan->Move(KDirToFileSourceName, KDirToFileTargetNameWild, CFileMan::EOverWrite, gStat); sl@0: } sl@0: TestResult(err,KErrAccessDenied,KErrAccessDenied); sl@0: sl@0: RmDir(KFixedTargetTestFolder); sl@0: RmDir(KFixedSourceTestFolder); sl@0: MakeFile(KDirToFileTargetName); sl@0: MakeDir(KDirToFileSourceCreatePath); sl@0: err = gFileMan->Move(KDirToFileSourceNameWild, KDirToFileTargetNameWild, 0); sl@0: if(!gAsynch) sl@0: { sl@0: err = gFileMan->Move(KDirToFileSourceNameWild, KDirToFileTargetNameWild, 0); sl@0: } sl@0: else sl@0: { sl@0: err = gFileMan->Move(KDirToFileSourceNameWild, KDirToFileTargetNameWild, 0, gStat); sl@0: } sl@0: TestResult(err,KErrNotFound); sl@0: sl@0: RmDir(KFixedTargetTestFolder); sl@0: RmDir(KFixedSourceTestFolder); sl@0: MakeFile(KDirToFileTargetName); sl@0: MakeDir(KDirToFileSourceCreatePath); sl@0: if(!gAsynch) sl@0: { sl@0: err = gFileMan->Move(KDirToFileSourceNameWild, KDirToFileTargetNameWild, CFileMan::EOverWrite); sl@0: } sl@0: else sl@0: { sl@0: err = gFileMan->Move(KDirToFileSourceNameWild, KDirToFileTargetNameWild, CFileMan::EOverWrite, gStat); sl@0: } sl@0: TestResult(err,KErrNotFound); sl@0: sl@0: RmDir(KFixedTargetTestFolder); sl@0: RmDir(KFixedSourceTestFolder); sl@0: gFileMan->SetObserver(gObserver); sl@0: } sl@0: sl@0: LOCAL_C void TestMove() sl@0: // sl@0: // Test Move sl@0: // sl@0: { sl@0: test.Next(_L("Test move")); sl@0: RmDir(_L("\\F32-TST\\TFMAN\\MOVEDIR\\*")); sl@0: sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\MOVEDIR\\")); sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EMPTY\\")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE2.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE3.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\FILE4.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EXE1.BIN")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\EXE2.BIN")); sl@0: sl@0: TInt r=KErrNone; sl@0: sl@0: if (testingInvalidPathLengths) sl@0: // Create a path of greater 256 characters by renaming a directory and check it can be sl@0: // manipulated (tests fix to F32) sl@0: { sl@0: MakeDir(_L("\\START\\LONG\\")); sl@0: MakeDir(_L("\\FINISH\\")); sl@0: MakeFile(_L("\\START\\LONG\\ABCDEFGH01ABCDEFGH01ABCDEFGH01ABCDEFGH01.txt")); sl@0: MakeFile(_L("\\START\\LONG\\ELEPHANT01ELEPHANT02ELEPHANT03ELEPHANT04.txt")); sl@0: MakeFile(_L("\\START\\LONG\\DINOSAUR01DINOSAUR02DINOSAUR03DINOSAUR04.txt")); sl@0: MakeFile(_L("\\START\\LONG\\FILEFILE01FILEFILE02FILEFILE03FILEFILE04.txt")); sl@0: r=gFileMan->Rename(_L("\\START\\LONG"),_L("\\START\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff"),CFileMan::EOverWrite); sl@0: test(r==KErrNone); sl@0: sl@0: // Two long directory names - makes paths invalid sl@0: MakeDir(_L("\\TEST\\LONG\\NAME\\FGHIJ")); sl@0: MakeDir(_L("\\TEST\\LONG\\NAME\\FGHIJ\\DIRECTORY1DIRECTORY2DIRECTORY3DIRECTORY4\\")); sl@0: MakeFile(_L("\\TEST\\LONG\\NAME\\FGHIJ\\ELEPHANT01ELEPHANT02ELEPHANT03ELEPHANT04")); sl@0: MakeFile(_L("\\TEST\\LONG\\NAME\\FGHIJ\\FILEFILE01FILEFILE02FILEFILE03FILEFILE04")); sl@0: r=gFileMan->Rename(_L("\\TEST\\LONG"),_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds"),CFileMan::EOverWrite); sl@0: test(r==KErrNone); sl@0: sl@0: MakeDir(_L("\\START\\ASDFFDSA\\")); sl@0: } sl@0: sl@0: //testing invalid source path at the beginning: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Move(_L(":C:\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT")); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Move(_L(":C:\\F32-TST\\TFMAN\\DELDIR\\FILE?.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE*.TXT"),0,gStat); sl@0: } sl@0: TestResult(r,KErrBadName,KErrBadName); sl@0: sl@0: //testing invalid target path at the beginning: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),_L(":C:\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT")); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE?.TXT"),_L(":C:\\F32-TST\\TFMAN\\DELDIR\\FILE*.TXT"),0,gStat); sl@0: } sl@0: TestResult(r,KErrBadName,KErrBadName); sl@0: sl@0: //testing invalid source path at the middle: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\:DELDIR\\FILE1.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT")); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\:DELDIR\\FILE?.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE*.TXT"),0,gStat); sl@0: } sl@0: TestResult(r,KErrBadName,KErrNone); sl@0: sl@0: //testing invalid target path at the middle: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),_L("\\F32-TST\\TFMAN\\:DELDIR\\FILE1.TXT")); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE?.TXT"),_L("\\F32-TST\\TFMAN\\:DELDIR\\FILE*.TXT"),0,gStat); sl@0: } sl@0: TestResult(r,KErrBadName,KErrNone); sl@0: sl@0: //testing invalid source path at the end: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\:FILE1.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT")); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\:FILE?.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE*.TXT"),0,gStat); sl@0: } sl@0: TestResult(r,KErrBadName,KErrNone); sl@0: sl@0: //testing invalid target path at the end: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\:FILE1.TXT")); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE?.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\:FILE*.TXT"),0,gStat); sl@0: } sl@0: TestResult(r,KErrBadName,KErrNone); sl@0: sl@0: sl@0: if (!gAsynch) sl@0: r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE?.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE*.TXT")); sl@0: else sl@0: r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE?.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE*.TXT"),0,gStat); sl@0: TestResult(r,KErrNone); sl@0: sl@0: if ((!gAsynch)&&(testingInvalidPathLengths)) sl@0: { sl@0: r=gFileMan->Move(_L("\\START\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\*.*"),_L("\\FINISH\\")); sl@0: test(r==KErrNone); sl@0: sl@0: r=gFileMan->Move(_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds\\*.*"),_L("\\FINISH\\"), CFileMan::EOverWrite | CFileMan::ERecurse); sl@0: test(r==KErrNone); sl@0: sl@0: r=gFileMan->RmDir(_L("\\START\\")); sl@0: test(r==KErrNone); sl@0: r=gFileMan->RmDir(_L("\\FINISH\\")); sl@0: test(r==KErrNone); sl@0: } sl@0: if ((gAsynch)&&(testingInvalidPathLengths)) sl@0: { sl@0: r=gFileMan->Move(_L("\\START\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\*.*"),_L("\\FINISH\\"),CFileMan::EOverWrite,gStat); sl@0: User::WaitForRequest(gStat); sl@0: test(r==KErrNone); sl@0: r=gFileMan->Move(_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds\\*.*"),_L("\\FINISH\\"), CFileMan::EOverWrite | CFileMan::ERecurse,gStat); sl@0: User::WaitForRequest(gStat); sl@0: test(r==KErrNone); sl@0: r=gFileMan->RmDir(_L("\\START\\"),gStat); sl@0: WaitForSuccess(); sl@0: test(r==KErrNone); sl@0: r=gFileMan->RmDir(_L("\\FINISH\\"),gStat); sl@0: WaitForSuccess(); sl@0: test(r==KErrNone); sl@0: } sl@0: sl@0: if (!gAsynch) sl@0: r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT")); sl@0: else sl@0: r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),0,gStat); sl@0: TestResult(r,KErrNone); sl@0: sl@0: if (!gAsynch) sl@0: r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\*.TXT"),_L("\\F32-TST\\TFMAN\\MOVEDIR\\")); sl@0: else sl@0: r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\*.TXT"),_L("\\F32-TST\\TFMAN\\MOVEDIR\\"),0,gStat); sl@0: TestResult(r); sl@0: sl@0: if (!gAsynch) sl@0: r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\*.TXT"),_L("\\F32-TST\\TFMAN\\MoveDIR.\\FILE*.TXT")); sl@0: else sl@0: r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\*.TXT"),_L("\\F32-TST\\TFMAN\\MoveDIR\\FILE*.TXT"),0,gStat); sl@0: TestResult(r,KErrNotFound); sl@0: sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT")); sl@0: if (!gAsynch) sl@0: r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),_L("\\F32-TST\\TFMAN\\MoveDIR\\FILE1.TXT"),0); sl@0: else sl@0: r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),_L("\\F32-TST\\TFMAN\\MoveDIR\\FILE1.TXT"),0,gStat); sl@0: TestResult(r,KErrAlreadyExists); sl@0: r=TheFs.Delete(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT")); sl@0: test(r==KErrNone); sl@0: sl@0: test.Next(_L("Check files have been moved")); sl@0: RmDir(_L("\\F32-TST\\TFMAN\\AFTER\\*")); sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\AFTER\\DELTEST\\EMPTY\\")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\DELTEST\\FILE4.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\DELTEST\\EXE1.BIN")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\EXE2.BIN")); sl@0: Compare(_L("\\F32-TST\\TFMAN\\AFTER\\*"),_L("\\F32-TST\\TFMAN\\DELDIR\\*")); sl@0: sl@0: RmDir(_L("\\F32-TST\\TFMAN\\AFTER\\*")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FILE1.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FILE2.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FILE3.TXT")); sl@0: Compare(_L("\\F32-TST\\TFMAN\\AFTER\\*"),_L("\\F32-TST\\TFMAN\\MOVEDIR\\*")); sl@0: sl@0: if (testingInvalidPathLengths) sl@0: { sl@0: r=gFileMan->RmDir(_L("\\TEST\\")); sl@0: test(r==KErrNone); sl@0: } sl@0: sl@0: TestDEF121663(); // Test moving directory to its subdirectory sl@0: TestDEF123575(); // Test moving directories where src and trg have matching subdirectory structures sl@0: TestDEF125570(); // Test move when trg has at least one of the src dirs sl@0: TestDEF130404(); // Test move when the src doesn't fully exist sl@0: if (!IsTestingLFFS()) sl@0: TestPDEF137716(); // Test moving files to overwrite folders that have the same names sl@0: } sl@0: sl@0: LOCAL_C void TestSimultaneous() sl@0: // sl@0: // Create and run two CFileMen simultaneously sl@0: // sl@0: { sl@0: test.Next(_L("Test create and run two CFileMans simultaneously")); sl@0: RmDir(_L("\\F32-TST\\TFMAN\\fman2\\")); sl@0: sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\FMAN1\\")); sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\FMAN2\\")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\FMAN1\\ROD.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\FMAN1\\JANE.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\FMAN1\\FREDDY.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\FMAN2\\BORIS.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\FMAN2\\FREDRICK.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\FMAN2\\PETER.TXT")); sl@0: sl@0: CFileMan* fman=CFileMan::NewL(TheFs); sl@0: TRequestStatus stat1; sl@0: TInt r=fman->Delete(_L("\\F32-TST\\TFMAN\\FMAN1\\*.*"),0,stat1); sl@0: test(r==KErrNone); sl@0: r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\FMAN2\\*.TXT"),_L("\\F32-TST\\TFMAN\\FMAN2\\*.EXT"),0,gStat); sl@0: test(r==KErrNone); sl@0: FOREVER sl@0: { sl@0: if (stat1!=KRequestPending && gStat!=KRequestPending) sl@0: break; sl@0: User::WaitForAnyRequest(); sl@0: } sl@0: test(stat1==KErrNone && gStat==KErrNone); sl@0: delete fman; sl@0: sl@0: test.Next(_L("Check all files")); sl@0: RmDir(_L("\\F32-TST\\TFMAN\\AFTER\\*")); sl@0: sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\AFTER\\")); sl@0: Compare(_L("\\F32-TST\\TFMAN\\After\\*"),_L("\\F32-TST\\TFMAN\\FMAN1\\*")); sl@0: sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\BORIS.EXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FREDRICK.EXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\PETER.EXT")); sl@0: Compare(_L("\\F32-TST\\TFMAN\\After\\*"),_L("\\F32-TST\\TFMAN\\FMAN2\\*")); sl@0: } sl@0: sl@0: // Test wildcards are replaced with letters from the matched file (CFileMan::CreateTargetNameFromSource) sl@0: LOCAL_C void TestDEF092084() sl@0: { sl@0: if(gAsynch) sl@0: { sl@0: return; sl@0: } sl@0: test.Next(_L("Test wildcards are replaced with letters from the matched file (DEF092084)")); sl@0: MakeDir(_L("\\DEF092084")); sl@0: MakeFile(_L("\\DEF092084\\FILE1.TXT")); sl@0: sl@0: TInt r = gFileMan->Rename(_L("\\DEF092084\\*.TXT"),_L("\\DEF092084\\*.DDB"), CFileMan::EOverWrite); sl@0: test(r==KErrNone); sl@0: CheckFileExists(_L("\\DEF092084\\FILE1.DDB"), KErrNone); sl@0: sl@0: r = gFileMan->Rename(_L("\\DEF092084\\?*.DD?"),_L("\\DEF092084\\?*.TXT"), CFileMan::EOverWrite); sl@0: test(r==KErrNone); sl@0: CheckFileExists(_L("\\DEF092084\\FILE1.TXT"), KErrNone); sl@0: sl@0: RmDir(_L("\\DEF092084\\")); sl@0: } sl@0: sl@0: //--------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_FMAN-0542 sl@0: //! @SYMTestType UT sl@0: //! @SYMREQ INC109754 sl@0: //! @SYMTestCaseDesc 1. Tests that CFileMan::Rename() does not incorrectly remove empty source directory sl@0: //! @SYMTestActions Renames the only file from source directory to target directory, then check if sl@0: //! the empty source directory still exists. sl@0: //! 2. Tests the trailing backslash ("\") is interpreted to ("\*.*"). sl@0: //! @SYMTestExpectedResults The operation completes with error code KErrNone; sl@0: //! The empty source directory still exists. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //--------------------------------------------- sl@0: void TestINC109754() sl@0: { sl@0: test.Next(_L("Test empty source directory should exist after contents being renamed (INC109754)")); sl@0: TInt r = KErrNone; sl@0: // Setting up comparing dir sl@0: RmDir( _L("\\F32-TST\\TFMAN\\INC109754_C\\")); sl@0: MakeDir( _L("\\F32-TST\\TFMAN\\INC109754_C\\SRC\\")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC109754_C\\TRG\\FILE.TXT")); sl@0: sl@0: // Setting up testing dir sl@0: RmDir( _L("\\F32-TST\\TFMAN\\INC109754\\")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC109754\\SRC\\FILE.TXT")); sl@0: MakeDir( _L("\\F32-TST\\TFMAN\\INC109754\\TRG\\")); sl@0: sl@0: // Test case 1: CFileMan::Rename(_L("C:\\SRC\\"), _L("C:\\TRG\\")); sl@0: if (!gAsynch) sl@0: r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\INC109754\\SRC\\"),_L("\\F32-TST\\TFMAN\\INC109754\\TRG\\")); sl@0: else sl@0: r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\INC109754\\SRC\\"),_L("\\F32-TST\\TFMAN\\INC109754\\TRG\\"),0,gStat); sl@0: TestResult(r); sl@0: Compare(_L("\\F32-TST\\TFMAN\\INC109754\\"), _L("\\F32-TST\\TFMAN\\INC109754_C\\")); sl@0: sl@0: // Setting up testing dir sl@0: RmDir( _L("\\F32-TST\\TFMAN\\INC109754\\")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC109754\\SRC\\FILE.TXT")); sl@0: MakeDir( _L("\\F32-TST\\TFMAN\\INC109754\\TRG\\")); sl@0: sl@0: // Test case 2: CFileMan::Rename(_L("C:\\SRC\\*.*"), _L("C:\\TRG\\")); sl@0: if (!gAsynch) sl@0: r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\INC109754\\SRC\\*.*"),_L("\\F32-TST\\TFMAN\\INC109754\\TRG\\")); sl@0: else sl@0: r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\INC109754\\SRC\\*.*"),_L("\\F32-TST\\TFMAN\\INC109754\\TRG\\"),0,gStat); sl@0: TestResult(r); sl@0: Compare(_L("\\F32-TST\\TFMAN\\INC109754\\"), _L("\\F32-TST\\TFMAN\\INC109754_C\\")); sl@0: } sl@0: sl@0: sl@0: /* sl@0: Test code for INC111038() and executed with Cache enabled and FS_NOT_RUGGED. sl@0: */ sl@0: LOCAL_C void TestINC111038() sl@0: { sl@0: TInt r; sl@0: test.Next(_L("Test example of incorrect attribute flushing")); sl@0: sl@0: _LIT(KTestFile, "\\TESTFILE.TXT"); sl@0: sl@0: test.Printf(_L("1: Create Test File\n")); sl@0: RFile testFile; sl@0: r = testFile.Create(TheFs, KTestFile, EFileRead | EFileWrite); sl@0: test(r == KErrNone); sl@0: sl@0: test.Printf(_L("2: Populate testFile1 Data\n")); sl@0: r = testFile.Write(_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ")); sl@0: test(r == KErrNone); sl@0: sl@0: test.Printf(_L("3: Get Initial Attributes\n")); sl@0: TUint atts = 0; sl@0: r = testFile.Att(atts); sl@0: test(r == KErrNone); sl@0: test.Printf(_L(" Attributes: %08x"), atts); sl@0: sl@0: test.Printf(_L("4: Set KEntryAttHidden Attribute\n")); sl@0: r = testFile.SetAtt(KEntryAttHidden, 0); sl@0: test(r == KErrNone); sl@0: sl@0: test.Printf(_L("5: Verify KEntryAttHidden Attribute is set for testFile1\n")); sl@0: r = testFile.Att(atts); sl@0: test(r == KErrNone); sl@0: test(atts & KEntryAttHidden); sl@0: sl@0: test.Printf(_L("6: Read Data from beginning of file testFile1\n")); sl@0: TBuf8<4> data; sl@0: r = testFile.Read(0, data); sl@0: test(r == KErrNone); sl@0: sl@0: test.Printf(_L("7: Close all the testFiles\n")); sl@0: testFile.Close(); sl@0: sl@0: test.Printf(_L("8: Verify KEntryAttHidden is present\n")); sl@0: r = TheFs.Att(KTestFile, atts); sl@0: test(r == KErrNone); sl@0: test.Printf(_L(" Finally, attributes are : %08x\n"), atts); sl@0: test(atts & KEntryAttHidden); sl@0: sl@0: test.Printf(_L("9: Delete Test File\n")); sl@0: r = TheFs.Delete(KTestFile); sl@0: test(r == KErrNone || r == KErrNotFound); sl@0: } sl@0: sl@0: LOCAL_C void TestDEF113299() sl@0: { sl@0: test.Next(_L("Test invalid file rename (DEF113299)")); sl@0: sl@0: TInt err =0; sl@0: TFileName srcFileName = _L("C:\\F32-TST\\TFMAN\\DEF113299\\src\\corner.html"); sl@0: TFileName trgFileName = _L("C:\\F32-TST\\TFMAN\\DEF113299\\src\\mi?d**dle.html"); sl@0: TFileName trgInvalidFileName = _L("C:\\F32-TST\\TFMAN\\DEF113299\\src\\mi?d**dle>.html"); // Invalid filename sl@0: TFileName renamedFileName = _L("C:\\F32-TST\\TFMAN\\DEF113299\\src\\mirderdle.html"); sl@0: sl@0: RmDir(_L("C:\\F32-TST\\TFMAN\\DEF113299\\")); sl@0: MakeFile(srcFileName,_L8("Test Data")); sl@0: sl@0: // Renaming a file with invalid special characters should fail with error code KErrBadName(-28) sl@0: if (!gAsynch) sl@0: err = gFileMan->Rename(srcFileName,trgInvalidFileName); sl@0: else sl@0: err = gFileMan->Rename(srcFileName,trgInvalidFileName, 0, gStat); sl@0: TestResult(err,KErrBadName); sl@0: sl@0: if(!gAsynch) sl@0: err = gFileMan->Rename(srcFileName,trgFileName); sl@0: else sl@0: err = gFileMan->Rename(srcFileName,trgFileName, 0, gStat); sl@0: TestResult(err,KErrNone); sl@0: sl@0: CheckFileExists(renamedFileName,KErrNone,ETrue); sl@0: } sl@0: sl@0: LOCAL_C void TestRename() sl@0: // sl@0: // Test rename with wildcards sl@0: // sl@0: { sl@0: test.Next(_L("Test rename with wildcards")); sl@0: RmDir(_L("\\F32-TST\\TFMAN\\rename\\dest\\")); sl@0: sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\")); sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\DirTest\\")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\abcDEF.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\abxx.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\HELLO.SPG")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\SHEET1.SPR")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\DirTest.TXT\\Unchanged.txt")); sl@0: sl@0: TInt r; sl@0: sl@0: if (testingInvalidPathLengths) sl@0: // Create a path of greater 256 characters by renaming a directory and check it can be sl@0: // manipulated (tests fix to F32) sl@0: { sl@0: MakeDir(_L("\\LONGNAME\\")); sl@0: MakeDir(_L("\\LONGNAME\\DIRECTORY1DIRECTORY2DIRECTORY3DIRECTORY4\\")); sl@0: MakeFile(_L("\\LONGNAME\\ELEPHANT01ELEPHANT02ELEPHANT03ELEPHANT04.txt")); sl@0: MakeFile(_L("\\LONGNAME\\DINOSAUR01DINOSAUR02DINOSAUR03DINOSAUR04.txt")); sl@0: MakeFile(_L("\\LONGNAME\\FILEFILE01FILEFILE02FILEFILE03FILEFILE04.bin")); sl@0: r=gFileMan->Rename(_L("\\LONGNAME"),_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff"),CFileMan::EOverWrite); sl@0: test(r==KErrNone); sl@0: sl@0: // Two long directory names - makes paths invalid sl@0: MakeDir(_L("\\TEST\\LONG\\NAME\\FGHIJ")); sl@0: MakeDir(_L("\\TEST\\LONG\\NAME\\FGHIJ\\DIRECTORY1DIRECTORY2DIRECTORY3DIRECTORY4\\")); sl@0: MakeFile(_L("\\TEST\\LONG\\NAME\\FGHIJ\\ELEPHANT01ELEPHANT02ELEPHANT03ELEPHANT.txt")); sl@0: MakeFile(_L("\\TEST\\LONG\\NAME\\FGHIJ\\FILEFILE01FILEFILE02FILEFILE03FILEFILE.txt")); sl@0: r=gFileMan->Rename(_L("\\TEST\\LONG"),_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds"),CFileMan::EOverWrite); sl@0: test(r==KErrNone); sl@0: } sl@0: sl@0: //testing invalid source path at the beginning: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Rename(_L("::C\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Rename(_L("::C\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite,gStat); sl@0: } sl@0: TestResult(r,KErrBadName,KErrBadName); sl@0: sl@0: //testing invalid target path at the beginning: sl@0: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("::C\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("::C\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite,gStat); sl@0: } sl@0: TestResult(r,KErrBadName,KErrBadName); sl@0: sl@0: //testing invalid source path at the middle: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\:RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\:RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite,gStat); sl@0: } sl@0: TestResult(r,KErrBadName,KErrNone); sl@0: sl@0: //testing invalid target path at the middle: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\:RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\:RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite,gStat); sl@0: } sl@0: TestResult(r,KErrBadName,KErrNone); sl@0: sl@0: //testing invalid source path at the end: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\:*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\:*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite,gStat); sl@0: } sl@0: TestResult(r,KErrBadName,KErrNone); sl@0: sl@0: //testing invalid target path at the end: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\:*.DDB"),CFileMan::EOverWrite); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\:*.DDB"),CFileMan::EOverWrite,gStat); sl@0: } sl@0: TestResult(r,KErrBadName,KErrNone); sl@0: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite); sl@0: test(r==KErrNone); sl@0: if (testingInvalidPathLengths) sl@0: { sl@0: r=gFileMan->Rename(_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\elephant01elephant02elephant03elephant04.txt"),_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\elephant01elephant02elephant03elephant04.bin")); sl@0: test(r==KErrBadName); sl@0: r=gFileMan->Rename(_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff"),_L("\\Shortened"),CFileMan::EOverWrite); sl@0: test(r==KErrNone); sl@0: r=gFileMan->Rename(_L("\\Shortened\\*.txt"),_L("\\Shortened\\*.cat")); sl@0: test(r==KErrNone); sl@0: r=gFileMan->RmDir(_L("\\Shortened\\")); sl@0: test(r==KErrNone); sl@0: sl@0: r=gFileMan->Rename(_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds"),_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\NotSoShortened"),CFileMan::EOverWrite); sl@0: test(r==KErrNone); sl@0: r=gFileMan->Rename(_L("\\TEST"),_L("\\OXO!")); sl@0: test(r==KErrNone); sl@0: r=gFileMan->Rename(_L("\\OXO!\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as"),_L("\\OXO!\\Shorter")); sl@0: test(r==KErrNone); sl@0: r=gFileMan->Rename(_L("\\OXO!\\Shorter\\NotSoShortened\\NAME\\FGHIJ\\*.txt"),_L("\\TEST\\Shorter\\NotSoShortened\\NAME\\FGHIJ\\*.cat")); sl@0: test(r==KErrNone); sl@0: r=gFileMan->RmDir(_L("\\OXO!\\")); sl@0: test(r==KErrNone); sl@0: sl@0: } sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite,gStat); sl@0: WaitForSuccess(); sl@0: if (testingInvalidPathLengths) sl@0: { sl@0: r=gFileMan->Rename(_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\elephant01elephant02elephant03elephant04.txt"),_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\elephant01elephant02elephant03elephant04.bin")); sl@0: test(r==KErrBadName); sl@0: r=gFileMan->Rename(_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff"),_L("\\Shortened"),CFileMan::EOverWrite,gStat); sl@0: WaitForSuccess(); sl@0: r=gFileMan->Rename(_L("\\Shortened\\*.txt"),_L("\\Shortened\\*.bin"),0,gStat); sl@0: WaitForSuccess(); sl@0: r=gFileMan->RmDir(_L("\\Shortened\\"),gStat); sl@0: WaitForSuccess(); sl@0: sl@0: r=gFileMan->Rename(_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds"),_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\NotSoShortened"),CFileMan::EOverWrite,gStat); sl@0: WaitForSuccess(); sl@0: test(r==KErrNone); sl@0: r=gFileMan->Rename(_L("\\TEST"),_L("\\OXO!"),CFileMan::EOverWrite,gStat); sl@0: WaitForSuccess(); sl@0: test(r==KErrNone); sl@0: r=gFileMan->Rename(_L("\\OXO!\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as"),_L("\\OXO!\\Shorter"),CFileMan::EOverWrite,gStat); sl@0: WaitForSuccess(); sl@0: test(r==KErrNone); sl@0: r=gFileMan->Rename(_L("\\OXO!\\Shorter\\NotSoShortened\\NAME\\FGHIJ\\*.txt"),_L("\\TEST\\Shorter\\NotSoShortened\\NAME\\FGHIJ\\*.cat"),CFileMan::EOverWrite,gStat); sl@0: WaitForSuccess(); sl@0: test(r==KErrNone); sl@0: r=gFileMan->RmDir(_L("\\OXO!\\")); sl@0: test(r==KErrNone); sl@0: r=gFileMan->RmDir(_L("\\TEST\\")); sl@0: test(r==KErrNone); sl@0: } sl@0: } sl@0: RmDir(_L("\\F32-TST\\TFMAN\\after\\")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\abcDEF.DDB")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\abxx.DDB")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\DirTest.DDB\\Unchanged.txt")); sl@0: Compare(_L("\\F32-TST\\TFMAN\\AFTER\\*"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*")); sl@0: sl@0: RmDir(_L("\\F32-TST\\TFMAN\\after\\")); sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\AFTER\\DirTest\\")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\HELLO.SPG")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\SHEET1.SPR")); sl@0: Compare(_L("\\F32-TST\\TFMAN\\AFTER\\*"),_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*")); sl@0: sl@0: if (!gAsynch) sl@0: r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.TXT")); sl@0: else sl@0: r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.TXT"),0,gStat); sl@0: TestResult(r); sl@0: sl@0: RmDir(_L("\\F32-TST\\TFMAN\\after\\")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\abcDEF.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\abxx.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\DirTest.TXT\\Unchanged.txt")); sl@0: Compare(_L("\\F32-TST\\TFMAN\\AFTER\\*"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*")); sl@0: sl@0: test.Next(_L("Test rename case of filenames")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\CASETEST\\FileName1")); sl@0: sl@0: if (!gAsynch) sl@0: r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\CASETEST\\FileName1"),_L("\\F32-TST\\TFMAN\\CASETEST\\FILENAME1")); sl@0: else sl@0: r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\CASETEST\\FileName1"),_L("\\F32-TST\\TFMAN\\CASETEST\\FILENAME1"),0,gStat); sl@0: TestResult(r); sl@0: CheckFileExists(_L("\\F32-TST\\TFMAN\\CASETEST\\FileName1"),KErrNone,EFalse); sl@0: CheckFileExists(_L("\\F32-TST\\TFMAN\\CASETEST\\FILENAME1"),KErrNone,ETrue); sl@0: sl@0: if (!gAsynch) sl@0: r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\CASETEST\\FILENAME1"),_L("\\F32-TST\\TFMAN\\CASETEST\\FILENAME1"),CFileMan::EOverWrite); sl@0: else sl@0: r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\CASETEST\\FILENAME1"),_L("\\F32-TST\\TFMAN\\CASETEST\\FILENAME1"),CFileMan::EOverWrite,gStat); sl@0: TestResult(r); sl@0: CheckFileExists(_L("\\F32-TST\\TFMAN\\CASETEST\\FILENAME1"),KErrNone,ETrue); sl@0: sl@0: // Test behaviour for omitted parameters sl@0: // For this, default should be session path sl@0: TFileName sessionPath; sl@0: TInt err=TheFs.SessionPath(sessionPath); sl@0: test(err==KErrNone); sl@0: sl@0: SetupDirectories(ETrue, NULL); sl@0: err=TheFs.SetSessionPath(_L("\\F32-TST\\TFMAN\\dest\\")); sl@0: test(err == KErrNone); sl@0: sl@0: err = gFileMan->Rename(_L("\\F32-TST\\TFMAN\\source"), _L("")); sl@0: test(err == KErrNone); sl@0: Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), _L("\\F32-TST\\TFMAN\\dest\\source\\*")); sl@0: sl@0: RmDir(_L("\\F32-TST\\TFMAN\\dest\\")); sl@0: RmDir(_L("\\F32-TST\\TFMAN\\source\\")); sl@0: SetupDirectories(ETrue, NULL); sl@0: err=TheFs.SetSessionPath(_L("\\F32-TST\\TFMAN\\source\\")); sl@0: test(err == KErrNone); sl@0: sl@0: err = gFileMan->Rename(_L(""), _L("\\F32-TST\\TFMAN\\dest\\")); sl@0: test(err == KErrNone); sl@0: Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), _L("\\F32-TST\\TFMAN\\dest\\*")); sl@0: sl@0: err=TheFs.SetSessionPath(sessionPath); sl@0: test(err==KErrNone); sl@0: sl@0: TestINC109754(); // Test empty source directory should exist after contents being renamed sl@0: TestDEF092084(); // Test wildcards are replaced with letters from the matched file sl@0: TestDEF113299(); // Test invalid file rename sl@0: } sl@0: sl@0: LOCAL_C void TestAttribs() sl@0: // sl@0: // Test attribs sl@0: // sl@0: { sl@0: test.Next(_L("Test set file attributes")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\ATTRIBS\\Attrib1.AT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\ATTRIBS\\Attrib2.at")); sl@0: sl@0: TUint legalAttMask=KEntryAttMaskSupported&~(KEntryAttDir|KEntryAttVolume); sl@0: TUint setMask=KEntryAttReadOnly; sl@0: TUint clearMask=KEntryAttHidden|KEntryAttArchive; sl@0: if (!gAsynch) sl@0: { sl@0: TInt r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\ATTRIBS\\AT*.AT"),setMask,clearMask,TTime(0)); sl@0: test(r==KErrNone); sl@0: } sl@0: else sl@0: { sl@0: TInt r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\ATTRIBS\\AT*.AT"),setMask,clearMask,TTime(0),0,gStat); sl@0: test(r==KErrNone); sl@0: WaitForSuccess(); sl@0: } sl@0: sl@0: CDirScan* scan=CDirScan::NewL(TheFs); sl@0: scan->SetScanDataL(_L("\\F32-TST\\TFMAN\\ATTRIBS\\*"),KEntryAttMaskSupported,ESortByName); sl@0: CDir* entryList; sl@0: scan->NextL(entryList); sl@0: TInt count=entryList->Count(); sl@0: test(count==2); sl@0: TEntry entry=(*entryList)[0]; sl@0: test(entry.iName.MatchF(_L("attrib1.AT"))!=KErrNotFound); sl@0: test(entry.iAtt==KEntryAttReadOnly); sl@0: entry=(*entryList)[1]; sl@0: test(entry.iName.MatchF(_L("attrib2.AT"))!=KErrNotFound); sl@0: test(entry.iAtt==KEntryAttReadOnly); sl@0: delete entryList; sl@0: sl@0: TDateTime dateTime(1990,ENovember,20,9,5,0,0); sl@0: TTime time(dateTime); // FAT loses microseconds if try to convert HomeTime() sl@0: sl@0: if (!gAsynch) sl@0: { sl@0: TInt r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\ATTRIBS\\AT*.AT"),0,legalAttMask,time); sl@0: test(r==KErrNone); sl@0: } sl@0: else sl@0: { sl@0: TInt r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\ATTRIBS\\AT*.AT"),0,legalAttMask,time,0,gStat); sl@0: test(r==KErrNone); sl@0: WaitForSuccess(); sl@0: } sl@0: sl@0: scan->SetScanDataL(_L("\\F32-TST\\TFMAN\\ATTRIBS\\*"),KEntryAttMaskSupported,ESortByName); sl@0: scan->NextL(entryList); sl@0: count=entryList->Count(); sl@0: test(count==2); sl@0: entry=(*entryList)[0]; sl@0: test(entry.iName.MatchF(_L("attrib1.AT"))!=KErrNotFound); sl@0: test(entry.iAtt==0); sl@0: TDateTime dt=(entry.iModified).DateTime(); sl@0: test(dt.Year()==dateTime.Year()); sl@0: test(dt.Month()==dateTime.Month()); sl@0: test(dt.Day()==dateTime.Day()); sl@0: test(dt.Hour()==dateTime.Hour()); sl@0: test(dt.Minute()==dateTime.Minute()); sl@0: test(dt.Second()==dateTime.Second()); sl@0: test(entry.iModified==time); sl@0: entry=(*entryList)[1]; sl@0: test(entry.iName.MatchF(_L("attrib2.AT"))!=KErrNotFound); sl@0: test(entry.iAtt==0); sl@0: test(entry.iModified==time); sl@0: delete entryList; sl@0: delete scan; sl@0: sl@0: TestINC111038(); // Test example of incorrect attribute flushing sl@0: } sl@0: sl@0: LOCAL_C void TestINC091841() sl@0: { sl@0: if(gAsynch) sl@0: { sl@0: return; sl@0: } sl@0: sl@0: test.Next(_L("Test delete long fullnames (INC091841)")); sl@0: MakeDir(_L("\\12345678\\Book\\12345678\\")); sl@0: TFileName longname; sl@0: longname.Copy(_L("\\12345678\\Book\\12345678\\12345678901234567890123456789012345678901234567890.x")); sl@0: MakeFile(longname); sl@0: TFileName oldname = longname; sl@0: TInt ret = KErrNone; sl@0: while(ret == KErrNone) sl@0: { sl@0: oldname = longname; sl@0: longname.Append(_L("xxxxx")); sl@0: ret = TheFs.Replace(oldname, longname); sl@0: } sl@0: if(oldname.Length() >= KMaxFileName-5) // if not, it means that we won't be calling ShrinkNames !! sl@0: { sl@0: TInt r = gFileMan->Rename(_L("\\12345678\\Book\\12345678"),_L("\\INC091841\\Book\\012-235-abcd"),0); sl@0: test(r==KErrNone); sl@0: CDir* dir; sl@0: r = TheFs.GetDir(_L("\\INC091841\\Book\\012-235-abcd\\"), KEntryAttNormal, ESortNone, dir); sl@0: test(r==KErrNone); sl@0: r = KErrNotFound; sl@0: TInt dirlen = sizeof("\\INC091841\\Book\\012-235-abcd\\"); sl@0: for(TInt i=0; r==KErrNotFound && iCount(); i++) sl@0: { sl@0: if((*dir)[i].iName.Length() + dirlen > oldname.Length()) sl@0: { sl@0: r = KErrNone; sl@0: } sl@0: } sl@0: delete dir; sl@0: test(r==KErrNone); sl@0: r = gFileMan->RmDir(_L("\\INC091841\\")); sl@0: test(r==KErrNone); sl@0: } sl@0: RmDir(_L("\\12345678\\")); sl@0: } sl@0: sl@0: LOCAL_C void TestRmDir() sl@0: // sl@0: // Test rmdir function sl@0: // sl@0: { sl@0: test.Next(_L("Test rmdir function")); sl@0: sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\RMDIR\\EMPTY\\")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\RMDIR\\ALFRED.txt")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\RMDIR\\RICHARD.txt")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\RMDIR\\RMSUBDIR1\\RMSUBSUBDIR\\CHARLES.txt")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\RMDIR\\RMSUBDIR2\\EDMUND.txt")); sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\TESTDIR\\")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\TESTDIR\\DEF123044.txt")); sl@0: sl@0: TInt r; sl@0: sl@0: if (testingInvalidPathLengths) sl@0: // Create a path of greater 256 characters by renaming a directory and check it can be sl@0: // manipulated (tests fix to F32) sl@0: { sl@0: MakeDir(_L("\\LONGNAMETEST\\")); sl@0: MakeDir(_L("\\LONGNAMETEST\\DIRECTORY1DIRECTORY2DIRECTORY3DIRECTORY4\\")); sl@0: MakeFile(_L("\\LONGNAMETEST\\ELEPHANT01ELEPHANT02ELEPHANT03ELEPHANT04")); sl@0: MakeFile(_L("\\LONGNAMETEST\\FILEFILE01FILEFILE02FILEFILE03FILEFILE04")); sl@0: r=gFileMan->Rename(_L("\\LONGNAMETEST"),_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff"),CFileMan::EOverWrite); sl@0: test(r==KErrNone); sl@0: } sl@0: sl@0: //testing invalid source path at the beginning: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->RmDir(_L(":C:\\F32-TST\\TFMAN\\RMDIR\\*.AT")); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->RmDir(_L(":C:\\F32-TST\\TFMAN\\RMDIR\\*.AT"),gStat); sl@0: } sl@0: TestResult(r,KErrBadName,KErrBadName); sl@0: sl@0: //testing invalid source path at the middle: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\:RMDIR\\*.AT")); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\:RMDIR\\*.AT"),gStat); sl@0: } sl@0: TestResult(r,KErrBadName,KErrNone); sl@0: sl@0: //testing invalid source path at the end: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\TESTDIR\\:DEF.txt")); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\TESTDIR\\:DEF.txt"),gStat); sl@0: } sl@0: TestResult(r,KErrNone,KErrNone); sl@0: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\RMDIR\\*.AT")); sl@0: test(r==KErrNone); sl@0: if (testingInvalidPathLengths) sl@0: { sl@0: r=gFileMan->RmDir(_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\")); sl@0: test(r==KErrNone); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\RMDIR\\*.AT"),gStat); sl@0: test(r==KErrNone); sl@0: WaitForSuccess(); sl@0: if (testingInvalidPathLengths) sl@0: { sl@0: r=gFileMan->RmDir(_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\"),gStat); sl@0: test(r==KErrNone); sl@0: WaitForSuccess(); sl@0: } sl@0: } sl@0: sl@0: TEntry entry; sl@0: r=TheFs.Entry(_L("\\F32-TST\\TFMAN\\RMDIR"),entry); sl@0: test(r==KErrNotFound); sl@0: sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\READONLY\\")); sl@0: r=TheFs.SetAtt(_L("\\F32-TST\\TFMAN\\READONLY\\"),KEntryAttReadOnly,0); sl@0: test(r==KErrNone); sl@0: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\READONLY\\")); sl@0: test(r==KErrAccessDenied); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\READONLY\\"),gStat); sl@0: test(r==KErrNone); sl@0: WaitForResult(KErrAccessDenied); sl@0: } sl@0: sl@0: r=TheFs.SetAtt(_L("\\F32-TST\\TFMAN\\READONLY\\"),0,KEntryAttReadOnly); sl@0: test(r==KErrNone); sl@0: sl@0: r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\READONLY\\")); sl@0: test(r==KErrNone); sl@0: sl@0: // Test behaviour for omitted parameters sl@0: // For this, default should be session path sl@0: TFileName sessionPath; sl@0: r=TheFs.SessionPath(sessionPath); sl@0: test(r==KErrNone); sl@0: sl@0: SetupDirectories(ETrue, NULL); sl@0: r=TheFs.SetSessionPath(_L("\\F32-TST\\TFMAN\\source\\")); sl@0: sl@0: // Default removal of session path sl@0: r=gFileMan->RmDir(_L("")); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.SetSessionPath(sessionPath); sl@0: sl@0: r = gFileMan->Rename(_L("\\F32-TST\\TFMAN\\source\\subdir"), _L("\\F32-TST\\TFMAN\\source\\tofail"), CFileMan::ERecurse); sl@0: test(r == KErrPathNotFound); sl@0: sl@0: r = gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\")); sl@0: test(r==KErrNone); sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\")); sl@0: sl@0: if(testingInvalidPathLengths) sl@0: { sl@0: TestINC091841(); // Test delete long fullnames sl@0: } sl@0: sl@0: //--------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_FMAN-0316 sl@0: //! @SYMTestType UT sl@0: //! @SYMREQ DEF099820 sl@0: //! @SYMTestCaseDesc Test that CFileMan::RmDir() works when deleting a directory containing open files. sl@0: //! @SYMTestActions Open a file within a directory and try to remove the directory. sl@0: //! @SYMTestExpectedResults The operation completes with the error code KErrInUse. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //--------------------------------------------- sl@0: sl@0: test.Next(_L("Test delete directory containing open files")); sl@0: gFileMan->SetObserver(NULL); sl@0: sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\OPENFILE\\")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\OPENFILE\\FILE.TXT")); sl@0: sl@0: RFile file; sl@0: r = file.Open(TheFs,_L("\\F32-TST\\TFMAN\\OPENFILE\\FILE.TXT"), EFileRead | EFileShareExclusive); sl@0: test(r==KErrNone); sl@0: sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\OPENFILE\\")); sl@0: test(r==KErrInUse); sl@0: sl@0: file.Close(); sl@0: sl@0: r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\OPENFILE\\")); sl@0: test(r==KErrNone); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\OPENFILE\\"), gStat); sl@0: test(r==KErrNone); sl@0: WaitForResult(KErrInUse); sl@0: sl@0: file.Close(); sl@0: sl@0: r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\OPENFILE\\"), gStat); sl@0: test(r==KErrNone); sl@0: WaitForResult(KErrNone); sl@0: } sl@0: sl@0: gFileMan->SetObserver(gObserver); sl@0: } sl@0: sl@0: LOCAL_C void TestRecursiveCopy() sl@0: // sl@0: // Test the recursive copy function sl@0: // sl@0: { sl@0: test.Next(_L("Test recursive copy")); sl@0: RmDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\")); sl@0: sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\")); sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EMPTY\\")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE2.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE3.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\FILE4.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EXE1.BIN")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\EXE2.BIN")); sl@0: sl@0: TInt r; sl@0: if (!gAsynch) sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\"),_L("\\F32-TST\\TFMAN\\COPYDIR"),CFileMan::ERecurse); sl@0: else sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\"),_L("\\F32-TST\\TFMAN\\COPYDIR"),CFileMan::ERecurse,gStat); sl@0: TestResult(r); sl@0: sl@0: Compare(_L("\\F32-TST\\TFMAN\\DELDIR\\*"),_L("\\F32-TST\\TFMAN\\COPYDIR\\*")); sl@0: RmDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\")); sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\")); sl@0: sl@0: if (!gAsynch) sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\*.BIN"),_L("\\F32-TST\\TFMAN\\COPYDIR\\*.EXT"),CFileMan::ERecurse); sl@0: else sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\*.BIN"),_L("\\F32-TST\\TFMAN\\COPYDIR\\*.EXT"),CFileMan::ERecurse,gStat); sl@0: TestResult(KErrNone); sl@0: sl@0: RmDir(_L("\\F32-TST\\TFMAN\\after\\")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\DELTEST\\EXE1.EXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\EXE2.EXT")); sl@0: Compare(_L("\\F32-TST\\TFMAN\\AFTER\\*"),_L("\\F32-TST\\TFMAN\\COPYDIR\\*")); sl@0: sl@0: // Test behaviour for omitted parameters sl@0: // For this, default should be session path sl@0: TFileName sessionPath; sl@0: r=TheFs.SessionPath(sessionPath); sl@0: test(r==KErrNone); sl@0: sl@0: RmDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\")); sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\")); sl@0: r=TheFs.SetSessionPath(_L("\\F32-TST\\TFMAN\\COPYDIR\\")); sl@0: sl@0: // Default copy to session path sl@0: if (!gAsynch) sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\"),_L(""),CFileMan::ERecurse); sl@0: else sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\"),_L(""),CFileMan::ERecurse,gStat); sl@0: TestResult(KErrNone); sl@0: Compare(_L("\\F32-TST\\TFMAN\\DELDIR\\*"),_L("\\F32-TST\\TFMAN\\COPYDIR\\*")); sl@0: sl@0: RmDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\")); sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\")); sl@0: r=TheFs.SetSessionPath(_L("\\F32-TST\\TFMAN\\DELDIR\\")); sl@0: sl@0: // Default copy from session path sl@0: if (!gAsynch) sl@0: r=gFileMan->Copy(_L(""),_L("\\F32-TST\\TFMAN\\COPYDIR\\"),CFileMan::ERecurse); sl@0: else sl@0: r=gFileMan->Copy(_L(""),_L("\\F32-TST\\TFMAN\\COPYDIR\\"),CFileMan::ERecurse,gStat); sl@0: TestResult(KErrNone); sl@0: Compare(_L("\\F32-TST\\TFMAN\\DELDIR\\*"),_L("\\F32-TST\\TFMAN\\COPYDIR\\*")); sl@0: sl@0: RmDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\")); sl@0: RmDir(_L("\\F32-TST\\TFMAN\\DELDIR\\")); sl@0: r=TheFs.SetSessionPath(sessionPath); sl@0: test(r==KErrNone); sl@0: } sl@0: sl@0: LOCAL_C void TestRecursiveAttribs() sl@0: // sl@0: // Test set attribs recursively sl@0: // sl@0: { sl@0: test.Next(_L("Test recursive attribs")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\Attrib1.AT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\Attrib2.at")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\SUBDIR\\ATFILE.TXT")); sl@0: sl@0: if (!gAsynch) sl@0: { sl@0: TInt r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\"),KEntryAttReadOnly,0,TTime(0),CFileMan::ERecurse); sl@0: test(r==KErrNone); sl@0: } sl@0: else sl@0: { sl@0: TInt r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\"),KEntryAttReadOnly,0,TTime(0),CFileMan::ERecurse,gStat); sl@0: test(r==KErrNone); sl@0: WaitForSuccess(); sl@0: } sl@0: sl@0: CDir* entryList; sl@0: CDirScan* scan=CDirScan::NewL(TheFs); sl@0: scan->SetScanDataL(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\*"),KEntryAttMaskSupported,ESortByName); sl@0: scan->NextL(entryList); sl@0: TInt count=entryList->Count(); sl@0: test(count==3); sl@0: TEntry entry=(*entryList)[0]; sl@0: test(entry.iName.MatchF(_L("ATTRIB1.AT"))!=KErrNotFound); sl@0: if (!IsTestingLFFS()) sl@0: test(entry.iAtt==(KEntryAttReadOnly|KEntryAttArchive)); sl@0: else sl@0: test(entry.iAtt&KEntryAttReadOnly); // ??? sl@0: entry=(*entryList)[1]; sl@0: test(entry.iName.MatchF(_L("ATTRIB2.AT"))!=KErrNotFound); sl@0: if (!IsTestingLFFS()) sl@0: test(entry.iAtt==(KEntryAttReadOnly|KEntryAttArchive)); sl@0: else sl@0: test(entry.iAtt&KEntryAttReadOnly); // ??? sl@0: entry=(*entryList)[2]; sl@0: test(entry.iName.MatchF(_L("SUBDIR"))!=KErrNotFound); sl@0: delete entryList; sl@0: sl@0: scan->NextL(entryList); sl@0: count=entryList->Count(); sl@0: test(count==1); sl@0: entry=(*entryList)[0]; sl@0: test(entry.iName.MatchF(_L("ATFILE.TXT"))!=KErrNotFound); sl@0: if (!IsTestingLFFS()) sl@0: test(entry.iAtt==(KEntryAttReadOnly|KEntryAttArchive)); sl@0: else sl@0: test(entry.iAtt&KEntryAttReadOnly); // ??? sl@0: delete entryList; sl@0: sl@0: scan->NextL(entryList); sl@0: test(entryList==NULL); sl@0: sl@0: if (!gAsynch) sl@0: { sl@0: TInt r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\"),0,KEntryAttReadOnly|KEntryAttArchive,TTime(0),CFileMan::ERecurse); sl@0: test(r==KErrNone); sl@0: } sl@0: else sl@0: { sl@0: TInt r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\"),0,KEntryAttReadOnly|KEntryAttArchive,TTime(0),CFileMan::ERecurse,gStat); sl@0: test(r==KErrNone); sl@0: WaitForSuccess(); sl@0: } sl@0: sl@0: scan->SetScanDataL(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\*"),KEntryAttMaskSupported,ESortByName); sl@0: scan->NextL(entryList); sl@0: count=entryList->Count(); sl@0: test(count==3); sl@0: entry=(*entryList)[0]; sl@0: test(entry.iName.MatchF(_L("ATTRIB1.AT"))!=KErrNotFound); sl@0: test(entry.iAtt==KEntryAttNormal); sl@0: entry=(*entryList)[1]; sl@0: test(entry.iName.MatchF(_L("ATTRIB2.AT"))!=KErrNotFound); sl@0: test(entry.iAtt==KEntryAttNormal); sl@0: entry=(*entryList)[2]; sl@0: test(entry.iName.MatchF(_L("SUBDIR"))!=KErrNotFound); sl@0: delete entryList; sl@0: sl@0: scan->NextL(entryList); sl@0: count=entryList->Count(); sl@0: test(count==1); sl@0: entry=(*entryList)[0]; sl@0: test(entry.iName.MatchF(_L("ATFILE.TXT"))!=KErrNotFound); sl@0: test(entry.iAtt==KEntryAttNormal); sl@0: delete entryList; sl@0: sl@0: scan->NextL(entryList); sl@0: test(entryList==NULL); sl@0: delete scan; sl@0: } sl@0: sl@0: LOCAL_C void TestRecursiveDelete() sl@0: // sl@0: // Test Recursive delete sl@0: // sl@0: { sl@0: test.Next(_L("Test recursive delete")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\RECDELETE\\FULL\\GRAPE.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\RECDELETE\\FULL\\GRAPE.PLP")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\RECDELETE\\GRAPE.PLP")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\RECDELETE\\FILE1.TXT")); sl@0: sl@0: if (!gAsynch) sl@0: { sl@0: TInt r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\RECDELETE\\*.PLP"),CFileMan::ERecurse); sl@0: test(r==KErrNone); sl@0: } sl@0: else sl@0: { sl@0: TInt r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\RECDELETE\\*.PLP"),CFileMan::ERecurse,gStat); sl@0: test(r==KErrNone); sl@0: WaitForSuccess(); sl@0: } sl@0: sl@0: RmDir(_L("\\F32-TST\\TFMAN\\after\\")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FULL\\GRAPE.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FILE1.TXT")); sl@0: Compare(_L("\\F32-TST\\TFMAN\\after\\*"),_L("\\F32-TST\\TFMAN\\RecDelete\\*")); sl@0: } sl@0: sl@0: LOCAL_C void TestINC108401() sl@0: { sl@0: sl@0: test.Next(_L("Test synchronous and asynchronous move operations (INC108401)")); sl@0: TInt err = 0; sl@0: sl@0: TFileName trgPath = _L("?:\\F32-TST\\"); sl@0: sl@0: if (gSessionPath[0]!='D'&& gSessionPath[0]!='Y') sl@0: { sl@0: #if !defined(__WINS__) sl@0: trgPath[0] = 'D'; sl@0: #else sl@0: trgPath[0] = 'Y'; sl@0: #endif sl@0: } sl@0: else sl@0: return; sl@0: sl@0: TFileName trgDir = trgPath; sl@0: trgDir.Append(_L("TFMAN\\INC108401\\dest\\")); sl@0: sl@0: // Moving files and dirs ACROSS DRIVE. sl@0: err = 0; sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\")); sl@0: MakeDir(trgDir); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file1")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file2")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2")); sl@0: // Synchronously sl@0: if (!gAsynch) sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), trgDir, 0); sl@0: else // Asynchronously sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), trgDir, 0, gStat); sl@0: test.Next(_L("Test INC108401 : ACROSS DRIVES with 0")); sl@0: TestResult(err); sl@0: // cleanup the current drive sl@0: RmDir(trgPath); sl@0: // remove the F32-TST dir on the C: drive sl@0: RmDir(_L("\\F32-TST\\TFMAN\\")); sl@0: sl@0: err = 0; sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\")); sl@0: MakeDir(trgDir); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file1")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file2")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2")); sl@0: // Synchronously sl@0: if (!gAsynch) sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), trgDir, CFileMan::EOverWrite); sl@0: else // Asynchronously sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), trgDir, CFileMan::EOverWrite, gStat); sl@0: test.Next(_L("Test INC108401 : ACROSS DRIVES with CFileMan::EOverWrite")); sl@0: TestResult(err); sl@0: // cleanup the current drive sl@0: RmDir(trgPath); sl@0: // remove the F32-TST dir on the C: drive sl@0: RmDir(_L("\\F32-TST\\")); sl@0: sl@0: err = 0; sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\")); sl@0: MakeDir(trgDir); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file1")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file2")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2")); sl@0: // Synchronously sl@0: if (!gAsynch) sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), trgDir, CFileMan::ERecurse); sl@0: else // Asynchronously sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), trgDir, CFileMan::ERecurse, gStat); sl@0: test.Next(_L("Test INC108401 : ACROSS DRIVES with CFileMan::ERecurse")); sl@0: TestResult(err); sl@0: // cleanup the current drive sl@0: RmDir(trgPath); sl@0: // remove the F32-TST dir on the C: drive sl@0: RmDir(_L("\\F32-TST\\")); sl@0: sl@0: sl@0: // Moving files and dirs on the SAME DRIVE. sl@0: // case for gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), 0); sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\")); sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\INC108401\\dest\\")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file1")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file2")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2")); sl@0: // Synchronously sl@0: if (!gAsynch) sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), 0); sl@0: else // Asynchronously sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), 0, gStat); sl@0: test.Next(_L("Test INC108401 : SAME DRIVE with 0")); sl@0: TestResult(err); sl@0: // test(err==KErrNone); sl@0: RmDir(_L("\\F32-TST\\TFMAN\\INC108401\\")); sl@0: sl@0: // case for gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), CFileMan::EOverWrite); sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\")); sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\INC108401\\dest\\")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file1")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file2")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2")); sl@0: // Synchronously sl@0: if (!gAsynch) sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), CFileMan::EOverWrite); sl@0: else // Asynchronously sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), CFileMan::EOverWrite, gStat); sl@0: test.Next(_L("Test INC108401 : SAME DRIVE with CFileMan::EOverWrite")); sl@0: TestResult(err); sl@0: // test(err==KErrNone); sl@0: RmDir(_L("\\F32-TST\\TFMAN\\INC108401\\")); sl@0: sl@0: // case for gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), CFileMan::EOverWrite|CFileMan::ERecurse); sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\")); sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\INC108401\\dest\\")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file1")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file2")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\file1")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\file1")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\file1")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\file1")); sl@0: // Synchronously sl@0: if (!gAsynch) sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), CFileMan::ERecurse|CFileMan::EOverWrite); sl@0: else // Asynchronously sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), CFileMan::ERecurse|CFileMan::EOverWrite, gStat); sl@0: test.Next(_L("Test INC108401 : SAME DRIVES with CFileMan::ERecurse|CFileMan::EOverWrite")); sl@0: TestResult(err); sl@0: // test(err==KErrNone); sl@0: RmDir(_L("\\F32-TST\\TFMAN\\INC108401\\")); sl@0: sl@0: // cleanup for the current drive sl@0: RmDir(trgPath); sl@0: RmDir(_L("\\F32-TST\\")); sl@0: sl@0: test.Printf(_L("Test INC108401 : ends\n")); sl@0: } sl@0: sl@0: LOCAL_C void TestINC089638() sl@0: { sl@0: if(gAsynch) sl@0: { sl@0: return; sl@0: } sl@0: sl@0: test.Next(_L("Test all items removed from source directory after recursive moving (INC089638)")); sl@0: RmDir(_L("\\INC089638\\source\\")); sl@0: RmDir(_L("\\INC089638\\dest\\")); sl@0: MakeFile(_L("\\INC089638\\source\\file1")); sl@0: MakeFile(_L("\\INC089638\\source\\file2")); sl@0: MakeFile(_L("\\INC089638\\source\\subdir1\\file3")); sl@0: MakeFile(_L("\\INC089638\\source\\subdir1\\file4")); sl@0: MakeFile(_L("\\INC089638\\source\\subdir2\\file5")); sl@0: MakeFile(_L("\\INC089638\\source\\subdir2\\file6")); sl@0: MakeDir(_L("\\INC089638\\dest\\")); sl@0: test(TheFs.SetAtt(_L("\\INC089638\\source\\subdir1"), KEntryAttHidden, 0) == KErrNone); sl@0: test(TheFs.SetAtt(_L("\\INC089638\\source\\subdir2"), KEntryAttReadOnly, 0) == KErrNone); sl@0: sl@0: TInt r = gFileMan->Move(_L("\\INC089638\\source\\"), _L("\\INC089638\\dest\\"), CFileMan::ERecurse); sl@0: test(r==KErrNone); sl@0: r = TheFs.RmDir(_L("\\INC089638\\source\\")); sl@0: test(r==KErrNone); sl@0: sl@0: RmDir(_L("\\INC089638\\")); sl@0: } sl@0: sl@0: void TestINC101379() sl@0: { sl@0: test.Next(_L("Test moving of directory to its subdirectory recursively and not recursively (INC101379)")); sl@0: TInt err; sl@0: _LIT(KSourceDir,"\\INC101379\\dir\\"); sl@0: _LIT(KFile1, "\\INC101379\\dir\\file1.txt"); sl@0: _LIT(KFile2, "\\INC101379\\dir\\subdir\\file2.txt"); sl@0: _LIT(KFile3, "\\INC101379\\dir\\other\\file3.txt"); sl@0: MakeFile(KFile1, _L8("qwerty")); sl@0: MakeFile(KFile2, _L8("abc")); sl@0: MakeFile(KFile3, _L8("qwerty")); sl@0: TFileName dest; sl@0: dest.Copy(KSourceDir); sl@0: dest.Append(_L("subdir")); sl@0: gFileMan->SetObserver(NULL); sl@0: if (!gAsynch) sl@0: err = gFileMan->Move(KSourceDir, dest, CFileMan::ERecurse|CFileMan::EOverWrite); sl@0: else sl@0: err = gFileMan->Move(KSourceDir, dest, CFileMan::ERecurse|CFileMan::EOverWrite, gStat); sl@0: test(err==KErrInUse); // Recursive move prohibited sl@0: if (gAsynch) sl@0: WaitForResult(KErrInUse); sl@0: CheckFileContents(KFile1, _L8("qwerty")); sl@0: CheckFileContents(KFile2, _L8("abc")); sl@0: CheckFileContents(KFile3, _L8("qwerty")); sl@0: sl@0: if (!gAsynch) sl@0: err = gFileMan->Move(KSourceDir, dest, CFileMan::EOverWrite); sl@0: else sl@0: err = gFileMan->Move(KSourceDir, dest, CFileMan::EOverWrite, gStat); sl@0: TestResult(err, KErrNone); // Non-recursive move must be OK sl@0: sl@0: _LIT(KFile1Moved, "\\INC101379\\dir\\subdir\\file1.txt"); sl@0: CheckFileContents(KFile1Moved, _L8("qwerty")); sl@0: CheckFileContents(KFile2, _L8("abc")); sl@0: CheckFileContents(KFile3, _L8("qwerty")); sl@0: gFileMan->SetObserver(gObserver); sl@0: RmDir(KSourceDir); sl@0: RmDir(_L("\\INC101379\\")); sl@0: } sl@0: sl@0: void TestINC099600() // and INC101061 sl@0: { sl@0: // Test move files from the internal drive to an external one (INC099600) sl@0: // Test move files with system (KEntryAttSystem) or hidden (KEntryAttHidden) attributes (INC101061) sl@0: test.Next(_L("Test move files from internal drive to external with system and hidden attributes")); sl@0: _LIT(KDest,"C:\\DEST099600\\"); sl@0: TBuf<64> source; sl@0: source.Format(_L("%c:\\INC099600\\"), (TUint) gDriveToTest); sl@0: TBuf<64> src; sl@0: TInt r; sl@0: TBuf<64> dst; sl@0: RmDir(source); sl@0: RmDir(KDest); sl@0: sl@0: src = source; sl@0: src.Append('a'); sl@0: MakeFile(src); sl@0: TheFs.SetAtt(src, KEntryAttArchive, 0); sl@0: src.Append('h'); sl@0: MakeFile(src); sl@0: TheFs.SetAtt(src, KEntryAttArchive | KEntryAttHidden, 0); sl@0: src.Append('s'); sl@0: MakeFile(src); sl@0: TheFs.SetAtt(src, KEntryAttArchive | KEntryAttHidden | KEntryAttSystem, 0); sl@0: src.Append('x'); sl@0: src.Append(KPathDelimiter); sl@0: src.Append('a'); sl@0: MakeFile(src); sl@0: TheFs.SetAtt(src, KEntryAttArchive, 0); sl@0: src.Append('h'); sl@0: MakeFile(src); sl@0: TheFs.SetAtt(src, KEntryAttArchive | KEntryAttHidden, 0); sl@0: sl@0: dst.Copy(KDest); sl@0: dst.Append(_L("ahsx\\")); sl@0: MakeDir(dst); sl@0: sl@0: TEntry entry; sl@0: r = gFileMan->Move(src, KDest, 0); // ahsx\ah sl@0: test(r == KErrNone); sl@0: r = TheFs.Entry(src, entry); sl@0: test(r == KErrNotFound); sl@0: sl@0: src.SetLength(src.Length()-1); // ahsx\a sl@0: r = gFileMan->Move(src, KDest, 0); sl@0: test(r == KErrNone); sl@0: r = TheFs.Entry(src, entry); sl@0: test(r == KErrNotFound); sl@0: sl@0: src.SetLength(src.Length()-3); // ahs sl@0: r = gFileMan->Move(src, KDest, 0); sl@0: test(r == KErrNone); sl@0: r = TheFs.Entry(src, entry); sl@0: test(r == KErrNotFound); sl@0: sl@0: src.SetLength(src.Length()-1); // ah sl@0: r = gFileMan->Move(src, KDest, 0); sl@0: test(r == KErrAlreadyExists); sl@0: r = TheFs.Entry(src, entry); sl@0: test(r == KErrNone); sl@0: sl@0: r = gFileMan->Move(src, KDest, CFileMan::EOverWrite); // ah sl@0: test(r == KErrNone); sl@0: r = TheFs.Entry(src, entry); sl@0: test(r == KErrNotFound); sl@0: sl@0: src.SetLength(src.Length()-1); // a sl@0: r = gFileMan->Move(src, KDest, 0); sl@0: test(r == KErrAlreadyExists); sl@0: r = TheFs.Entry(src, entry); sl@0: test(r == KErrNone); sl@0: sl@0: r = gFileMan->Move(src, KDest, CFileMan::EOverWrite); // a sl@0: test(r == KErrNone); sl@0: r = TheFs.Entry(src, entry); sl@0: test(r == KErrNotFound); sl@0: sl@0: RmDir(source); sl@0: RmDir(KDest); sl@0: } sl@0: sl@0: void SetupDirectoriesForCase0520() sl@0: // Setup initial directory structure for test case PBASE-T_FMAN-0520 sl@0: { sl@0: RmDir( _L("\\F32-TST\\TFMAN\\INC106735\\")); sl@0: MakeDir( _L("\\F32-TST\\TFMAN\\INC106735\\")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC106735\\F_ROOT.TXT"), _L8("blahblahblah")); sl@0: MakeDir( _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\F_SUB.TXT"), _L8("blahblahblah")); sl@0: MakeDir( _L("\\F32-TST\\TFMAN\\INC106735\\SUB01\\")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC106735\\SUB01\\F_SUB01.TXT"), _L8("blahblahblah")); sl@0: MakeDir( _L("\\F32-TST\\TFMAN\\INC106735\\SUB01\\SUB02\\")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC106735\\SUB01\\SUB02\\F_SUB02.TXT"), _L8("blahblahblah")); sl@0: } sl@0: sl@0: void SetupDirectoriesForCase0520Compare1() sl@0: // Comparing directory structure for recursive Move() without wildcard sl@0: { sl@0: RmDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\")); sl@0: MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\")); sl@0: MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\F_ROOT.TXT"), _L8("blahblahblah")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\F_SUB.TXT"), _L8("blahblahblah")); sl@0: MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\F_SUB01.TXT"), _L8("blahblahblah")); sl@0: MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\SUB02\\")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\SUB02\\F_SUB02.TXT"), _L8("blahblahblah")); sl@0: } sl@0: sl@0: void SetupDirectoriesForCase0520Compare2() sl@0: // Comparing directory structure for recursive Move() with wildcard sl@0: { sl@0: RmDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\")); sl@0: MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\")); sl@0: MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\F_ROOT.TXT"), _L8("blahblahblah")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\F_SUB.TXT"), _L8("blahblahblah")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\SUB01\\F_SUB01.TXT"), _L8("blahblahblah")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\SUB01\\SUB02\\F_SUB02.TXT"), _L8("blahblahblah")); sl@0: MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\")); sl@0: MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\SUB02\\")); sl@0: } sl@0: sl@0: void SetupDirectoriesForCase0520Compare3() sl@0: // Comparing directory structure for recursive Copy() without wildcard sl@0: { sl@0: RmDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\")); sl@0: MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\F_ROOT.TXT"), _L8("blahblahblah")); sl@0: MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\F_ROOT.TXT"), _L8("blahblahblah")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\F_SUB.TXT"), _L8("blahblahblah")); sl@0: MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\F_SUB01.TXT"), _L8("blahblahblah")); sl@0: MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\SUB02\\")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\SUB02\\F_SUB02.TXT"), _L8("blahblahblah")); sl@0: } sl@0: sl@0: void SetupDirectoriesForCase0520Compare4() sl@0: // Comparing directory structure for recursive Copy() with wildcard sl@0: { sl@0: RmDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\")); sl@0: MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\F_ROOT.TXT"), _L8("blahblahblah")); sl@0: MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\F_ROOT.TXT"), _L8("blahblahblah")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\F_SUB.TXT"), _L8("blahblahblah")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\SUB01\\F_SUB01.TXT"), _L8("blahblahblah")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\SUB01\\SUB02\\F_SUB02.TXT"), _L8("blahblahblah")); sl@0: MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\F_SUB01.TXT"), _L8("blahblahblah")); sl@0: MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\SUB02\\")); sl@0: MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\SUB02\\F_SUB02.TXT"), _L8("blahblahblah")); sl@0: } sl@0: sl@0: LOCAL_C void TestRecursiveMove() sl@0: // sl@0: // Test recursive move sl@0: // sl@0: { sl@0: test.Next(_L("Test recursive move")); sl@0: RmDir(_L("\\F32-TST\\TFMAN\\RecMove2\\")); sl@0: sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\RECMOVE\\FULL\\FILE2.PLP")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\RECMOVE\\FULL\\FILE3.PLP")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\RECMOVE\\FULL\\GRAPE.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\RECMOVE\\GRAPE.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\RECMOVE\\FILE1.PLP")); sl@0: sl@0: TInt err; sl@0: if (!gAsynch) sl@0: err=gFileMan->Move(_L("\\F32-TST\\TFMAN\\RECMOVE\\*.PLP"),_L("\\F32-TST\\TFMAN\\RECMOVE2\\"),CFileMan::ERecurse); sl@0: else sl@0: err=gFileMan->Move(_L("\\F32-TST\\TFMAN\\RECMOVE\\*.PLP"),_L("\\F32-TST\\TFMAN\\RECMOVE2\\"),CFileMan::ERecurse,gStat); sl@0: TestResult(err); sl@0: sl@0: RmDir(_L("\\F32-TST\\TFMAN\\after\\")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FULL\\FILE2.PLP")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FULL\\FILE3.PLP")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FILE1.PLP")); sl@0: Compare(_L("\\F32-TST\\TFMAN\\after\\*"),_L("\\F32-TST\\TFMAN\\RecMOve2\\*")); sl@0: sl@0: // sl@0: // Test moving empty directories (DEF073924) sl@0: // sl@0: test.Next(_L("Test moving empty directories")); sl@0: sl@0: SetupDirectories(EFalse, NULL); sl@0: sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\"), _L("\\F32-TST\\TFMAN\\dest\\"), CFileMan::ERecurse); sl@0: test(err == KErrNotFound); // Expected - directory is empty sl@0: sl@0: // Test that all directories are still present sl@0: TEntry entry; sl@0: err = TheFs.Entry(_L("\\F32-TST\\TFMAN\\source\\"), entry); sl@0: test(err == KErrNone); sl@0: err = TheFs.Entry(_L("\\F32-TST\\TFMAN\\dest\\"), entry); sl@0: test(err == KErrNone); sl@0: sl@0: SetupDirectories(EFalse, NULL); sl@0: sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source"), _L("\\F32-TST\\TFMAN\\dest\\"), CFileMan::ERecurse); sl@0: test(err == KErrNone); // Expected - should move (or rename) directory sl@0: sl@0: // Test directory has been moved sl@0: err = TheFs.Entry(_L("\\F32-TST\\TFMAN\\dest\\source\\"), entry); sl@0: test(err == KErrNone); sl@0: err = TheFs.Entry(_L("\\F32-TST\\TFMAN\\source\\"), entry); sl@0: test(err == KErrNotFound); sl@0: sl@0: RmDir(_L("\\F32-TST\\TFMAN\\dest\\source\\")); sl@0: sl@0: // sl@0: // Test moving when the source directory contains subdirectories (INC074828, INC078800) sl@0: // sl@0: test.Next(_L("Test moving a directory containing subdirectories")); sl@0: sl@0: SetupDirectories(ETrue, NULL); sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\"), _L("\\F32-TST\\TFMAN\\dest\\"), CFileMan::ERecurse | CFileMan::EOverWrite); sl@0: test(err == KErrNone); sl@0: sl@0: Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), _L("\\F32-TST\\TFMAN\\dest\\*")); sl@0: sl@0: //--------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_FMAN-0160 sl@0: //! @SYMTestType UT sl@0: //! @SYMREQ DEF087791 sl@0: //! @SYMTestCaseDesc Test that CFileMan::Move() works when the destination paths does not exist. sl@0: //! @SYMTestActions Copy directory structures to a non-existant directory on the same drive. sl@0: //! @SYMTestExpectedResults Completes with no error, files are copied and intermediate directories are created. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //--------------------------------------------- sl@0: test.Next(_L("Test moving when the target directory does not exist")); sl@0: sl@0: SetupDirectories(ETrue, NULL); sl@0: sl@0: RmDir(_L("\\F32-TST\\TFMAN\\dest\\")); sl@0: sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\"), _L("\\F32-TST\\TFMAN\\dest\\"), CFileMan::ERecurse); sl@0: test(err == KErrNone); sl@0: sl@0: Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), _L("\\F32-TST\\TFMAN\\dest\\*")); sl@0: sl@0: SetupDirectories(ETrue, NULL); sl@0: sl@0: RmDir(_L("\\F32-TST\\TFMAN\\dest\\")); sl@0: sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\"), _L("\\F32-TST\\TFMAN\\dest"), CFileMan::ERecurse); sl@0: test(err == KErrNone); sl@0: sl@0: Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), _L("\\F32-TST\\TFMAN\\dest\\*")); sl@0: sl@0: SetupDirectories(ETrue, NULL); sl@0: sl@0: RmDir(_L("\\F32-TST\\TFMAN\\dest\\")); sl@0: sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source"), _L("\\F32-TST\\TFMAN\\dest\\"), CFileMan::ERecurse); sl@0: test(err == KErrNone); sl@0: sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\compare\\subdir\\")); sl@0: Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), _L("\\F32-TST\\TFMAN\\dest\\source\\*")); sl@0: RmDir(_L("\\F32-TST\\TFMAN\\compare\\subdir\\")); sl@0: sl@0: SetupDirectories(ETrue, NULL); sl@0: sl@0: RmDir(_L("\\F32-TST\\TFMAN\\dest\\")); sl@0: sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\File1.TXT"), _L("\\F32-TST\\TFMAN\\dest\\"), CFileMan::ERecurse); sl@0: test(err == KErrNone); sl@0: sl@0: CheckFileExists(_L("\\F32-TST\\TFMAN\\source\\File1.TXT"), KErrNotFound, ETrue); sl@0: CheckFileExists(_L("\\F32-TST\\TFMAN\\dest\\File1.TXT"), KErrNone, ETrue); sl@0: sl@0: RmDir(_L("\\F32-TST\\TFMAN\\dest\\")); sl@0: RmDir(_L("\\F32-TST\\TFMAN\\source\\")); sl@0: sl@0: // Test behaviour for omitted parameters sl@0: // For this, default should be session path sl@0: TFileName sessionPath; sl@0: err=TheFs.SessionPath(sessionPath); sl@0: test(err==KErrNone); sl@0: sl@0: SetupDirectories(ETrue, NULL); sl@0: err=TheFs.SetSessionPath(_L("\\F32-TST\\TFMAN\\dest\\")); sl@0: test(err == KErrNone); sl@0: sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source"), _L(""), CFileMan::ERecurse); sl@0: test(err == KErrNone); sl@0: Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), _L("\\F32-TST\\TFMAN\\dest\\source\\*")); sl@0: sl@0: RmDir(_L("\\F32-TST\\TFMAN\\dest\\")); sl@0: RmDir(_L("\\F32-TST\\TFMAN\\source\\")); sl@0: SetupDirectories(ETrue, NULL); sl@0: err=TheFs.SetSessionPath(_L("\\F32-TST\\TFMAN\\source\\")); sl@0: test(err == KErrNone); sl@0: sl@0: err = gFileMan->Move(_L(""), _L("\\F32-TST\\TFMAN\\dest\\"), CFileMan::ERecurse); sl@0: test(err == KErrNone); sl@0: Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), _L("\\F32-TST\\TFMAN\\dest\\*")); sl@0: sl@0: err=TheFs.SetSessionPath(sessionPath); sl@0: test(err==KErrNone); sl@0: sl@0: //--------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_FMAN-0520 sl@0: //! @SYMTestType UT sl@0: //! @SYMREQ INC106735 sl@0: //! @SYMTestCaseDesc Test that CFileMan::Move() (recursive mode) works properly when the destination sl@0: //! directory is sub-directory of the source directory. sl@0: //! (e.g. "C:SRC\\*.TXT" -> "C:\\SRC\\SUB\\") sl@0: //! @SYMTestActions Move, copy files recursively from source directory to one of its sub-directory, sl@0: //! with or without wildcards applied. sl@0: //! @SYMTestExpectedResults Completes with no error, file(s) are moved or copied properly, and no redundant sl@0: //! movings or copyings are made for files in destination directory. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //--------------------------------------------- sl@0: test.Next(_L("Test recursive moving and copying to sub-directories")); sl@0: // Testing recursive Move() without wildcard sl@0: SetupDirectoriesForCase0520(); sl@0: SetupDirectoriesForCase0520Compare1(); sl@0: if (!gAsynch) sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC106735\\F_ROOT.TXT"), _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\*"), CFileMan::ERecurse); sl@0: else sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC106735\\F_ROOT.TXT"), _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\*"), CFileMan::ERecurse, gStat); sl@0: TestResult(err, KErrNone); sl@0: Compare(_L("\\F32-TST\\TFMAN\\INC106735\\"), _L("\\F32-TST\\TFMAN\\INC106735_COM\\")); sl@0: sl@0: // Testing recursive Move() with wildcard sl@0: SetupDirectoriesForCase0520(); sl@0: SetupDirectoriesForCase0520Compare2(); sl@0: if (!gAsynch) sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC106735\\*.TXT"), _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\"), CFileMan::ERecurse); sl@0: else sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC106735\\*.TXT"), _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\"), CFileMan::ERecurse, gStat); sl@0: TestResult(err, KErrNone); sl@0: Compare(_L("\\F32-TST\\TFMAN\\INC106735\\"), _L("\\F32-TST\\TFMAN\\INC106735_COM\\")); sl@0: sl@0: // Testing recursive Copy() without wildcard sl@0: SetupDirectoriesForCase0520(); sl@0: SetupDirectoriesForCase0520Compare3(); sl@0: if (!gAsynch) sl@0: err = gFileMan->Copy(_L("\\F32-TST\\TFMAN\\INC106735\\F_ROOT.TXT"), _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\"), CFileMan::ERecurse); sl@0: else sl@0: err = gFileMan->Copy(_L("\\F32-TST\\TFMAN\\INC106735\\F_ROOT.TXT"), _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\"), CFileMan::ERecurse, gStat); sl@0: TestResult(err, KErrNone); sl@0: Compare(_L("\\F32-TST\\TFMAN\\INC106735\\"), _L("\\F32-TST\\TFMAN\\INC106735_COM\\")); sl@0: sl@0: // Testing recursive Copy() with wildcard sl@0: SetupDirectoriesForCase0520(); sl@0: SetupDirectoriesForCase0520Compare4(); sl@0: if (!gAsynch) sl@0: err = gFileMan->Copy(_L("\\F32-TST\\TFMAN\\INC106735\\*.TXT"), _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\"), CFileMan::ERecurse); sl@0: else sl@0: err = gFileMan->Copy(_L("\\F32-TST\\TFMAN\\INC106735\\*.TXT"), _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\"), CFileMan::ERecurse, gStat); sl@0: TestResult(err, KErrNone); sl@0: Compare(_L("\\F32-TST\\TFMAN\\INC106735\\"), _L("\\F32-TST\\TFMAN\\INC106735_COM\\")); sl@0: sl@0: TestINC089638(); // Test all items removed from source directory after recursive moving sl@0: TestINC101379(); // Test moving of directory to its subdirectory recursively and not recursively sl@0: TestINC099600(); // and INC101061, Test move files from internal drive to external with system sl@0: // and hidden attributes sl@0: } sl@0: sl@0: sl@0: // sl@0: // A complex test directory structure... sl@0: // sl@0: LOCAL_D const TInt KNumFiles = 8; sl@0: LOCAL_D const TFileName complexFile[] = sl@0: { sl@0: _L("\\F32-TST\\TFMAN\\complex\\dir1\\file1.txt"), sl@0: _L("\\F32-TST\\TFMAN\\complex\\dir1\\file2.txt"), sl@0: _L("\\F32-TST\\TFMAN\\complex\\dir1\\subdir1\\file3.txt"), sl@0: _L("\\F32-TST\\TFMAN\\complex\\dir1\\subdir1\\file4.txt"), sl@0: _L("\\F32-TST\\TFMAN\\complex\\dir12\\dir1\\file1.txt"), sl@0: _L("\\F32-TST\\TFMAN\\complex\\dir12\\dir1\\file2.txt"), sl@0: _L("\\F32-TST\\TFMAN\\complex\\dir12\\dir1\\subdir1\\file3.txt"), sl@0: _L("\\F32-TST\\TFMAN\\complex\\dir12\\dir1\\subdir1\\file4.txt") sl@0: }; sl@0: sl@0: // sl@0: // The expected result of moving the directory complex\\dir1 into complex\\dir2\\ *without* EOverWrite sl@0: // sl@0: LOCAL_D const TInt KNumFilesResult1 = 8; sl@0: LOCAL_D const TFileName complexResult1[] = sl@0: { sl@0: _L("\\F32-TST\\TFMAN\\complex_result1\\dir1\\file1.txt"), sl@0: _L("\\F32-TST\\TFMAN\\complex_result1\\dir1\\file2.txt"), sl@0: _L("\\F32-TST\\TFMAN\\complex_result1\\dir1\\subdir1\\file3.txt"), sl@0: _L("\\F32-TST\\TFMAN\\complex_result1\\dir1\\subdir1\\file4.txt"), sl@0: _L("\\F32-TST\\TFMAN\\complex_result1\\dir12\\dir1\\file1.txt"), sl@0: _L("\\F32-TST\\TFMAN\\complex_result1\\dir12\\dir1\\file2.txt"), sl@0: _L("\\F32-TST\\TFMAN\\complex_result1\\dir12\\dir1\\subdir1\\file3.txt"), sl@0: _L("\\F32-TST\\TFMAN\\complex_result1\\dir12\\dir1\\subdir1\\file4.txt") sl@0: }; sl@0: sl@0: // sl@0: // The expected result of moving the directory complex\\dir1 into complex\\dir2\\ *with* EOverWrite sl@0: // sl@0: LOCAL_D const TInt KNumFilesResult2 = 4; sl@0: LOCAL_D const TFileName complexResult2[] = sl@0: { sl@0: _L("\\F32-TST\\TFMAN\\complex_result2\\dir12\\dir1\\file1.txt"), sl@0: _L("\\F32-TST\\TFMAN\\complex_result2\\dir12\\dir1\\file2.txt"), sl@0: _L("\\F32-TST\\TFMAN\\complex_result2\\dir12\\dir1\\subdir1\\file3.txt"), sl@0: _L("\\F32-TST\\TFMAN\\complex_result2\\dir12\\dir1\\subdir1\\file4.txt"), sl@0: sl@0: }; sl@0: sl@0: sl@0: LOCAL_C void TestRecursiveMoveAcrossDrives() sl@0: // sl@0: // Test recursive move across drives sl@0: // sl@0: { sl@0: test.Next(_L("Test recursive move across drives")); sl@0: sl@0: TFileName trgDir = _L("\\F32-TST\\TFMAN\\RECMOVE2\\"); sl@0: TFileName trgSpec = _L("\\F32-TST\\TFMAN\\RECMOVE2\\*"); sl@0: sl@0: if (gSessionPath[0]=='C') sl@0: { sl@0: #if !defined(__WINS__) sl@0: trgDir = _L("D:\\F32-TST\\TFMAN\\RECMOVE2\\"); sl@0: trgSpec = _L("D:\\F32-TST\\TFMAN\\RECMOVE2\\*"); sl@0: #else sl@0: trgDir = _L("Y:\\F32-TST\\TFMAN\\RECMOVE2\\"); sl@0: trgSpec = _L("Y:\\F32-TST\\TFMAN\\RECMOVE2\\*"); sl@0: #endif sl@0: } sl@0: sl@0: RmDir(trgDir); sl@0: sl@0: MakeFile(_L("C:\\F32-TST\\TFMAN\\RECMOVE\\FULL\\FILE2.PLP")); sl@0: MakeFile(_L("C:\\F32-TST\\TFMAN\\RECMOVE\\FULL\\FILE3.PLP")); sl@0: MakeFile(_L("C:\\F32-TST\\TFMAN\\RECMOVE\\FULL\\GRAPE.TXT")); sl@0: MakeFile(_L("C:\\F32-TST\\TFMAN\\RECMOVE\\GRAPE.TXT")); sl@0: MakeFile(_L("C:\\F32-TST\\TFMAN\\RECMOVE\\FILE1.PLP")); sl@0: sl@0: TInt err; sl@0: if (!gAsynch) sl@0: err=gFileMan->Move(_L("C:\\F32-TST\\TFMAN\\RECMOVE\\*.PLP"),trgDir,CFileMan::ERecurse); sl@0: else sl@0: err=gFileMan->Move(_L("C:\\F32-TST\\TFMAN\\RECMOVE\\*.PLP"),trgDir,CFileMan::ERecurse,gStat); sl@0: test.Printf(_L("TestRecursiveMoveAcrossDrives(),gFileMan->Move(),err=%d\n"),err); sl@0: TestResult(err); sl@0: sl@0: RmDir(_L("C:\\F32-TST\\TFMAN\\after\\")); sl@0: MakeFile(_L("C:\\F32-TST\\TFMAN\\AFTER\\FULL\\FILE2.PLP")); sl@0: MakeFile(_L("C:\\F32-TST\\TFMAN\\AFTER\\FULL\\FILE3.PLP")); sl@0: MakeFile(_L("C:\\F32-TST\\TFMAN\\AFTER\\FILE1.PLP")); sl@0: Compare(_L("C:\\F32-TST\\TFMAN\\after\\*"),trgSpec); sl@0: RmDir(_L("C:\\F32-TST\\TFMAN\\AFTER\\")); sl@0: RmDir(_L("C:\\F32-TST\\TFMAN\\RECMOVE\\")); sl@0: sl@0: // sl@0: // Test moving empty directories (DEF073924) sl@0: // sl@0: test.Next(_L("Test moving empty directories")); sl@0: sl@0: TFileName destOtherDrive; sl@0: SetupDirectories(EFalse, &destOtherDrive); sl@0: sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\"), destOtherDrive, CFileMan::ERecurse); sl@0: test(err == KErrNotFound); // Expected - directory is empty sl@0: sl@0: // Test that all directories are still present sl@0: TEntry entry; sl@0: err = TheFs.Entry(_L("\\F32-TST\\TFMAN\\source\\"), entry); sl@0: test(err == KErrNone); sl@0: err = TheFs.Entry(destOtherDrive, entry); sl@0: test(err == KErrNone); sl@0: sl@0: //--------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_FMAN-0571 sl@0: //! @SYMTestType UT sl@0: //! @SYMREQ INC108401 sl@0: //! @SYMTestCaseDesc This testcase tests the synchronous and asynchronous move operations sl@0: //! exhaustively with flags set as 0, CFileMan::EOverWrite, CFileMan::ERecurse sl@0: //! on the SAME and ACROSS drives without trailing slash at the end of source sl@0: //! dir path. sl@0: //! @SYMTestActions 1. Copy directory structures to another directory across drive. sl@0: //! 2. Copy directory structures to another directory across drive overwriting sl@0: //! duplicate files. sl@0: //! 3. Copy directory structures to another directory across drive. sl@0: //! 4. Copy directory structures to another directory on same drive. sl@0: //! 5. Copy directory structures to another directory on same drive overwriting sl@0: //! duplicate files. sl@0: //! 6. Copy directory structures to another directory on same drive. sl@0: //! @SYMTestExpectedResults 1. Completes with no error, the last directory and its contents are moved sl@0: //! from the src directory to the destination directory. sl@0: //! 2. Completes with no error, the last directory and its contents are moved sl@0: //! from the src directory to the destination directory, duplicate files are updated. sl@0: //! 3. Completes with no error, the last directory and its contents are moved sl@0: //! from the src directory to the destination directory. sl@0: //! 4. Completes with no error, the last directory and its contents are moved sl@0: //! from the src directory to the destination directory. sl@0: //! 5. Completes with no error, the last directory and its contents are moved sl@0: //! from the src directory to the destination directory, duplicate files are updated. sl@0: //! 6. Completes with no error, the last directory and its contents are moved sl@0: //! from the src directory to the destination directory. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //--------------------------------------------- sl@0: sl@0: TestINC108401(); sl@0: sl@0: // sl@0: // Test moving when the source directory contains subdirectories (INC074828, INC078800) sl@0: // sl@0: test.Next(_L("Test moving a directory containing subdirectories")); sl@0: sl@0: SetupDirectories(ETrue, &destOtherDrive); sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\"), destOtherDrive, CFileMan::ERecurse | CFileMan::EOverWrite); sl@0: test(err == KErrNone); sl@0: sl@0: destOtherDrive.Append(_L("*")); sl@0: Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), destOtherDrive); sl@0: sl@0: //--------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_FMAN-0161 sl@0: //! @SYMTestType UT sl@0: //! @SYMREQ DEF087791 sl@0: //! @SYMTestCaseDesc Test that CFileMan::Move() works when the destination paths does not exist. sl@0: //! @SYMTestActions Copy directory structures to a non-existant directory on a different drive. sl@0: //! @SYMTestExpectedResults Completes with no error, files are copied and intermediate directories are created. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //--------------------------------------------- sl@0: test.Next(_L("Test moving when the target directory does not exist")); sl@0: sl@0: SetupDirectories(ETrue, &destOtherDrive); sl@0: sl@0: RmDir(destOtherDrive); sl@0: sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\"), destOtherDrive, CFileMan::ERecurse); sl@0: test(err == KErrNone); sl@0: sl@0: Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), destOtherDrive); sl@0: sl@0: SetupDirectories(ETrue, &destOtherDrive); sl@0: sl@0: RmDir(destOtherDrive); sl@0: sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source"), destOtherDrive, CFileMan::ERecurse); sl@0: test(err == KErrNone); sl@0: sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\compare\\subdir\\")); sl@0: destOtherDrive.Append(_L("source\\")); sl@0: Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), destOtherDrive); sl@0: RmDir(_L("\\F32-TST\\TFMAN\\compare\\subdir\\")); sl@0: sl@0: SetupDirectories(ETrue, &destOtherDrive); sl@0: sl@0: RmDir(destOtherDrive); sl@0: sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\File1.TXT"), destOtherDrive, CFileMan::ERecurse); sl@0: test(err == KErrNone); sl@0: sl@0: CheckFileExists(_L("\\F32-TST\\TFMAN\\source\\File1.TXT"), KErrNotFound, ETrue); sl@0: destOtherDrive.Append(_L("File1.TXT")); sl@0: CheckFileExists(destOtherDrive, KErrNone, ETrue); sl@0: sl@0: RmDir(destOtherDrive); sl@0: RmDir(_L("\\F32-TST\\TFMAN\\source\\")); sl@0: sl@0: // sl@0: // Test recursive move of complex directory structure into itself (INC078759) sl@0: // sl@0: sl@0: test.Next(_L("Test recursive move of complex directory structure")); sl@0: sl@0: // Set up the test directory sl@0: TInt level = 0; sl@0: for(level=0; level < KNumFiles; level++) sl@0: { sl@0: err = TheFs.MkDirAll(complexFile[level]); sl@0: test(err == KErrNone || err == KErrAlreadyExists); sl@0: sl@0: RFile file; sl@0: err = file.Create(TheFs, complexFile[level], EFileRead | EFileWrite); sl@0: test(err == KErrNone || err == KErrAlreadyExists || err == KErrBadName); sl@0: file.Close(); sl@0: } sl@0: sl@0: // sl@0: // Move directory 'dir1' into 'dir12' *without* overwrite flag set sl@0: // sl@0: // - This should fail, as 'dir12' already contains a directory called 'dir1' sl@0: // - No directories should be modified sl@0: // sl@0: sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\complex\\dir1"), _L("\\F32-TST\\TFMAN\\complex\\dir12\\"), CFileMan::ERecurse); sl@0: test(err == KErrAlreadyExists); sl@0: sl@0: for(level=0; level < KNumFilesResult1; level++) sl@0: { sl@0: err = TheFs.MkDirAll(complexResult1[level]); sl@0: test(err == KErrNone || err == KErrAlreadyExists); sl@0: sl@0: RFile file; sl@0: err = file.Create(TheFs, complexResult1[level], EFileRead | EFileWrite); sl@0: test(err == KErrNone || err == KErrAlreadyExists || err == KErrBadName); sl@0: file.Close(); sl@0: } sl@0: sl@0: Compare(_L("\\F32-TST\\TFMAN\\complex_result1\\*"), _L("\\F32-TST\\TFMAN\\complex\\*")); sl@0: sl@0: // sl@0: // Move directory 'dir1' into 'dir12' *with* overwrite flag set sl@0: // sl@0: err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\complex\\dir1"), _L("\\F32-TST\\TFMAN\\complex\\dir12\\"), CFileMan::ERecurse | CFileMan::EOverWrite); sl@0: test(err == KErrNone); sl@0: sl@0: for(level=0; level < KNumFilesResult2; level++) sl@0: { sl@0: err = TheFs.MkDirAll(complexResult2[level]); sl@0: test(err == KErrNone || err == KErrAlreadyExists); sl@0: sl@0: RFile file; sl@0: err = file.Create(TheFs, complexResult2[level], EFileRead | EFileWrite); sl@0: test(err == KErrNone || err == KErrAlreadyExists || err == KErrBadName); sl@0: file.Close(); sl@0: } sl@0: sl@0: Compare(_L("\\F32-TST\\TFMAN\\complex_result2\\*"), _L("\\F32-TST\\TFMAN\\complex\\*")); sl@0: sl@0: // ...tidy up files sl@0: for(level=0; level < KNumFiles; level++) sl@0: TheFs.Delete(complexFile[level]); sl@0: for(level=0; level < KNumFilesResult1; level++) sl@0: TheFs.Delete(complexResult1[level]); sl@0: for(level=0; level < KNumFilesResult2; level++) sl@0: TheFs.Delete(complexResult2[level]); sl@0: sl@0: // ...tidy up directories sl@0: for(level=0; level < KNumFiles; level++) sl@0: TheFs.RmDir(complexFile[level]); sl@0: for(level=0; level < KNumFilesResult1; level++) sl@0: TheFs.RmDir(complexResult1[level]); sl@0: for(level=0; level < KNumFilesResult2; level++) sl@0: TheFs.RmDir(complexResult2[level]); sl@0: sl@0: TheFs.RmDir(_L("C:\\F32-TST\\TFMAN\\")); sl@0: TheFs.RmDir(_L("C:\\F32-TST\\")); sl@0: } sl@0: sl@0: class CFileManCopyAllCancel : public CBase, public MFileManObserver sl@0: { sl@0: public: sl@0: CFileManCopyAllCancel(CFileMan* aFileMan); sl@0: TControl NotifyFileManStarted(); sl@0: TControl NotifyFileManEnded(); sl@0: sl@0: private: sl@0: CFileMan* iFileMan; sl@0: }; sl@0: sl@0: sl@0: CFileManCopyAllCancel::CFileManCopyAllCancel(CFileMan* aFileMan) sl@0: // sl@0: // Constructor sl@0: // sl@0: { sl@0: __DECLARE_NAME(_S("CFileManCopyAllCancel")); sl@0: iFileMan=aFileMan; sl@0: } sl@0: sl@0: MFileManObserver::TControl CFileManCopyAllCancel::NotifyFileManStarted() sl@0: // sl@0: // Observer for TestCopyAllCancel tests sl@0: // sl@0: { sl@0: return(MFileManObserver::ECancel); sl@0: } sl@0: sl@0: MFileManObserver::TControl CFileManCopyAllCancel::NotifyFileManEnded() sl@0: // sl@0: // Observer for TestCopyAllCancel tests sl@0: // sl@0: { sl@0: return(MFileManObserver::EContinue); sl@0: } sl@0: sl@0: sl@0: sl@0: LOCAL_C void TestCopyAllCancel() sl@0: // sl@0: // Test copy (all cancel) sl@0: // sl@0: { sl@0: test.Next(_L("Test copy all cancel")); sl@0: sl@0: RmDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\*")); sl@0: CFileManCopyAllCancel* fManObserver=new(ELeave) CFileManCopyAllCancel(gFileMan); sl@0: CleanupStack::PushL(fManObserver); sl@0: gFileMan->SetObserver(fManObserver); sl@0: sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\")); sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EMPTY\\")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\NewDir\\ABC.DEF")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE2.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE3.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\FILE4.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EXE1.BIN")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\EXE2.BIN")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA1.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA2.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA3.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA4.TXT")); sl@0: sl@0: test.Next(_L("Test cancel copy all the files ")); sl@0: TInt r; sl@0: sl@0: if (!gAsynch) sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0); sl@0: else sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0,gStat); sl@0: TestResult(r,KErrCancel); sl@0: sl@0: if (!gAsynch) sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.txt"),_L("\\F32-TST\\TFMAN\\file1.txt"),0); sl@0: else sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.txt"),_L("\\F32-TST\\TFMAN\\file1.txt"),0,gStat); sl@0: TestResult(r,KErrCancel); sl@0: gFileMan->SetObserver(gObserver); sl@0: CleanupStack::PopAndDestroy(); sl@0: } sl@0: sl@0: class CFileManObserverOverWrite : public CBase, public MFileManObserver sl@0: { sl@0: public: sl@0: CFileManObserverOverWrite(CFileMan* aFileMan); sl@0: TControl NotifyFileManEnded(); sl@0: private: sl@0: CFileMan* iFileMan; sl@0: }; sl@0: sl@0: sl@0: CFileManObserverOverWrite::CFileManObserverOverWrite(CFileMan* aFileMan) sl@0: // sl@0: // Constructor sl@0: // sl@0: { sl@0: __DECLARE_NAME(_S("CFileManObserverOverWrite")); sl@0: iFileMan=aFileMan; sl@0: } sl@0: sl@0: sl@0: MFileManObserver::TControl CFileManObserverOverWrite::NotifyFileManEnded() sl@0: // sl@0: // Observer for testoverwrite tests sl@0: // sl@0: { sl@0: TInt lastError=iFileMan->GetLastError(); sl@0: if (lastError!=KErrNone) sl@0: { sl@0: test(lastError==KErrAlreadyExists); sl@0: if (gAsynch==EFalse) sl@0: { sl@0: TFileName fileName=iFileMan->CurrentEntry().iName; sl@0: test.Printf(_L(" %S already exists\n"),&fileName); sl@0: } sl@0: } sl@0: return(MFileManObserver::EContinue); sl@0: } sl@0: sl@0: LOCAL_C void TestOverWrite() sl@0: // sl@0: // Test overwrite for copy and rename sl@0: // sl@0: { sl@0: test.Next(_L("Test overwrite option")); sl@0: RmDir(_L("\\F32-TST\\TFMAN\\OVERWRITE\\")); sl@0: CFileManObserverOverWrite* fManObserver=new(ELeave) CFileManObserverOverWrite(gFileMan); sl@0: CleanupStack::PushL(fManObserver); sl@0: gFileMan->SetObserver(fManObserver); sl@0: sl@0: TBuf8<128> contentsFile1=_L8("Test file one contents"); sl@0: TBuf8<128> contentsFile2=_L8("Test file two contents"); sl@0: sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\FILE1.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\FILE2.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC\\FILE1.TXT"),contentsFile1); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC\\FILE2.TXT"),contentsFile2); sl@0: sl@0: if (!gAsynch) sl@0: { sl@0: TInt r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC"),_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG"),0); sl@0: test(r==KErrAlreadyExists); sl@0: } sl@0: else sl@0: { sl@0: TInt r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC"),_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG"),0,gStat); sl@0: test(r==KErrNone); sl@0: WaitForResult(KErrAlreadyExists); sl@0: } sl@0: sl@0: RFile f; sl@0: TInt r=f.Open(TheFs,_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\FILE1.TXT"),EFileRead); sl@0: test(r==KErrNone); sl@0: TBuf8<128> data; sl@0: r=f.Read(data); sl@0: test(r==KErrNone); sl@0: test(data.Length()==0); sl@0: f.Close(); sl@0: sl@0: if (!gAsynch) sl@0: { sl@0: TInt r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC"),_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG"),CFileMan::EOverWrite); sl@0: test(r==KErrNone); sl@0: } sl@0: else sl@0: { sl@0: TInt r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC"),_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG"),CFileMan::EOverWrite,gStat); sl@0: test(r==KErrNone); sl@0: WaitForSuccess(); sl@0: } sl@0: sl@0: r=f.Open(TheFs,_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\FILE1.TXT"),EFileRead); sl@0: test(r==KErrNone); sl@0: r=f.Read(data); sl@0: test(r==KErrNone); sl@0: test(data==contentsFile1); sl@0: f.Close(); sl@0: sl@0: RmDir(_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\FILE1.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\FILE2.TXT")); sl@0: sl@0: if (!gAsynch) sl@0: { sl@0: TInt r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC\\*"),_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\*"),0); sl@0: test(r==KErrAlreadyExists); sl@0: } sl@0: else sl@0: { sl@0: TInt r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC\\*"),_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\*"),0,gStat); sl@0: test(r==KErrNone); sl@0: WaitForResult(KErrAlreadyExists); sl@0: } sl@0: sl@0: r=f.Open(TheFs,_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\FILE2.TXT"),EFileRead); sl@0: test(r==KErrNone); sl@0: r=f.Read(data); sl@0: test(r==KErrNone); sl@0: test(data.Length()==0); sl@0: f.Close(); sl@0: sl@0: if (!gAsynch) sl@0: { sl@0: TInt r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC\\*"),_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\*"),CFileMan::EOverWrite); sl@0: test(r==KErrNone); sl@0: } sl@0: else sl@0: { sl@0: TInt r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC\\*"),_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\*"),CFileMan::EOverWrite,gStat); sl@0: test(r==KErrNone); sl@0: WaitForSuccess(); sl@0: } sl@0: sl@0: r=f.Open(TheFs,_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\FILE2.TXT"),EFileRead); sl@0: test(r==KErrNone); sl@0: r=f.Read(data); sl@0: test(r==KErrNone); sl@0: test(data==contentsFile2); sl@0: f.Close(); sl@0: gFileMan->SetObserver(gObserver); sl@0: CleanupStack::PopAndDestroy(); sl@0: } sl@0: sl@0: LOCAL_C void TestErrorHandling() sl@0: // sl@0: // Test bad paths etc sl@0: // sl@0: { sl@0: test.Next(_L("Test error handling")); sl@0: if (!gAsynch) sl@0: { sl@0: TInt r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\BADPATH\\*")); sl@0: test(r==KErrPathNotFound); sl@0: } sl@0: else sl@0: { sl@0: TInt r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\BADPATH\\*"),0,gStat); sl@0: test(r==KErrNone); sl@0: WaitForResult(KErrPathNotFound); sl@0: } sl@0: sl@0: CFileMan* fMan=CFileMan::NewL(TheFs); sl@0: TInt r; sl@0: { sl@0: for(TInt drvNum=EDriveA; drvNum<=EDriveZ; ++drvNum) sl@0: { sl@0: TDriveInfo drvInfo; sl@0: if(KErrNone==TheFs.Drive(drvInfo, drvNum) && drvInfo.iType==EMediaNotPresent) sl@0: { sl@0: // found a non-extant drive, test it... sl@0: _LIT(KBad,"?:\\BADPATH\\*"); sl@0: TBuf<16> bad(KBad); sl@0: bad[0] = TUint16('A'+drvNum); sl@0: TInt r=fMan->Delete(bad); sl@0: test(r==KErrNotReady); sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: delete fMan; sl@0: sl@0: MakeFile(_L("\\ONE\\TWO\\FILE1.TXT")); sl@0: MakeFile(_L("\\ONE\\TWO\\FOUR")); sl@0: test.Next(_L("Test cyclic copy")); sl@0: if (!gAsynch) sl@0: r=gFileMan->Copy(_L("\\ONE\\TWO\\*"),_L("\\ONE\\TWO\\THREE\\"),CFileMan::ERecurse); sl@0: else sl@0: r=gFileMan->Copy(_L("\\ONE\\TWO\\*"),_L("\\ONE\\TWO\\THREE\\"),CFileMan::ERecurse,gStat); sl@0: test(r==KErrArgument); sl@0: sl@0: test.Next(_L("Test src name == trg name")); sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Copy(_L("\\ONE\\TWO\\FOUR"),_L("\\ONE\\TWO\\FOUR")); // default aSwitch=EOverWrite sl@0: test(r==KErrNone); sl@0: r=gFileMan->Copy(_L("\\ONE\\TWO\\FOUR"),_L("\\ONE\\TWO\\FOUR"), 0); sl@0: test(r==KErrAlreadyExists); sl@0: r=gFileMan->Copy(_L("\\ONE\\TWO\\FOUR"),_L("\\ONE\\TWO\\FOUR"),CFileMan::ERecurse); sl@0: test(r==KErrAlreadyExists); sl@0: r=gFileMan->Copy(_L("\\ONE\\TWO\\F*R"),_L("\\ONE\\TWO\\FOUR"),CFileMan::ERecurse); sl@0: test(r==KErrAlreadyExists); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Copy(_L("\\ONE\\TWO\\*.TXT"),_L("\\ONE\\TWO\\*.TXT"),0,gStat); sl@0: test(r==KErrNone); sl@0: WaitForResult(KErrAlreadyExists); sl@0: r=gFileMan->Copy(_L("\\ONE\\TWO\\FOUR"),_L("\\ONE\\TWO\\F*R"),CFileMan::ERecurse,gStat); sl@0: test(r==KErrNone); sl@0: WaitForResult(KErrNone); sl@0: } sl@0: RmDir(_L("\\ONE\\")); sl@0: sl@0: test.Next(_L("Test copy missing source and path")); sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Copy(_L("\\ONE\\TWO\\XXXYYY"),_L("\\ONE\\TWO\\asdfsadf")); sl@0: test(r==KErrPathNotFound); sl@0: r=gFileMan->Copy(_L("\\ONE\\TWO\\XXXYYY"),_L("\\ONE\\TWO\\asdfsadf"),CFileMan::ERecurse); sl@0: test(r==KErrPathNotFound); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Copy(_L("\\ONE\\TWO\\*.TXT"),_L("\\ONE\\TWO\\*.YYY"),0,gStat); sl@0: test(r==KErrNone); sl@0: WaitForResult(KErrPathNotFound); sl@0: r=gFileMan->Copy(_L("\\ONE\\TWO\\XXXYYY"),_L("\\ONE\\TWO\\asdfsadf"),CFileMan::ERecurse,gStat); sl@0: test(r==KErrNone); sl@0: WaitForResult(KErrPathNotFound); sl@0: } sl@0: sl@0: test.Next(_L("Test copy missing source")); sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\*.LPQ"),_L("\\ONE\\TWO\\*.YYY")); sl@0: test(r==KErrNotFound); sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\XXXYYY"),_L("\\ONE\\TWO\\asdfsadf"),CFileMan::ERecurse); sl@0: test(r==KErrNotFound); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\XXXYYY"),_L("\\ONE\\TWO\\asdfsadf"),0,gStat); sl@0: test(r==KErrNone); sl@0: WaitForResult(KErrNotFound); sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\XXXYYY"),_L("\\ONE\\TWO\\asdfsadf"),CFileMan::ERecurse,gStat); sl@0: test(r==KErrNone); sl@0: WaitForResult(KErrNotFound); sl@0: } sl@0: sl@0: RmDir(_L("\\EMPTYSRC\\")); sl@0: MakeDir(_L("\\EMPTYSRC\\")); sl@0: RmDir(_L("\\EMPTYTRG\\")); sl@0: MakeDir(_L("\\EMPTYTRG\\")); sl@0: test.Next(_L("Test copy empty source directory")); sl@0: if (!gAsynch) sl@0: { sl@0: r=gFileMan->Copy(_L("\\EMPTYSRC\\"),_L("\\EMPTYTRG\\")); sl@0: test(r==KErrNotFound); sl@0: r=gFileMan->Copy(_L("\\EMPTYSRC\\"),_L("\\EMPTYTRG\\"), CFileMan::ERecurse); sl@0: test(r==KErrNotFound); sl@0: r=gFileMan->Copy(_L("\\EMPTYSRC"),_L("\\EMPTYTRG\\")); sl@0: test(r==KErrNotFound); sl@0: r=gFileMan->Copy(_L("\\EMPTYSRC"),_L("\\EMPTYTRG\\"), CFileMan::ERecurse); sl@0: test(r==KErrNotFound); sl@0: } sl@0: else sl@0: { sl@0: r=gFileMan->Copy(_L("\\EMPTYSRC\\"),_L("\\EMPTYTRG\\"), 0, gStat); sl@0: test(r==KErrNone); sl@0: WaitForResult(KErrNotFound); sl@0: r=gFileMan->Copy(_L("\\EMPTYSRC\\"),_L("\\EMPTYTRG\\"), CFileMan::ERecurse, gStat); sl@0: test(r==KErrNone); sl@0: WaitForResult(KErrNotFound); sl@0: r=gFileMan->Copy(_L("\\EMPTYSRC"),_L("\\EMPTYTRG\\"), 0, gStat); sl@0: test(r==KErrNone); sl@0: WaitForResult(KErrNotFound); sl@0: r=gFileMan->Copy(_L("\\EMPTYSRC"),_L("\\EMPTYTRG\\"), CFileMan::ERecurse, gStat); sl@0: test(r==KErrNone); sl@0: WaitForResult(KErrNotFound); sl@0: } sl@0: RmDir(_L("\\EMPTYSRC\\")); sl@0: RmDir(_L("\\EMPTYTRG\\")); sl@0: sl@0: sl@0: MakeFile(_L("Dummyfile")); sl@0: test.Next(_L("Test illegal names")); sl@0: r=gFileMan->Attribs(_L(":C:"),0,0,TTime(0),0); sl@0: test(r==KErrBadName); sl@0: r=gFileMan->Copy(_L(":C:"),_L("newname"),0); sl@0: test(r==KErrBadName); sl@0: r=gFileMan->Copy(_L("Dummyfile"),_L(":C:"),0); sl@0: test(r==KErrBadName); sl@0: r=gFileMan->Delete(_L(":C:"),0); sl@0: test(r==KErrBadName); sl@0: r=gFileMan->Move(_L(":C:"),_L("newname"),0); sl@0: test(r==KErrBadName); sl@0: r=gFileMan->Move(_L("dummyFile"),_L(":C:"),0); sl@0: test(r==KErrBadName); sl@0: r=gFileMan->Rename(_L(":C:"),_L("newname"),0); sl@0: test(r==KErrBadName); sl@0: r=gFileMan->Rename(_L("DummyFile"),_L(":C:"),0); sl@0: test(r==KErrBadName); sl@0: r=gFileMan->RmDir(_L("\\:C:\\")); sl@0: test(r==KErrBadName); sl@0: sl@0: r=gFileMan->Attribs(_L("::C:"),0,0,TTime(0),0); sl@0: test(r==KErrBadName); sl@0: r=gFileMan->Copy(_L("::C:"),_L("newname"),0); sl@0: test(r==KErrBadName); sl@0: r=gFileMan->Copy(_L("Dummyfile"),_L("::C:"),0); sl@0: test(r==KErrBadName); sl@0: r=gFileMan->Delete(_L("::C:"),0); sl@0: test(r==KErrBadName); sl@0: r=gFileMan->Move(_L("::C:"),_L("newname"),0); sl@0: test(r==KErrBadName); sl@0: r=gFileMan->Move(_L("dummyFile"),_L("::C:"),0); sl@0: test(r==KErrBadName); sl@0: r=gFileMan->Rename(_L("::C:"),_L("newname"),0); sl@0: test(r==KErrBadName); sl@0: r=gFileMan->Rename(_L("DummyFile"),_L("::C:"),0); sl@0: test(r==KErrBadName); sl@0: r=gFileMan->RmDir(_L("::C:")); sl@0: test(r==KErrBadName); sl@0: r=TheFs.Delete(_L("DummyFile")); sl@0: test(r==KErrNone); sl@0: // test copying two files with identical names that do not exist sl@0: _LIT(KNonExistent,"\\azzzz.txt"); sl@0: r=gFileMan->Copy(KNonExistent,KNonExistent,0); sl@0: test(r==KErrNotFound); sl@0: } sl@0: sl@0: LOCAL_C void TestNameMangling() sl@0: // sl@0: // Synchronous test of name mangling sl@0: // sl@0: { sl@0: test.Next(_L("Test name mangling")); sl@0: gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\TRG\\")); sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\TRG\\")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\abc.def")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\abcdefghijk.def")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\abc.defgh")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\abcdefghijk.defgh")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\zyx.abc.def")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\zyx.abcdefghijk.def")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\zyx.abc.defgh")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\zyx.abcdefghijk.defgh")); sl@0: sl@0: TInt r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\*.*"),_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\TRG\\*.*")); sl@0: test(r==KErrNone); sl@0: Compare(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\*"),_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\TRG\\*")); sl@0: r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\TRG\\*.*")); sl@0: test(r==KErrNone); sl@0: } sl@0: sl@0: LOCAL_C void TestLongNames() sl@0: // sl@0: // Synchronous test of name mangling sl@0: // sl@0: { sl@0: #if defined(__WINS__) sl@0: if (gSessionPath[0]=='C') sl@0: return; sl@0: #endif sl@0: sl@0: gFileMan->SetObserver(NULL); sl@0: sl@0: // Format the current drive sl@0: Format(CurrentDrive()); sl@0: // Create Session Path sl@0: CreateTestDirectory(_L("\\F32-TST\\TFMAN\\")); sl@0: sl@0: // Create 2 root directories with very long names sl@0: TInt longFileLength = KMaxFileName-4; sl@0: test.Next(_L("Test methods on long names")); sl@0: TFileName longFileNameA; sl@0: longFileNameA.SetLength(longFileLength); sl@0: longFileNameA.Fill('A',longFileLength); sl@0: TFileName longRootDirNameA=_L("\\"); sl@0: longRootDirNameA+=longFileNameA; sl@0: longRootDirNameA+=_L("\\"); sl@0: TInt r=TheFs.MkDir(longRootDirNameA); sl@0: test(r==KErrNone || r==KErrAlreadyExists); sl@0: // Second folder sl@0: TFileName longFileNameB; sl@0: longFileNameB.SetLength(longFileLength); sl@0: longFileNameB.Fill('B',longFileLength); sl@0: TFileName longRootDirNameB=_L("\\"); sl@0: longRootDirNameB+=longFileNameB; sl@0: longRootDirNameB+=_L("\\"); sl@0: r=TheFs.MkDir(longRootDirNameB); sl@0: test(r==KErrNone || r==KErrAlreadyExists); sl@0: sl@0: TInt longFilePtrLength = KMaxFileName-3; // We do not want the trailing backslash sl@0: TPtrC ptrLongFileA(longRootDirNameA.Ptr(),longFilePtrLength); sl@0: TPtrC ptrLongFileB(longRootDirNameB.Ptr(),longFilePtrLength); sl@0: sl@0: // TInt CFileMan::Move(const TDesC& anOld,const TDesC& aNew,TUint aSwitch=EOverWrite); sl@0: // Tries to move a folder with a long name into another sl@0: // This test will return KErrGeneral because the new path will exceed the maximum length sl@0: // See KMaxFileName sl@0: r=gFileMan->Move(ptrLongFileA,ptrLongFileB); sl@0: test(r==KErrGeneral); sl@0: sl@0: r=gFileMan->RmDir(longRootDirNameA); sl@0: test(r==KErrNone); sl@0: r=gFileMan->Rename(ptrLongFileB,ptrLongFileA); sl@0: test(r==KErrNone); sl@0: r=gFileMan->RmDir(longRootDirNameB); sl@0: test(r==KErrPathNotFound); sl@0: r=gFileMan->RmDir(longRootDirNameA); sl@0: test(r==KErrNone); sl@0: sl@0: TFileName longSubDirName=_L("\\Files\\"); sl@0: TPtrC longSubDirFileName(longFileNameA.Ptr(),longFilePtrLength-longSubDirName.Length()); sl@0: longSubDirName+=longSubDirFileName; sl@0: longSubDirName+=_L("\\"); sl@0: r=TheFs.MkDirAll(longSubDirName); sl@0: test(r==KErrNone); sl@0: sl@0: CDir* dirList; sl@0: r=TheFs.GetDir(longSubDirName,KEntryAttMaskSupported,0,dirList); sl@0: test(r==KErrNone); sl@0: test(dirList->Count()==0); sl@0: delete dirList; sl@0: sl@0: TPtrC ptrLongSubDirSrc(longSubDirName.Ptr(),longSubDirName.Length()-1); sl@0: TPtrC ptrLongSubDirTrg(longRootDirNameA.Ptr(),longRootDirNameA.Length()-1); sl@0: r=gFileMan->Copy(ptrLongSubDirSrc,ptrLongSubDirTrg); sl@0: test(r==KErrNone); sl@0: r=TheFs.MkDir(longRootDirNameB); sl@0: test(r==KErrNone); sl@0: r=gFileMan->Move(ptrLongSubDirSrc,longRootDirNameB); sl@0: test(r==KErrBadName); sl@0: r=TheFs.RmDir(longRootDirNameB); sl@0: test(r==KErrNone); sl@0: test(TheFs.RmDir(longSubDirName) == KErrNone); sl@0: test(TheFs.RmDir(_L("\\Files\\")) == KErrNone); sl@0: gFileMan->SetObserver(gObserver); sl@0: } sl@0: sl@0: LOCAL_C void TestFileAttributes() sl@0: // sl@0: // Test file attributes are copied and new settings sl@0: // sl@0: { sl@0: test.Next(_L("Test file attributes are copied")); sl@0: gFileMan->Delete(_L("\\F32-TST\\TFMAN\\FILEATT\\TRG\\*.*")); sl@0: MakeDir(_L("\\F32-TST\\TFMAN\\FILEATT\\TRG\\")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\FILEATT\\SRC\\readonly.def"),KEntryAttReadOnly); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\FILEATT\\SRC\\readonlyhidden.def"),KEntryAttReadOnly|KEntryAttHidden); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\FILEATT\\SRC\\hiddensystem.def"),KEntryAttHidden|KEntryAttSystem); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\FILEATT\\SRC\\systemarchive.def"),KEntryAttArchive|KEntryAttSystem); sl@0: sl@0: TInt r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\FILEATT\\SRC\\*.*"),_L("\\F32-TST\\TFMAN\\FILEATT\\TRG\\*.*")); sl@0: test(r==KErrNone); sl@0: Compare(_L("\\F32-TST\\TFMAN\\FILEATT\\SRC\\*.*"),_L("\\F32-TST\\TFMAN\\FILEATT\\TRG\\*")); sl@0: r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\FILEATT\\SRC\\*"),0,KEntryAttReadOnly,TTime(0)); sl@0: test(r==KErrNone); sl@0: r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\FILEATT\\TRG\\*"),0,KEntryAttReadOnly,TTime(0)); sl@0: test(r==KErrNone); sl@0: r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\FILEATT\\")); sl@0: test(r==KErrNone); sl@0: } sl@0: sl@0: class CFileManObserverContinue : public CBase, public MFileManObserver sl@0: { sl@0: public: sl@0: CFileManObserverContinue(CFileMan* aFileMan); sl@0: TControl NotifyFileManEnded(); sl@0: private: sl@0: CFileMan* iFileMan; sl@0: }; sl@0: sl@0: sl@0: CFileManObserverContinue::CFileManObserverContinue(CFileMan* aFileMan) sl@0: // sl@0: // Constructor sl@0: // sl@0: { sl@0: __DECLARE_NAME(_S("CFileManObserverOverWrite")); sl@0: iFileMan=aFileMan; sl@0: } sl@0: sl@0: sl@0: MFileManObserver::TControl CFileManObserverContinue::NotifyFileManEnded() sl@0: // sl@0: // Observer for testoverwrite tests sl@0: // sl@0: { sl@0: return(MFileManObserver::EContinue); sl@0: } sl@0: sl@0: LOCAL_C void TestCopyOpenFile() sl@0: // sl@0: // Copy a file while it is open sl@0: // sl@0: { sl@0: test.Next(_L("Test copying open files")); sl@0: sl@0: CFileManObserverContinue* fManObserver=new(ELeave) CFileManObserverContinue(gFileMan); sl@0: gFileMan->SetObserver(fManObserver); sl@0: sl@0: TBuf<256> contents; sl@0: TPtrC8 bufPtr; sl@0: CreateLongName(contents,gSeed,256); sl@0: bufPtr.Set((TUint8*)contents.Ptr(),contents.Size()); sl@0: sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\FILECOPY\\asdf.asdf"),bufPtr); sl@0: RFile f; sl@0: TInt r=f.Open(TheFs,_L("\\F32-TST\\TFMAN\\FILECOPY\\asdf.asdf"),EFileRead|EFileShareReadersOnly); sl@0: test(r==KErrNone); sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\FILECOPY\\asdf.asdf"),_L("\\F32-TST\\TFMAN\\FILECOPY\\xxxx.xxxx")); sl@0: test(r==KErrNone); sl@0: f.Close(); sl@0: r=f.Open(TheFs,_L("\\F32-TST\\TFMAN\\FILECOPY\\xxxx.xxxx"),EFileRead); sl@0: test(r==KErrNone); sl@0: TBuf8<256*sizeof(TText)> temp; sl@0: r=f.Read(temp); sl@0: test(r==KErrNone); sl@0: test(temp==bufPtr); sl@0: r=f.Read(temp); sl@0: test(r==KErrNone); sl@0: test(temp.Length()==0); sl@0: f.Close(); sl@0: sl@0: r=f.Open(TheFs,_L("\\F32-TST\\TFMAN\\FILECOPY\\asdf.asdf"),EFileRead); sl@0: test(r==KErrNone); sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\FILECOPY\\asdf.asdf"),_L("\\F32-TST\\TFMAN\\FILECOPY\\xxxx.xxxx")); sl@0: test(r==KErrInUse); sl@0: f.Close(); sl@0: sl@0: gFileMan->SetObserver(gObserver); sl@0: r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\FILECOPY\\")); sl@0: test(r==KErrNone); sl@0: delete fManObserver; sl@0: } sl@0: sl@0: void TestINC101844() sl@0: { sl@0: test.Next(_L("Test move files and subdirs with different attributes (INC101844)")); sl@0: _LIT(KDest,"C:\\DEST101844\\"); sl@0: TBuf<64> source; sl@0: source.Format(_L("%c:\\INC101844\\"), (TUint) gDriveToTest); sl@0: TBuf<64> src; sl@0: RmDir(source); sl@0: RmDir(KDest); sl@0: MakeDir(KDest); sl@0: TInt r; sl@0: sl@0: // Create files and subdirs with different attributes sl@0: src = source; sl@0: src.Append(_L("file1")); sl@0: MakeFile(src, _L8("blah")); sl@0: TheFs.SetAtt(src, KEntryAttReadOnly, 0); sl@0: src = source; sl@0: src.Append(_L("file2")); sl@0: MakeFile(src, _L8("blah")); sl@0: TheFs.SetAtt(src, KEntryAttHidden, 0); sl@0: src = source; sl@0: src.Append(_L("file3")); sl@0: MakeFile(src, _L8("blah")); sl@0: TheFs.SetAtt(src, KEntryAttSystem, 0); sl@0: src = source; sl@0: src.Append(_L("subdir1\\file4")); sl@0: MakeFile(src, _L8("blah")); sl@0: TheFs.SetAtt(src, KEntryAttArchive, 0); sl@0: src = source; sl@0: src.Append(_L("subdir1")); sl@0: TheFs.SetAtt(src, KEntryAttSystem | KEntryAttHidden, KEntryAttArchive); sl@0: sl@0: // Move directory containing files and subdirs with different attributes sl@0: r = gFileMan->Move(source, KDest, 0); sl@0: test(r==KErrNone); sl@0: sl@0: // Check that the files and subdirs have moved and have the correct attributes sl@0: TEntry entry; sl@0: src = KDest; sl@0: src.Append(_L("file1")); sl@0: r = TheFs.Entry(src, entry); sl@0: test(r == KErrNone); sl@0: test(entry.iAtt&KEntryAttReadOnly); sl@0: sl@0: src = KDest; sl@0: src.Append(_L("file2")); sl@0: r = TheFs.Entry(src, entry); sl@0: test(r == KErrNone); sl@0: test(entry.iAtt&KEntryAttHidden); sl@0: sl@0: src = KDest; sl@0: src.Append(_L("file3")); sl@0: r = TheFs.Entry(src, entry); sl@0: test(r == KErrNone); sl@0: test(entry.iAtt&KEntryAttSystem); sl@0: sl@0: src = source; sl@0: src.Append(_L("subdir1\\")); sl@0: r = gFileMan->Move(src, source, 0); sl@0: test(r == KErrNone); sl@0: sl@0: r = TheFs.RmDir(src); sl@0: test(r==KErrNone); sl@0: src = source; sl@0: src.Append(_L("file4")); sl@0: r = TheFs.Delete(src); sl@0: test(r==KErrNone); sl@0: r = TheFs.RmDir(source); sl@0: test(r==KErrNone); sl@0: RmDir(KDest); sl@0: } sl@0: sl@0: LOCAL_C void TestMoveAcrossDrives() sl@0: // sl@0: // Move a file from C: to the target drive sl@0: // sl@0: { sl@0: test.Next(_L("Test move across drives")); sl@0: sl@0: TFileName trgDrive = _L("\\"); sl@0: TFileName trgFile = _L("\\Sketch"); sl@0: TFileName trgDir = _L("\\DRIVEMOVE\\"); sl@0: TFileName trgDirFile = _L("\\DRIVEMOVE\\Sketch"); sl@0: sl@0: if (gSessionPath[0]=='C') sl@0: { sl@0: #if !defined(__WINS__) sl@0: trgDrive = _L("D:\\"); sl@0: trgFile = _L("D:\\Sketch"); sl@0: trgDir = _L("D:\\DRIVEMOVE\\"); sl@0: trgDirFile = _L("D:\\DRIVEMOVE\\Sketch"); sl@0: #else sl@0: trgDrive = _L("Y:\\"); sl@0: trgFile = _L("Y:\\Sketch"); sl@0: trgDir = _L("Y:\\DRIVEMOVE\\"); sl@0: trgDirFile = _L("Y:\\DRIVEMOVE\\Sketch"); sl@0: #endif sl@0: } sl@0: sl@0: RmDir(trgDir); sl@0: RmDir(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\")); sl@0: sl@0: MakeFile(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\Sketch")); sl@0: sl@0: // Move Sketch from the source to target sl@0: TInt r = gFileMan->Move(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\Sketch"),trgDrive); sl@0: test.Printf(_L("TestMoveAcrossDrives(),gFileMan->Move(),r=%d\n"),r); sl@0: // Check Sketch no longer exists on source drive sl@0: CheckFileExists(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\Sketch"),KErrNotFound); sl@0: // Check Sketch exists on target drive sl@0: CheckFileExists(trgFile,KErrNone); sl@0: sl@0: MakeFile(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\Sketch")); sl@0: // Move Directory DRIVEMOVE from the source to target sl@0: r = gFileMan->Move(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE"),trgDrive); sl@0: test.Printf(_L("TestMoveAcrossDrives(),gFileMan->Move(),r=%d\n"),r); sl@0: // Check DRIVEMOVE no longer exists on source drive sl@0: CheckFileExists(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\Sketch"),KErrPathNotFound); sl@0: // Check Sketch exists on target drive sl@0: CheckFileExists(trgDirFile,KErrNone); sl@0: sl@0: RmDir(trgDir); sl@0: test(TheFs.Delete(trgFile) == KErrNone); sl@0: sl@0: TestINC101844(); // Test move files and subdirs with different attributes sl@0: } sl@0: sl@0: class CFileManObserverCopyAbort : public CBase, public MFileManObserver sl@0: { sl@0: public: sl@0: CFileManObserverCopyAbort(CFileMan* aFileMan); sl@0: TControl NotifyFileManEnded(); sl@0: void SetAbortStep(TInt aAbortStep); sl@0: private: sl@0: CFileMan* iFileMan; sl@0: TInt iCurrentStep; sl@0: }; sl@0: sl@0: sl@0: CFileManObserverCopyAbort::CFileManObserverCopyAbort(CFileMan* aFileMan) sl@0: // sl@0: // Constructor sl@0: // sl@0: : iFileMan(aFileMan), sl@0: iCurrentStep(0) sl@0: { sl@0: __DECLARE_NAME(_S("CFileManObserverCopyAbort")); sl@0: } sl@0: sl@0: sl@0: void CFileManObserverCopyAbort::SetAbortStep(TInt aAbortStep) sl@0: // sl@0: // Set the step at which to cancel the operation sl@0: // sl@0: { sl@0: iCurrentStep = aAbortStep; sl@0: } sl@0: sl@0: sl@0: MFileManObserver::TControl CFileManObserverCopyAbort::NotifyFileManEnded() sl@0: // sl@0: // Observer for testoverwrite tests sl@0: // sl@0: { sl@0: TInt lastError = iFileMan->GetLastError(); sl@0: test(lastError == KErrNone); sl@0: sl@0: TFileName srcfile; sl@0: iFileMan->GetCurrentSource(srcfile); sl@0: sl@0: TInt action = iFileMan->CurrentAction(); sl@0: test(action == CFileMan::EMove || sl@0: action == CFileMan::EDelete || sl@0: action == CFileMan::ERmDir); sl@0: sl@0: iCurrentStep--; sl@0: return(iCurrentStep ? MFileManObserver::EContinue : MFileManObserver::EAbort); sl@0: } sl@0: sl@0: LOCAL_C void TestAbortedMoveAcrossDrives() sl@0: // sl@0: // Move a file from C: to D: or Y:, and test various cancel conditions sl@0: // sl@0: { sl@0: test.Next(_L("Test cancel move across drives")); sl@0: sl@0: const TInt KNumFiles = 5; sl@0: sl@0: TFileName trgDirRoot = _L("\\F32-TST\\TFMAN\\"); sl@0: TFileName trgDirFull = _L("\\F32-TST\\TFMAN\\CANCELMOVE\\"); sl@0: TFileName trgDirFile = _L("\\F32-TST\\TFMAN\\CANCELMOVE\\FILE"); sl@0: sl@0: if (gSessionPath[0]=='C') sl@0: { sl@0: #if !defined(__WINS__) sl@0: trgDirRoot = _L("D:\\F32-TST\\TFMAN\\"); sl@0: trgDirFull = _L("D:\\F32-TST\\TFMAN\\CANCELMOVE\\"); sl@0: trgDirFile = _L("D:\\F32-TST\\TFMAN\\CANCELMOVE\\FILE"); sl@0: #else sl@0: trgDirRoot = _L("Y:\\F32-TST\\TFMAN\\"); sl@0: trgDirFull = _L("Y:\\F32-TST\\TFMAN\\CANCELMOVE\\"); sl@0: trgDirFile = _L("Y:\\F32-TST\\TFMAN\\CANCELMOVE\\FILE"); sl@0: #endif sl@0: } sl@0: sl@0: gFileMan->RmDir(_L("C:\\F32-TST\\TFMAN\\CANCELMOVE\\")); sl@0: sl@0: CFileManObserverCopyAbort* fManObserver=new(ELeave) CFileManObserverCopyAbort(gFileMan); sl@0: CleanupStack::PushL(fManObserver); sl@0: sl@0: // Check that source files exist when interrupting the copy step sl@0: TInt step = 0; sl@0: TInt i = 0; sl@0: for(step = 1; step <= KNumFiles+1; ++step) sl@0: { sl@0: for (i = 0; i < KNumFiles; i++) sl@0: { sl@0: TFileName sourceFile =_L("C:\\F32-TST\\TFMAN\\CANCELMOVE\\FILE"); sl@0: sourceFile.AppendNum(i); sl@0: sourceFile.Append(_L(".TXT")); sl@0: MakeFile(sourceFile); sl@0: } sl@0: sl@0: gFileMan->RmDir(trgDirFull); sl@0: sl@0: fManObserver->SetAbortStep(step); sl@0: gFileMan->SetObserver(fManObserver); sl@0: sl@0: TInt r; sl@0: if (!gAsynch) sl@0: r=gFileMan->Move(_L("C:\\F32-TST\\TFMAN\\CANCELMOVE"),trgDirRoot, CFileMan::EOverWrite); sl@0: else sl@0: r=gFileMan->Move(_L("C:\\F32-TST\\TFMAN\\CANCELMOVE"),trgDirRoot, CFileMan::EOverWrite, gStat); sl@0: sl@0: test.Printf(_L("TestAbortedMoveAcrossDrives(),gFileMan->Move(),r=%d\n"),r); sl@0: TestResult(r, (step <= KNumFiles) ? KErrCancel : KErrNone); sl@0: sl@0: gFileMan->SetObserver(NULL); sl@0: sl@0: // Check that the expected target files exist... sl@0: CheckFileExists(trgDirFull, KErrNone, EFalse); sl@0: for (i = 0; i < Min(step, KNumFiles); i++) sl@0: { sl@0: TFileName trgAfterFile = trgDirFile; sl@0: trgAfterFile.AppendNum(i); sl@0: trgAfterFile.Append(_L(".TXT")); sl@0: CheckFileExists(trgAfterFile, KErrNone); sl@0: } sl@0: sl@0: // Check that the expected source files still exist after the abort... sl@0: CheckFileExists(_L("C:\\F32-TST\\TFMAN\\CANCELMOVE\\"), (step <= KNumFiles) ? KErrNone : KErrNotFound, EFalse); sl@0: for (; i < KNumFiles; i++) sl@0: { sl@0: TFileName srcAfterFile =_L("C:\\F32-TST\\TFMAN\\CANCELMOVE\\FILE"); sl@0: srcAfterFile.AppendNum(i); sl@0: srcAfterFile.Append(_L(".TXT")); sl@0: CheckFileExists(srcAfterFile, KErrNone); sl@0: } sl@0: } sl@0: sl@0: gFileMan->SetObserver(NULL); sl@0: CleanupStack::PopAndDestroy(); sl@0: sl@0: RmDir(trgDirRoot); // "?:\\F32-TST\\TFMAN\\" sl@0: TheFs.RmDir(trgDirRoot.Left(16)); sl@0: TheFs.RmDir(trgDirRoot.Left(10)); sl@0: TheFs.RmDir(_L("C:\\F32-TST\\TFMAN\\")); sl@0: TheFs.RmDir(_L("C:\\F32-TST\\")); sl@0: } sl@0: sl@0: sl@0: LOCAL_C void TestMoveEmptyDirectory() sl@0: // sl@0: // "Try to move an empty directory C:\F32-TST\TFMAN\DRIVEMOVE\ to C:\" sl@0: // sl@0: { sl@0: test.Next(_L("Test move empty directory")); sl@0: sl@0: #if !defined(__WINS__) sl@0: TFileName trgDrive=_L("D:\\"); sl@0: #else sl@0: if (gSessionPath[0]!='C') sl@0: return; sl@0: TFileName trgDrive=_L("C:\\"); sl@0: #endif sl@0: sl@0: MakeDir(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\")); sl@0: TInt r=gFileMan->Move(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\*"),trgDrive,CFileMan::ERecurse); sl@0: test.Printf(_L("TestMoveEmptyDirectory(),gFileMan->Move(),r=%d\n"),r); sl@0: test (r==KErrNotFound); sl@0: } sl@0: sl@0: LOCAL_C void TestCopyAndRename() sl@0: // sl@0: // Rename while copying files and directories sl@0: // sl@0: { sl@0: test.Next(_L("Test rename while copying files and directories")); sl@0: gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\CPMV")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\ONE\\ONE_1.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\ONE\\ONE_2.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\ONE\\ONE_3.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\ONE\\TWOTWO.TWO")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\ONE_4.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\ONE_5.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\TWO.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\TWO.GOD")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\TWO.BAD")); sl@0: sl@0: TInt r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\TWO.*"), _L("\\F32-TST\\TFMAN\\THREE.*"), CFileMan::ERecurse); sl@0: test(r==KErrNone); sl@0: sl@0: CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE.TXT"), KErrNone); sl@0: CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE.GOD"), KErrNone); sl@0: CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE.BAD"), KErrNone); sl@0: r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\CPMV\\THREE.*")); sl@0: test(r==KErrNone); sl@0: sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\TWO2\\TWO__1.TXT")); sl@0: MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\TWO2\\TWO__2.TXT")); sl@0: sl@0: // copy and rename dir sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\CPMV\\TWO2"), _L("\\F32-TST\\TFMAN\\CPMV\\THREE"), CFileMan::ERecurse); sl@0: test(r==KErrNone); sl@0: Compare(_L("\\F32-TST\\TFMAN\\CPMV\\TWO2\\*"), _L("\\F32-TST\\TFMAN\\CPMV\\THREE\\*")); sl@0: sl@0: // copy and move into another dir sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\CPMV\\TWO2"), _L("\\F32-TST\\TFMAN\\CPMV\\THREE\\TWO"), CFileMan::ERecurse); sl@0: test(r==KErrNone); sl@0: Compare(_L("\\F32-TST\\TFMAN\\CPMV\\TWO2\\*"), _L("\\F32-TST\\TFMAN\\CPMV\\THREE\\TWO\\*")); sl@0: sl@0: // copy and rename files and dirs in current dir sl@0: r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\CPMV\\TWO*"), _L("\\F32-TST\\TFMAN\\CPMV\\THREE*"), CFileMan::ERecurse); sl@0: test(r==KErrNone); sl@0: // Compare(_L("\\F32-TST\\TFMAN\\CPMV\\TWO2\\*"), _L("\\F32-TST\\TFMAN\\CPMV\\THREE2\\*")); sl@0: sl@0: CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\ONE\\THREEO.TWO"), KErrNone); sl@0: CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE\\TWO__1.TXT"), KErrNone); sl@0: CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE\\TWO__2.TXT"), KErrNone); sl@0: CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE.TXT"), KErrNone); sl@0: CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE.BAD"), KErrNone); sl@0: CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE.GOD"), KErrNone); sl@0: CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE\\THREE1.TXT"), KErrNone); sl@0: CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE\\THREE2.TXT"), KErrNone); sl@0: sl@0: gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\CPMV\\")); sl@0: } sl@0: sl@0: void TestStackUsage(TInt aLevel, TThreadStackInfo& aStack) sl@0: { sl@0: // DEF104115 sl@0: _LIT(KDir, "\\DEF104115\\"); sl@0: _LIT(KFile1, "\\DEF104115\\file1veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryverylong.txt"); sl@0: _LIT(KFile2, "\\DEF104115\\SUBDIR\\longfile2.txt"); sl@0: sl@0: if(aLevel==0) sl@0: { sl@0: test.Next(_L("Test stack usage")); sl@0: RmDir(KDir); sl@0: MakeFile(KFile1, _L8("123456789012345678901234567890")); sl@0: MakeFile(KFile2); sl@0: } sl@0: TInt r = KErrNone; sl@0: char* start = NULL; sl@0: char* end = NULL; sl@0: TInt available = 0; sl@0: TInt stacksize = aStack.iBase - aStack.iLimit; sl@0: start = (char*)aStack.iLimit; sl@0: end = (char*)&stacksize; sl@0: available = (TInt)end - (TInt)start; sl@0: #ifdef __X86__ sl@0: if(available > 6 * 1024) // X86 uses about twice as much stack as ARM in debug mode, so double the number. sl@0: #else sl@0: if(available > 3 * 1024) // don't touch this constant ... fix CFileMan instead!! sl@0: #endif sl@0: { sl@0: TestStackUsage(aLevel+1, aStack); sl@0: return; sl@0: } sl@0: sl@0: test.Printf(_L("Level:%d Available:%d\n"), aLevel, available); sl@0: sl@0: gFileMan->SetObserver(NULL); sl@0: // Attribs sl@0: r = gFileMan->Attribs(KDir, 0, 0, 0, CFileMan::ERecurse); sl@0: test(r==KErrNone); sl@0: sl@0: // Move sl@0: r = gFileMan->Move(KFile1, KFile2, CFileMan::ERecurse); sl@0: test(r==KErrAlreadyExists); sl@0: sl@0: r = gFileMan->Move(KFile1, KFile2, CFileMan::ERecurse | CFileMan::EOverWrite); sl@0: test(r==KErrNone); sl@0: sl@0: // Copy sl@0: r = gFileMan->Copy(KFile2, KFile1, CFileMan::ERecurse); sl@0: test(r==KErrNone); sl@0: sl@0: // Rename sl@0: r = gFileMan->Rename(KFile1, KFile2, 0); sl@0: test(r==KErrAlreadyExists); sl@0: sl@0: r = gFileMan->Rename(KFile1, KFile2, CFileMan::EOverWrite); sl@0: test(r==KErrNone); sl@0: sl@0: // Delete sl@0: r = gFileMan->Delete(KFile2, CFileMan::ERecurse); sl@0: test(r==KErrNone); sl@0: sl@0: // RmDir sl@0: r = gFileMan->RmDir(KDir); sl@0: test(r==KErrNone); sl@0: sl@0: gFileMan->SetObserver(gObserver); sl@0: } sl@0: sl@0: LOCAL_C void InitialiseL() sl@0: // sl@0: // Set up test variables sl@0: // sl@0: { sl@0: gFileMan=CFileMan::NewL(TheFs); sl@0: gObserver=new(ELeave) CFileManObserver(gFileMan); sl@0: gFileMan->SetObserver(gObserver); sl@0: } sl@0: sl@0: LOCAL_C void Cleanup() sl@0: // sl@0: // Cleanup test variables sl@0: // sl@0: { sl@0: delete gFileMan; sl@0: delete gObserver; sl@0: } sl@0: sl@0: LOCAL_C void SetupDirStructure(TFileName& aSrcPath,TFileName& aTrgPath) sl@0: { sl@0: TFileName tmpName = aSrcPath; sl@0: sl@0: // Create the TrgPath dirs sl@0: MakeDir(aTrgPath); sl@0: sl@0: // Create the aSrcPath dirs sl@0: tmpName = aSrcPath; sl@0: tmpName.Append(_L("EmptyDir01\\")); sl@0: MakeDir(tmpName); sl@0: sl@0: tmpName = aSrcPath; sl@0: tmpName.Append(_L("EmptyDir02\\")); sl@0: MakeDir(tmpName); sl@0: sl@0: tmpName = aSrcPath; sl@0: tmpName.Append(_L("EmptyDir03\\")); sl@0: MakeDir(tmpName); sl@0: sl@0: tmpName = aSrcPath; sl@0: tmpName.Append(_L("FILE01.TXT")); sl@0: MakeFile(tmpName); sl@0: sl@0: tmpName = aSrcPath; sl@0: tmpName.Append(_L("FILE02.TXT")); sl@0: MakeFile(tmpName); sl@0: sl@0: tmpName = aSrcPath; sl@0: tmpName.Append(_L("FILE03.TXT")); sl@0: MakeFile(tmpName); sl@0: sl@0: tmpName = aSrcPath; sl@0: tmpName.Append(_L("SubDir01\\EmptyDir01\\")); sl@0: MakeDir(tmpName); sl@0: sl@0: tmpName = aSrcPath; sl@0: tmpName.Append(_L("SubDir02\\EmptyDir02\\")); sl@0: MakeDir(tmpName); sl@0: sl@0: tmpName = aSrcPath; sl@0: tmpName.Append(_L("SubDir03\\EmptyDir03\\")); sl@0: MakeDir(tmpName); sl@0: sl@0: tmpName = aSrcPath; sl@0: tmpName.Append(_L("SubDir01\\FILE01.TXT")); sl@0: MakeFile(tmpName); sl@0: sl@0: tmpName = aSrcPath; sl@0: tmpName.Append(_L("SubDir01\\FILE02.TXT")); sl@0: MakeFile(tmpName); sl@0: sl@0: tmpName = aSrcPath; sl@0: tmpName.Append(_L("SubDir01\\FILE03.TXT")); sl@0: MakeFile(tmpName); sl@0: sl@0: tmpName = aSrcPath; sl@0: tmpName.Append(_L("SubDir02\\FILE01.TXT")); sl@0: MakeFile(tmpName); sl@0: sl@0: tmpName = aSrcPath; sl@0: tmpName.Append(_L("SubDir02\\FILE02.TXT")); sl@0: MakeFile(tmpName); sl@0: sl@0: tmpName = aSrcPath; sl@0: tmpName.Append(_L("SubDir02\\FILE03.TXT")); sl@0: MakeFile(tmpName); sl@0: sl@0: tmpName = aSrcPath; sl@0: tmpName.Append(_L("SubDir03\\FILE01.TXT")); sl@0: MakeFile(tmpName); sl@0: sl@0: tmpName = aSrcPath; sl@0: tmpName.Append(_L("SubDir03\\FILE02.TXT")); sl@0: MakeFile(tmpName); sl@0: sl@0: tmpName = aSrcPath; sl@0: tmpName.Append(_L("SubDir03\\FILE03.TXT")); sl@0: MakeFile(tmpName); sl@0: } sl@0: sl@0: LOCAL_C void TestPDEF112148() sl@0: { sl@0: test.Next(_L("Test recursive and non-recursive move across drives (PDEF112148)")); sl@0: sl@0: TInt err = 0; sl@0: sl@0: TFileName trgPath; sl@0: trgPath.Format(_L("%c:\\F32-TST\\TFMAN\\PDEF112148\\dest\\"), (TUint8)gDriveToTest); sl@0: TFileName srcPath = _L("C:\\F32-TST\\TFMAN\\PDEF112148\\src\\"); sl@0: sl@0: // Non-Recursive move sl@0: // clean up before testing sl@0: RmDir(srcPath); sl@0: RmDir(trgPath); sl@0: // Setup the directory structure sl@0: SetupDirStructure(srcPath, trgPath); sl@0: if(!gAsynch) sl@0: err = gFileMan->Move(srcPath, trgPath, 0); sl@0: else sl@0: err = gFileMan->Move(srcPath, trgPath, 0, gStat); sl@0: TestResult(err); sl@0: sl@0: // Verify src contents after move operation sl@0: CDir *dir = NULL; sl@0: err = TheFs.GetDir(srcPath, KEntryAttMaskSupported, ESortNone, dir); sl@0: test(6 == dir->Count()); sl@0: delete dir; sl@0: // Verify dest contents after move operation sl@0: err = TheFs.GetDir(trgPath, KEntryAttMaskSupported, ESortNone, dir); sl@0: test(3 == dir->Count()); sl@0: delete dir; sl@0: sl@0: // Recursive move with "\\" at the end of srcPath sl@0: // clean up before execution sl@0: RmDir(srcPath); sl@0: RmDir(trgPath); sl@0: // Setup the directory structure sl@0: SetupDirStructure(srcPath, trgPath); sl@0: if(!gAsynch) sl@0: err = gFileMan->Move(srcPath, trgPath, CFileMan::ERecurse); sl@0: else sl@0: err = gFileMan->Move(srcPath, trgPath, CFileMan::ERecurse, gStat); sl@0: TestResult(err); sl@0: sl@0: // Verify src has no content sl@0: err = TheFs.GetDir(srcPath, KEntryAttMaskSupported, ESortNone, dir); sl@0: test(0 == dir->Count()); sl@0: delete dir; sl@0: // Verify dest contents after move operation sl@0: err = TheFs.GetDir(trgPath, KEntryAttMaskSupported, ESortNone, dir); sl@0: test(9 == dir->Count()); sl@0: delete dir; sl@0: sl@0: // Recursive move without "\\" at the end of srcPath sl@0: // clean up before execution sl@0: RmDir(srcPath); sl@0: RmDir(trgPath); sl@0: // Setup the directory structure sl@0: SetupDirStructure(srcPath, trgPath); sl@0: // Remove the "\\" at the end of srcPath for Recursive Move sl@0: srcPath.Delete(srcPath.Length()-1,1); sl@0: if(!gAsynch) sl@0: err = gFileMan->Move(srcPath, trgPath, CFileMan::ERecurse); sl@0: else sl@0: err = gFileMan->Move(srcPath, trgPath, CFileMan::ERecurse, gStat); sl@0: TestResult(err); sl@0: sl@0: // Add the "\\" at the end of srcPath for verification sl@0: srcPath.Append(KPathDelimiter); sl@0: // Verify src doesnt not exist sl@0: err = gFileMan->RmDir(srcPath); sl@0: test(err==KErrPathNotFound); // KErrPathNotFound expected as src has been moved to dest sl@0: // Verify dest after move operation sl@0: err = TheFs.GetDir(trgPath, KEntryAttMaskSupported, ESortNone, dir); sl@0: test(1 == dir->Count()); sl@0: delete dir; sl@0: sl@0: // clean up before leaving sl@0: RmDir(srcPath); sl@0: RmDir(trgPath); sl@0: } sl@0: //--------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_FMAN-2398 sl@0: //! @SYMTestType UT sl@0: //! @SYMREQ DEF130678 sl@0: //! @SYMTestCaseDesc Tests that CFileMan::Move itself does not leak any memory sl@0: //! @SYMTestActions Move files and keep checking the memory usage for each operation. sl@0: //! @SYMTestExpectedResults Test completes without any crash and hence without any memory leak. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //--------------------------------------------- sl@0: void TestDEF130678() sl@0: { sl@0: test.Next(_L("Test CFileMan::Move does not leak any memory")); sl@0: _LIT(KFromFile,"C:\\TestDEF130678\\FROM\\from_"); sl@0: _LIT(KToFile,"C:\\TestDEF130678\\TO\\"); sl@0: sl@0: TInt run; sl@0: // choose a number that certainly tests all memory allocations. sl@0: // it is used for memory allocation failure simulation. sl@0: TInt maxRun = 50; sl@0: // start OOM loop sl@0: for(run=1; run<=maxRun; ++run) sl@0: { sl@0: TInt err = KErrNone; sl@0: TFileName fromFile, toFile; sl@0: sl@0: fromFile.Append(KFromFile); sl@0: fromFile.AppendNum(run); sl@0: fromFile.Append(_L(".txt")); sl@0: MakeFile(fromFile); sl@0: sl@0: MakeDir(_L("C:\\TestDEF130678\\FROM\\")); sl@0: MakeDir(_L("C:\\TestDEF130678\\TO\\")); sl@0: toFile.Append(KToFile); sl@0: sl@0: // Check the memory usage sl@0: __UHEAP_MARK; sl@0: // set to fail every run-th memory allocation sl@0: __UHEAP_SETFAIL(RAllocator::EDeterministic, run); sl@0: sl@0: CFileMan* fileMan = NULL; sl@0: TInt errTrap1 = KErrNone; sl@0: TRAP(errTrap1,(fileMan=CFileMan::NewL(TheFs))); sl@0: if (errTrap1 != KErrNone) sl@0: { sl@0: // reset the memory allocation failure and check for any leak sl@0: __UHEAP_RESET; sl@0: __UHEAP_MARKEND; sl@0: continue; sl@0: } sl@0: sl@0: CleanupStack::PushL(fileMan); sl@0: TInt errTrap2 = KErrNone; sl@0: TRAP(errTrap2,(err = fileMan->Move(fromFile,toFile))); sl@0: if (errTrap2 != KErrNone || err != KErrNone) sl@0: { sl@0: CleanupStack::PopAndDestroy(fileMan); sl@0: // reset the memory allocation failure and check for any leak sl@0: __UHEAP_RESET; sl@0: __UHEAP_MARKEND; sl@0: continue; sl@0: } sl@0: CleanupStack::PopAndDestroy(fileMan); sl@0: // reset the memory allocation failure and check for any leak sl@0: __UHEAP_RESET; sl@0: __UHEAP_MARKEND; sl@0: } // End of OOM loop sl@0: sl@0: // cleanup sl@0: RmDir(_L("C:\\TestDEF130678\\")); sl@0: } sl@0: sl@0: GLDEF_C void CallTestsL() sl@0: // sl@0: // Do tests sl@0: // sl@0: { sl@0: // T_FMAN is independent of all tests so format first sl@0: #ifndef __WINS__ sl@0: Format(CurrentDrive()); sl@0: #endif sl@0: sl@0: InitialiseL(); sl@0: CreateTestDirectory(_L("\\F32-TST\\TFMAN\\")); sl@0: // May not be able to test handling of invalid path lengths because F32 fix sl@0: // to prevent paths >256 ever being created sl@0: testingInvalidPathLengths = CheckIfShortPathsAreSupported(); sl@0: sl@0: //----------------------------------------------------------------------------------- sl@0: // Asynchronous tests sl@0: // sl@0: gAsynch=ETrue; sl@0: test.Next(_L("Asynchronous tests ...")); sl@0: TheFs.SetAllocFailure(gAllocFailOff); sl@0: sl@0: TInt uid; sl@0: test(HAL::Get(HAL::EMachineUid,uid)==KErrNone); sl@0: TBool doTargetTests = (!IsTestingLFFS() && sl@0: uid!=HAL::EMachineUid_Cogent && sl@0: uid!=HAL::EMachineUid_IQ80310 && sl@0: uid!=HAL::EMachineUid_X86PC); sl@0: sl@0: if (doTargetTests) sl@0: { sl@0: TestMoveAcrossDrives(); sl@0: TestRecursiveMoveAcrossDrives(); sl@0: TestMoveEmptyDirectory(); sl@0: TestAbortedMoveAcrossDrives(); sl@0: TestPDEF112148(); // Test recursive and non-recursive move across drives sl@0: } sl@0: sl@0: TestOverWrite(); sl@0: TestRename(); sl@0: TestErrorHandling(); sl@0: sl@0: TestRecursiveMove(); sl@0: TestRecursiveDelete(); sl@0: TestRecursiveAttribs(); sl@0: TestRecursiveCopy(); sl@0: sl@0: TestRmDir(); sl@0: TestSimultaneous(); sl@0: TestAttribs(); sl@0: TestDelete(); sl@0: if (!IsTestingLFFS()) sl@0: TestCopy(); // ??? sl@0: TestMove(); sl@0: TestCopyAllCancel(); sl@0: sl@0: //----------------------------------------------------------------------------------- sl@0: // Synchronous tests sl@0: // sl@0: gAsynch=EFalse; sl@0: test.Next(_L("Synchronous tests ...")); sl@0: TheFs.SetAllocFailure(gAllocFailOn); sl@0: sl@0: if (doTargetTests) sl@0: { sl@0: TestMoveAcrossDrives(); sl@0: TestRecursiveMoveAcrossDrives(); sl@0: TestMoveEmptyDirectory(); sl@0: TestAbortedMoveAcrossDrives(); sl@0: TestPDEF112148(); // Test recursive and non-recursive move across drives sl@0: } sl@0: sl@0: TestCopyOpenFile(); sl@0: if(testingInvalidPathLengths) sl@0: TestLongNames(); sl@0: TestNameMangling(); sl@0: TestFileAttributes(); sl@0: TestOverWrite(); sl@0: TestRename(); sl@0: TestErrorHandling(); sl@0: TestRecursiveMove(); sl@0: TestRecursiveDelete(); sl@0: TestRecursiveAttribs(); sl@0: TestRecursiveCopy(); sl@0: TestRmDir(); sl@0: TestSimultaneous(); sl@0: TestAttribs(); sl@0: TestDelete(); sl@0: TestCopy(); sl@0: TestMove(); sl@0: TestCopyAndRename(); sl@0: TestCopyAllCancel(); sl@0: sl@0: TestDEF130678(); // Test CFileMan::Move does not leak any memory sl@0: #ifndef __WINS__ sl@0: RThread t; sl@0: TThreadStackInfo stack; sl@0: test(t.StackInfo(stack)==KErrNone); sl@0: TestStackUsage(0, stack); sl@0: #endif sl@0: sl@0: Cleanup(); sl@0: DeleteTestDirectory(); sl@0: test(TheFs.RmDir(_L("\\F32-TST\\")) == KErrNone); sl@0: } sl@0: