kerneltest/f32test/server/t_fman.cpp
changeset 0 a41df078684a
child 31 56f325a607ea
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <f32file.h>
       
    17 #include <e32test.h>
       
    18 #include <hal.h>
       
    19 #include "t_server.h"
       
    20 #include "t_chlffs.h"
       
    21 
       
    22 GLDEF_D RTest test(_L("T_FMAN"));
       
    23 
       
    24 LOCAL_D CFileMan* gFileMan=NULL;
       
    25 LOCAL_D TBool gAsynch=EFalse;
       
    26 LOCAL_D TRequestStatus gStat;
       
    27 LOCAL_D TBool testingInvalidPathLengths;
       
    28 
       
    29 class CFileManObserver : public CBase, public MFileManObserver
       
    30 	{
       
    31 public:
       
    32 	CFileManObserver(CFileMan* aFileMan);
       
    33 	TControl NotifyFileManEnded();
       
    34 private:
       
    35 	CFileMan* iFileMan;
       
    36 	};
       
    37 
       
    38 LOCAL_D CFileManObserver* gObserver;
       
    39 
       
    40 CFileManObserver::CFileManObserver(CFileMan* aFileMan)
       
    41 //
       
    42 // Constructor
       
    43 //
       
    44 	{
       
    45 	__DECLARE_NAME(_S("CFileManObserver"));
       
    46 	iFileMan=aFileMan;
       
    47 	}
       
    48 
       
    49 MFileManObserver::TControl CFileManObserver::NotifyFileManEnded()
       
    50 //
       
    51 // Called back after each FMan tick
       
    52 //
       
    53 	{
       
    54 	TInt lastError=iFileMan->GetLastError();
       
    55 	if (lastError!=KErrNone && lastError!=KErrBadName)
       
    56 		{
       
    57 		TFileName fileName=iFileMan->CurrentEntry().iName;
       
    58 		if (gAsynch==EFalse)
       
    59 			test.Printf(_L("CurrentEntry is %S\n"),&fileName);
       
    60 		test(lastError==KErrAlreadyExists);
       
    61 		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);
       
    62 		}
       
    63 	return(MFileManObserver::EContinue);
       
    64 	}
       
    65 
       
    66 LOCAL_C void WaitForSuccess()
       
    67 //
       
    68 // Wait for gStat to complete with KErrNone
       
    69 //
       
    70 	{
       
    71 	User::WaitForRequest(gStat);
       
    72 	test(gStat==KErrNone);
       
    73 	}
       
    74 
       
    75 LOCAL_C void WaitForResult(TInt aResult)
       
    76 //
       
    77 // Wait for gStat to complete with aResult
       
    78 //
       
    79 	{
       
    80 	User::WaitForRequest(gStat);
       
    81 	test(gStat==aResult);
       
    82 	}
       
    83 
       
    84 LOCAL_C void TestResult(TInt aReturnVal, TInt aExpectedAsynchReturnStatus=KErrNone, TInt aExpectedSynchReturn=KErrNone)
       
    85 //
       
    86 // Test the result, wait for an asynchronous call
       
    87 //
       
    88 	{
       
    89 	if (!gAsynch)
       
    90 		test(aReturnVal==aExpectedAsynchReturnStatus);
       
    91 	else
       
    92 		{
       
    93 		test(aReturnVal==aExpectedSynchReturn);
       
    94 		WaitForResult(aExpectedAsynchReturnStatus);
       
    95 		}
       
    96 	}
       
    97 
       
    98 LOCAL_C void RmDir(const TDesC& aDirName)
       
    99 //
       
   100 // Remove a directory
       
   101 //
       
   102 	{
       
   103 	gFileMan->Attribs(aDirName, 0, KEntryAttReadOnly, 0, CFileMan::ERecurse);
       
   104 	TInt r=gFileMan->RmDir(aDirName);
       
   105 	test(r==KErrNone || r==KErrNotFound || r==KErrPathNotFound);
       
   106 	}
       
   107 
       
   108 LOCAL_C void Compare(const TDesC& aDir1,const TDesC& aDir2)
       
   109 //
       
   110 // Test that the contents of two directories are identical
       
   111 //
       
   112 	{
       
   113 
       
   114 	CDirScan* scanDir1=CDirScan::NewL(TheFs);
       
   115 	scanDir1->SetScanDataL(aDir1,KEntryAttMaskSupported,ESortByName);
       
   116 	CDirScan* scanDir2=CDirScan::NewL(TheFs);
       
   117 	scanDir2->SetScanDataL(aDir2,KEntryAttMaskSupported,ESortByName);
       
   118 
       
   119 	FOREVER
       
   120 		{
       
   121 		CDir* entryList1;
       
   122 		CDir* entryList2;
       
   123 
       
   124 		scanDir1->NextL(entryList1);
       
   125 		scanDir2->NextL(entryList2);
       
   126 
       
   127 		if (entryList1==NULL || entryList2==NULL)
       
   128 			{
       
   129 			test(entryList1==NULL && entryList2==NULL);
       
   130 			break;
       
   131 			}
       
   132 
       
   133 		TFileName abbPath1=scanDir1->AbbreviatedPath();
       
   134 		TFileName abbPath2=scanDir2->AbbreviatedPath();
       
   135 		test(abbPath1==abbPath2);
       
   136 
       
   137 		TInt count1=entryList1->Count();
       
   138 		TInt count2=entryList2->Count();
       
   139 		test(count1==count2);
       
   140 
       
   141 		while(count1--)
       
   142 			{
       
   143 			TEntry entry1=(*entryList1)[count1];
       
   144 			TEntry entry2=(*entryList2)[count1];
       
   145 			test(entry1.iName==entry2.iName);
       
   146 			test(entry1.iAtt==entry2.iAtt);
       
   147 			}
       
   148 
       
   149 		delete entryList1;
       
   150 		delete entryList2;
       
   151 		}
       
   152 
       
   153 	delete scanDir1;
       
   154 	delete scanDir2;
       
   155 	}
       
   156 
       
   157 LOCAL_C void SetupDirectories(TBool aCreateFiles, TFileName* aDestOtherDrive)
       
   158 //
       
   159 // Set up a directory structure and files to test copying/moving across drives
       
   160 //
       
   161 	{
       
   162 	TInt err = KErrNone;
       
   163 
       
   164 	TFileName sourceName		= _L("\\F32-TST\\TFMAN\\source\\");
       
   165 	TFileName sourceNameSubDir	= _L("\\F32-TST\\TFMAN\\source\\subdir\\");
       
   166 	TFileName sourceCompare		= _L("\\F32-TST\\TFMAN\\compare\\");	
       
   167 	TFileName sourceCompareSubDir		= _L("\\F32-TST\\TFMAN\\compare\\subdir\\");	
       
   168 	TFileName destSameDrive		= _L("\\F32-TST\\TFMAN\\dest\\");	// Target destination on the same drive
       
   169 
       
   170 	if(aDestOtherDrive)
       
   171 		{
       
   172 #if !defined(__WINS__)
       
   173 		*aDestOtherDrive = gSessionPath[0] == 'C' ? _L("D:\\F32-TST\\TFMAN\\dest\\") : _L("C:\\F32-TST\\TFMAN\\dest\\");
       
   174 #else
       
   175 		*aDestOtherDrive = gSessionPath[0] == 'C' ? _L("Y:\\F32-TST\\TFMAN\\dest\\") : _L("C:\\F32-TST\\TFMAN\\dest\\");
       
   176 #endif
       
   177 		err = TheFs.MkDirAll(*aDestOtherDrive);
       
   178 		test(err == KErrNone || err == KErrAlreadyExists);
       
   179 		}
       
   180 
       
   181 	err = TheFs.MkDirAll(sourceName);
       
   182 	test(err == KErrNone || err == KErrAlreadyExists);
       
   183 
       
   184 	err = TheFs.MkDirAll(sourceCompare);
       
   185 	test(err == KErrNone || err == KErrAlreadyExists);
       
   186 
       
   187 	err = TheFs.MkDirAll(destSameDrive);
       
   188 	test(err == KErrNone || err == KErrAlreadyExists);
       
   189 
       
   190 	if(aCreateFiles)
       
   191 		{
       
   192 		err = TheFs.MkDirAll(sourceNameSubDir);
       
   193 		test(err == KErrNone || err == KErrAlreadyExists);
       
   194 
       
   195 		err = TheFs.MkDirAll(sourceCompareSubDir);
       
   196 		test(err == KErrNone || err == KErrAlreadyExists);
       
   197 		
       
   198 		for(TInt i=0; i<5; i++)
       
   199 			{
       
   200 			// Create a test file to be copied
       
   201 			TFileName name = sourceName;
       
   202 			name.Append(_L("File"));
       
   203 			name.AppendNum(i);
       
   204 			name.Append(_L(".TXT"));
       
   205 
       
   206 			RFile file;
       
   207 			err = file.Create(TheFs,name,EFileRead|EFileWrite);
       
   208 			test(err == KErrNone || err == KErrAlreadyExists);
       
   209 			file.Close();
       
   210 
       
   211 			// ...and another to compare against
       
   212 			name = sourceCompare;
       
   213 			name.Append(_L("File"));
       
   214 			name.AppendNum(i);
       
   215 			name.Append(_L(".TXT"));
       
   216 
       
   217 			err = file.Create(TheFs,name,EFileRead|EFileWrite);
       
   218 			test(err == KErrNone || err == KErrAlreadyExists);
       
   219 			file.Close();
       
   220 			}
       
   221 		}
       
   222 	}
       
   223 
       
   224 TBool CheckIfShortPathsAreSupported()
       
   225 	{
       
   226 	TBool ret = EFalse;
       
   227 	TBuf<1+8+3+1+4> buf;
       
   228 	_LIT(KTestFile, "\\longname1\\file");
       
   229 	RmDir(_L("\\longname1\\"));
       
   230 	MakeFile(KTestFile);
       
   231 	TInt err = TheFs.GetShortName(_L("\\longname1\\"), buf);	
       
   232 	if(err == KErrNone)
       
   233 		{
       
   234 		buf.Insert(0, _L("\\"));
       
   235 		buf.Append(_L("\\file"));
       
   236 		err = TheFs.Delete(buf);
       
   237 		test(err == KErrNone);
       
   238   		ret = ETrue;
       
   239 		}
       
   240 	RmDir(_L("\\longname1\\"));
       
   241 	return ret;
       
   242 	}
       
   243 	
       
   244 	LOCAL_C void TestDelete()
       
   245 //
       
   246 // Test files are deleted
       
   247 //
       
   248 	{
       
   249 	
       
   250 	test.Next(_L("Set up files and start deleting"));
       
   251 
       
   252 	MakeDir(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EMPTY\\"));
       
   253 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"));
       
   254 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE2.TXT"));
       
   255 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE3.TXT"));
       
   256 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\FILE4.TXT"));
       
   257 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EXE1.BIN"));
       
   258 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\EXE2.BIN"));
       
   259 	
       
   260 	TInt r;
       
   261 	// absolute path for code warrior two more than wins (\epoc32\winscw\c vs \epoc32\wins\c)
       
   262 #if defined(__WINSCW__)
       
   263 	_LIT(KLongName1,"\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffd");
       
   264 #else
       
   265 	_LIT(KLongName1,"\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa");
       
   266 #endif
       
   267 
       
   268 _LIT(KInvalidLongName,"\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdffdsa23asdffdsa24asdffdsa25asdffdsa");
       
   269 _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");
       
   270 	if (testingInvalidPathLengths)
       
   271 //	Create a path of greater 256 characters by renaming a directory and check it can be
       
   272 //	manipulated (tests fix to F32)		
       
   273 		{
       
   274 	//	One long directory name - makes paths invalid	
       
   275 		MakeDir(_L("\\TEST\\LONG\\NAME\\ABCDE"));
       
   276 		MakeDir(_L("\\TEST\\LONG\\NAME\\ABCDE\\DIRECTORY1DIRECTORY2DIRECTORY3DIRECTORY4\\"));
       
   277 		MakeFile(_L("\\TEST\\LONG\\NAME\\ABCDE\\ELEPHANT01ELEPHANT02ELEPHANT03ELEPHANT04"));
       
   278 		MakeFile(_L("\\TEST\\LONG\\NAME\\ABCDE\\FILEFILE01FILEFILE02FILEFILE03FILEFILE04"));
       
   279 		TFileName name1(KLongName1);
       
   280 		r=gFileMan->Rename(_L("\\TEST\\LONG"),name1,CFileMan::EOverWrite);
       
   281 		test(r==KErrNone);
       
   282 	//	Two long directory names - makes paths invalid
       
   283 		MakeDir(_L("\\TEST\\LONG\\NAME\\FGHIJ"));
       
   284 		MakeDir(_L("\\TEST\\LONG\\NAME\\FGHIJ\\DIRECTORY1DIRECTORY2DIRECTORY3DIRECTORY4\\"));
       
   285 		MakeFile(_L("\\TEST\\LONG\\NAME\\FGHIJ\\ELEPHANT01ELEPHANT02ELEPHANT03ELEPHANT04"));
       
   286 		MakeFile(_L("\\TEST\\LONG\\NAME\\FGHIJ\\FILEFILE01FILEFILE02FILEFILE03FILEFILE04"));
       
   287 		
       
   288 		// Testing invalid long file name (i.e. >256) 
       
   289 		r=gFileMan->Rename(_L("\\TEST\\LONG"),KInvalidLongName,CFileMan::EOverWrite);
       
   290 		test(r==KErrBadName);
       
   291 		
       
   292 		// Testing invalid long path (i.e. >256)
       
   293 		r=gFileMan->Rename(_L("\\TEST\\LONG"),KInvalidLongPath,CFileMan::EOverWrite);
       
   294 		test(r==KErrBadName);
       
   295 
       
   296 		r=gFileMan->Rename(_L("\\TEST\\LONG"),_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds"),CFileMan::EOverWrite);
       
   297 		test(r==KErrNone);
       
   298 		}
       
   299 
       
   300 	//testing invalid source path at the beginning:
       
   301 	if (!gAsynch)
       
   302 		{
       
   303 		r=gFileMan->Delete(_L(":C\\F32-TST\\TFMAN\\DELDIR\\*.TXT"));
       
   304 		}
       
   305 	else
       
   306 		{
       
   307 		r=gFileMan->Delete(_L(":C\\F32-TST\\TFMAN\\DELDIR\\*.TXT"),0,gStat);
       
   308 		}
       
   309 	TestResult(r,KErrBadName,KErrBadName);
       
   310 
       
   311 	//testing invalid source path at the middle:	
       
   312 	if (!gAsynch)
       
   313 		{
       
   314 		r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\:DELDIR\\*.TXT"));
       
   315 		}
       
   316 	else
       
   317 		{
       
   318 		r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\:DELDIR\\*.TXT"),0,gStat);
       
   319 		}
       
   320 	TestResult(r,KErrBadName,KErrNone);
       
   321 
       
   322 	//testing invalid source path at the end:	
       
   323 	if (!gAsynch)
       
   324 		{
       
   325 		r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\DELDIR\\:*.TXT"));
       
   326 		}
       
   327 	else
       
   328 		{
       
   329 		r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\DELDIR\\:*.TXT"),0,gStat);
       
   330 		}
       
   331 	TestResult(r,KErrBadName,KErrNone);
       
   332 
       
   333 	if (!gAsynch)
       
   334 		{
       
   335 		r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\DELDIR\\*.TXT"));
       
   336 		TestResult(r);
       
   337 		if (testingInvalidPathLengths)
       
   338 			{
       
   339 			TFileName name1(KLongName1);
       
   340 			name1+=_L("\\NAME\\ABCDE\\*.*");
       
   341 			r=gFileMan->Delete(name1);	
       
   342 			test(r==KErrNone);
       
   343 
       
   344 			r=gFileMan->Delete(_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds\\NAME\\FGHIJ\\*.*"));	
       
   345 			test(r==KErrNone);
       
   346 			}
       
   347 		}
       
   348 	else
       
   349 		{
       
   350 		gFileMan->Delete(_L("\\F32-TST\\TFMAN\\DELDIR\\*.TXT"),0,gStat);
       
   351 		WaitForSuccess();
       
   352 		if (testingInvalidPathLengths)
       
   353 			{
       
   354 			TFileName name1(KLongName1);
       
   355 			name1+=_L("\\NAME\\ABCDE\\*.*");
       
   356 			r=gFileMan->Delete(name1,0,gStat);	
       
   357 			WaitForSuccess();
       
   358 			test(r==KErrNone);
       
   359 		
       
   360 			r=gFileMan->Delete(_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds\\NAME\\FGHIJ\\*.*"),0,gStat);	
       
   361 			WaitForSuccess();
       
   362 			test(r==KErrNone);
       
   363 			}
       
   364 		}
       
   365 
       
   366 	test.Next(_L("Check files are deleted"));
       
   367 	RmDir(_L("\\F32-TST\\TFMAN\\After\\"));
       
   368 	MakeDir(_L("\\F32-TST\\TFMAN\\AFTER\\DELDIR\\DELTEST\\EMPTY\\"));
       
   369 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\DELDIR\\DELTEST\\EXE1.BIN"));
       
   370 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\DELDIR\\DELTEST\\FILE4.TXT"));
       
   371 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\DELDIR\\EXE2.BIN"));
       
   372 	Compare(_L("\\F32-TST\\TFMAN\\DELDIR\\*"),_L("\\F32-TST\\TFMAN\\AFTER\\DELDIR\\*"));
       
   373 	
       
   374 	if (testingInvalidPathLengths)
       
   375 		{
       
   376 		r=gFileMan->RmDir(_L("\\TEST\\"));
       
   377 		test(r==KErrNone);
       
   378 		}
       
   379 
       
   380 	/**
       
   381 	Test wild card matching in short file names
       
   382 	Note this test is only run on FAT file systems as 'short file names' are only
       
   383 		supported by FAT.
       
   384 	DEF130113: TTG:<Wild card characters cannot be handled in the short file names> 
       
   385 	*/ 
       
   386 	TInt theDrive; 
       
   387 	r=TheFs.CharToDrive(gDriveToTest,theDrive);
       
   388 	test(r==KErrNone);
       
   389     TFSName f;
       
   390 	r = TheFs.FileSystemName(f, theDrive);
       
   391 	test(r == KErrNone || r == KErrNotFound);
       
   392     if (f.FindF(_L("Fat")) == 0 )
       
   393     	{
       
   394     	MakeFile(_L("abcdefghi.txt"));
       
   395     	TInt err = gFileMan->Delete(_L("ABCDEF~*"));
       
   396     	test(err == KErrNone);
       
   397     	MakeFile(_L("abcdefghi.txt"));
       
   398     	err = gFileMan->Delete(_L("ABCDEF~*.TXT"));
       
   399     	test(err == KErrNone);
       
   400     	MakeFile(_L("abcdefghi.txt"));
       
   401     	err = gFileMan->Delete(_L("ABCDEF~*.?XT"));
       
   402     	test(err == KErrNone);
       
   403     	MakeFile(_L("abcdefghi.txt"));
       
   404     	err = gFileMan->Delete(_L("ABCDEF~1.*"));
       
   405     	test(err == KErrNone);
       
   406     	}
       
   407 	}
       
   408 
       
   409 LOCAL_C void TestCopy()
       
   410 //
       
   411 // Test copy
       
   412 //
       
   413 	{
       
   414 
       
   415 	test.Next(_L("Test copy"));
       
   416 	RmDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\*"));
       
   417 
       
   418 	MakeDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
       
   419 	MakeDir(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EMPTY\\"));
       
   420 	MakeFile(_L("\\F32-TST\\TFMAN\\NewDir\\ABC.DEF"));
       
   421 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"));
       
   422 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE2.TXT"));
       
   423 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE3.TXT"));
       
   424 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\FILE4.TXT"));
       
   425 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EXE1.BIN"));
       
   426 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\EXE2.BIN"));
       
   427 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA1.TXT"));
       
   428 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA2.TXT"));
       
   429 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA3.TXT"));
       
   430 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA4.TXT"));
       
   431 
       
   432 	test.Next(_L("Test copy files to the same directory"));
       
   433 	TInt r;
       
   434 	
       
   435 	if (testingInvalidPathLengths)
       
   436 //	Create a path of greater 256 characters by renaming a directory and check it can be
       
   437 //	manipulated (tests fix to F32)		
       
   438 		{
       
   439 		MakeDir(_L("\\START\\LONG\\"));
       
   440 		MakeDir(_L("\\FINISH\\"));
       
   441 		MakeFile(_L("\\START\\LONG\\ABCDEFGH01ABCDEFGH01ABCDEFGH01ABCDEFGH01.txt"));
       
   442 		MakeFile(_L("\\START\\LONG\\ELEPHANT01ELEPHANT02ELEPHANT03ELEPHANT04.txt"));
       
   443 		MakeFile(_L("\\START\\LONG\\DINOSAUR01DINOSAUR02DINOSAUR03DINOSAUR04.txt"));
       
   444 		MakeFile(_L("\\START\\LONG\\FILEFILE01FILEFILE02FILEFILE03FILEFILE04.txt"));
       
   445 		r=gFileMan->Rename(_L("\\START\\LONG"),_L("\\START\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff"),CFileMan::EOverWrite);
       
   446 		test(r==KErrNone);
       
   447 		MakeDir(_L("\\START\\ASDFFDSA\\"));
       
   448 		}
       
   449 
       
   450 	//testing invalid source path at the beginning:
       
   451 	if (!gAsynch)
       
   452 		{
       
   453 		r=gFileMan->Copy(_L(":C:\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0);
       
   454 		}
       
   455 	else
       
   456 		{
       
   457 		r=gFileMan->Copy(_L(":C:\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0,gStat);
       
   458 		}
       
   459 	TestResult(r,KErrBadName,KErrBadName);
       
   460 		
       
   461 	//testing invalid target path at the beginning:  
       
   462 		
       
   463 	if (!gAsynch)
       
   464 		{
       
   465 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L(":C:\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0);
       
   466 		}
       
   467 	else
       
   468 		{
       
   469 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L(":C:\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0,gStat);
       
   470 		}
       
   471 	TestResult(r,KErrBadName,KErrBadName);
       
   472   
       
   473 	//testing invalid source path at the middle:	
       
   474 	if (!gAsynch)
       
   475 		{
       
   476 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\:DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0);
       
   477 		}
       
   478 	else
       
   479 		{
       
   480 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\:DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0,gStat);
       
   481 		}
       
   482 	TestResult(r,KErrBadName,KErrNone);
       
   483 	
       
   484 	//testing invalid target path at the middle:	
       
   485 	if (!gAsynch)
       
   486 		{
       
   487 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\:DELDIR\\rumba?.txt"),0);
       
   488 		}
       
   489 	else
       
   490 		{
       
   491 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\:DELDIR\\rumba?.txt"),0,gStat);
       
   492 		}
       
   493 	TestResult(r,KErrBadName,KErrNone);
       
   494 
       
   495 	//testing invalid source path at the end:	
       
   496 	if (!gAsynch)
       
   497 		{
       
   498 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\:file?.txt"),_L("\\F32-TST\\TFMAN\\:DELDIR\\rumba?.txt"),0);
       
   499 		}
       
   500 	else
       
   501 		{
       
   502 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\:file?.txt"),_L("\\F32-TST\\TFMAN\\:DELDIR\\rumba?.txt"),0,gStat);
       
   503 		}
       
   504 	TestResult(r,KErrBadName,KErrNone);	
       
   505 	
       
   506 	//testing invalid target path at the end:	
       
   507 	if (!gAsynch)
       
   508 		{
       
   509 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\:DELDIR\\:rumba?.txt"),0);
       
   510 		}
       
   511 	else
       
   512 		{
       
   513 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\:DELDIR\\:rumba?.txt"),0,gStat);
       
   514 		}
       
   515 	TestResult(r,KErrBadName,KErrNone);
       
   516 		
       
   517 	if (!gAsynch)
       
   518 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0);
       
   519 	else
       
   520 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0,gStat);
       
   521 	TestResult(r,KErrAlreadyExists);
       
   522 
       
   523 	if (!gAsynch)
       
   524 		r = gFileMan->Delete(_L("\\F32-TST\\TFMAN\\DELDIR\\rumba.txt"),0);
       
   525 	else
       
   526 		r = gFileMan->Delete(_L("\\F32-TST\\TFMAN\\DELDIR\\rumba.txt"),0,gStat);
       
   527 	TestResult(r,KErrNone);
       
   528 
       
   529 	if (!gAsynch)
       
   530 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\file1.txt"),0);
       
   531 	else
       
   532 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\file1.txt"),0,gStat);
       
   533 	TestResult(r,KErrAlreadyExists);
       
   534 
       
   535 	if (!gAsynch)
       
   536 		{
       
   537 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\*.TXT"),_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
       
   538 		test(r==KErrNone);
       
   539 		if (testingInvalidPathLengths)
       
   540 			{
       
   541 			test.Next(_L("Test invalid length paths"));
       
   542 			r=gFileMan->Copy(_L("\\START\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\*.*"),_L("\\FINISH\\"));
       
   543 			test(r==KErrNone);
       
   544 			r=gFileMan->RmDir(_L("\\START\\"));
       
   545 			test(r==KErrNone);
       
   546 			r=gFileMan->RmDir(_L("\\FINISH\\"));
       
   547 			test(r==KErrNone);
       
   548 			}
       
   549 		}
       
   550 	else
       
   551 		{
       
   552 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\*.TXT"),_L("\\F32-TST\\TFMAN\\COPYDIR\\"),0,gStat);
       
   553 		WaitForSuccess();
       
   554 		test(r==KErrNone);
       
   555 		if (testingInvalidPathLengths)
       
   556 			{
       
   557 			test.Next(_L("Test invalid length paths (Asynch)"));
       
   558 			r=gFileMan->Copy(_L("\\START\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\*.*"),_L("\\FINISH\\"),0,gStat);
       
   559 			WaitForSuccess();
       
   560 			test(r==KErrNone);
       
   561 			r=gFileMan->RmDir(_L("\\START\\"),gStat);
       
   562 			WaitForSuccess();
       
   563 			test(r==KErrNone);
       
   564 			r=gFileMan->RmDir(_L("\\FINISH\\"),gStat);
       
   565 			WaitForSuccess();
       
   566 			test(r==KErrNone);
       
   567 			}
       
   568 		}
       
   569 	
       
   570 	if (!gAsynch)
       
   571 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\NewDir\\*.*"),_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
       
   572 	else
       
   573 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\NewDir\\*.*"),_L("\\F32-TST\\TFMAN\\COPYDIR\\"),0,gStat);
       
   574 	TestResult(r);
       
   575 
       
   576 	test.Next(_L("Check files have been copied"));
       
   577 	RmDir(_L("\\F32-TST\\TFMAN\\after\\"));
       
   578 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FILE1.TXT"));
       
   579 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FILE2.TXT"));
       
   580 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FILE3.TXT"));
       
   581 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\RUMBA1.TXT"));
       
   582 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\RUMBA2.TXT"));
       
   583 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\RUMBA3.TXT"));
       
   584 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\RUMBA4.TXT"));
       
   585 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\ABC.DEF"));
       
   586 	Compare(_L("\\F32-TST\\TFMAN\\AFTER\\*"),_L("\\F32-TST\\TFMAN\\COPYDIR\\*"));
       
   587 
       
   588 	TFileName fn = _L("Z:\\TEST\\T_FSRV.CPP");
       
   589 	fn[0] = gExeFileName[0];
       
   590 	if (!gAsynch)
       
   591 		r=gFileMan->Copy(fn,_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
       
   592 	else
       
   593 		r=gFileMan->Copy(fn,_L("\\F32-TST\\TFMAN\\COPYDIR\\"),0,gStat);
       
   594 	TestResult(KErrNone);
       
   595 
       
   596 	TEntry entry;
       
   597 	r=TheFs.Entry(_L("\\F32-TST\\TFMAN\\COPYDIR\\T_FSRV.CPP"),entry);
       
   598 	test(r==KErrNone);
       
   599 	test(entry.iName.MatchF(_L("T_FSRV.CPP"))!=KErrNotFound);
       
   600 #if defined (__WINS__)
       
   601 	test(entry.iAtt==KEntryAttArchive);
       
   602 #else
       
   603 	if (!IsTestingLFFS())
       
   604 		test(entry.iAtt==KEntryAttReadOnly);
       
   605 	else
       
   606 		test(entry.iAtt&KEntryAttReadOnly); // ???
       
   607 #endif
       
   608 	r=TheFs.SetAtt(_L("\\F32-TST\\TFMAN\\COPYDIR\\T_FSRV.CPP"),0,KEntryAttReadOnly);
       
   609 	test(r==KErrNone);
       
   610 
       
   611 	r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\AFTER\\RUMBA?.TXT"));
       
   612 	test(r==KErrNone);
       
   613 	r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA?.TXT"));
       
   614 	test(r==KErrNone);
       
   615 	
       
   616 	}
       
   617 LOCAL_C void TestDEF121663_Setup(TFileName& aSrcPath)
       
   618 	{
       
   619 	RmDir(aSrcPath);
       
   620 	MakeDir(aSrcPath);
       
   621 	
       
   622 	for(TInt index=0; index<10; index++)
       
   623 		{
       
   624 		TFileName fileName;
       
   625 	    fileName.Copy(aSrcPath);
       
   626 	    fileName.Append(_L("FILE_"));fileName.AppendNum(index);fileName.Append(_L(".TXT"));
       
   627 		MakeFile(fileName, _L8("Some Data"));
       
   628 		}
       
   629 	}
       
   630 	
       
   631 LOCAL_C void TestDEF121663()
       
   632 	{
       
   633 	test.Next(_L("++TestDEF121663"));
       
   634 	
       
   635 	gFileMan->SetObserver(NULL);
       
   636 	TInt err = 0;
       
   637 	TFileName srcPath = _L("C:\\TestDEF121663\\");
       
   638 		
       
   639 	TestDEF121663_Setup(srcPath);
       
   640 	if(!gAsynch)
       
   641 		{
       
   642 		err = gFileMan->Move(_L("C:\\TestDEF121663"),_L("C:\\TestDEF121663\\TestDEF121663"),CFileMan::EOverWrite);
       
   643 		}
       
   644 	else
       
   645 		{
       
   646 		err = gFileMan->Move(_L("C:\\TestDEF121663"),_L("C:\\TestDEF121663\\TestDEF121663"),CFileMan::EOverWrite, gStat);
       
   647 		}
       
   648 	TestResult(err,KErrInUse,KErrInUse);
       
   649 
       
   650 	TestDEF121663_Setup(srcPath);
       
   651 	if(!gAsynch)
       
   652 		{
       
   653 		err = gFileMan->Move(_L("C:\\TestDEF121663\\"),_L("C:\\TestDEF121663\\TestDEF121663\\"),CFileMan::EOverWrite);
       
   654 		}
       
   655 	else
       
   656 		{
       
   657 		err = gFileMan->Move(_L("C:\\TestDEF121663\\"),_L("C:\\TestDEF121663\\TestDEF121663\\"),CFileMan::EOverWrite, gStat);
       
   658 		}
       
   659 	TestResult(err,KErrPathNotFound);
       
   660 	
       
   661 	TestDEF121663_Setup(srcPath);
       
   662 	if(!gAsynch)
       
   663 		{
       
   664 		err = gFileMan->Move(_L("C:\\TestDEF121663\\"),_L("C:\\TestDEF121663\\TestDEF121663"),CFileMan::EOverWrite);
       
   665 		}
       
   666 	else
       
   667 		{
       
   668 		err = gFileMan->Move(_L("C:\\TestDEF121663\\"),_L("C:\\TestDEF121663\\TestDEF121663"),CFileMan::EOverWrite, gStat);
       
   669 		}
       
   670 	TestResult(err,KErrPathNotFound);
       
   671 
       
   672 	TestDEF121663_Setup(srcPath);
       
   673 	if(!gAsynch)
       
   674 		{
       
   675 		err = gFileMan->Move(_L("C:\\TestDEF121663"),_L("C:\\TestDEF121663\\TestDEF121663\\"),CFileMan::ERecurse|CFileMan::EOverWrite);
       
   676 		}
       
   677 	else
       
   678 		{
       
   679 		err = gFileMan->Move(_L("C:\\TestDEF121663"),_L("C:\\TestDEF121663\\TestDEF121663\\"),CFileMan::ERecurse|CFileMan::EOverWrite, gStat);
       
   680 		}
       
   681 	TestResult(err,KErrInUse,KErrInUse);
       
   682 
       
   683 	TestDEF121663_Setup(srcPath);
       
   684 	if(!gAsynch)
       
   685 		{
       
   686 		err = gFileMan->Move(_L("C:\\TestDEF121663"),_L("C:\\TestDEF121663\\TestDEF121663"),CFileMan::ERecurse);
       
   687 		}
       
   688 	else
       
   689 		{
       
   690 		err = gFileMan->Move(_L("C:\\TestDEF121663"),_L("C:\\TestDEF121663\\TestDEF121663"),CFileMan::ERecurse, gStat);
       
   691 		}
       
   692 	TestResult(err,KErrInUse,KErrInUse);
       
   693 	
       
   694 	gFileMan->SetObserver(gObserver);
       
   695 	// remove previous dirs
       
   696 	RmDir(_L("C:\\TestDEF121663\\"));
       
   697 	test.Next(_L("--TestDEF121663"));
       
   698 	}
       
   699 
       
   700 LOCAL_C void TestDEF123575()
       
   701 	{
       
   702 	test.Next(_L("++TestDEF123575"));
       
   703 	TFileName srcPath;
       
   704 	TFileName destPath;
       
   705 	TInt err;
       
   706 	//setup the initial directory structure
       
   707 	srcPath = _L("\\F32-TST\\DEF123575\\SRCDIR\\CommonDIR\\temp\\temp1.1\\");
       
   708 	destPath = _L("\\F32-TST\\DEF123575\\DSTDIR\\CommonDIR\\temp\\temp1.1\\");
       
   709 	MakeDir(srcPath);
       
   710 	MakeDir(destPath);
       
   711 	MakeFile(_L("\\F32-TST\\DEF123575\\SRCDIR\\CommonDIR\\temp\\temp1.1\\FILE1.TXT"));
       
   712 	
       
   713 	srcPath = _L("\\F32-TST\\DEF123575\\SRCDIR\\CommonDIR");
       
   714 	destPath = _L("\\F32-TST\\DEF123575\\DSTDIR\\");
       
   715 	if(!gAsynch)
       
   716 		{
       
   717 		err = gFileMan->Move(srcPath,destPath,CFileMan::EOverWrite);
       
   718 		}
       
   719 	else
       
   720 		{
       
   721 		err = gFileMan->Move(srcPath,destPath,CFileMan::EOverWrite, gStat);
       
   722 		}
       
   723 	TestResult(err,KErrNone,KErrNone);
       
   724 
       
   725 	//test that source directory is empty after move
       
   726 	MakeDir(_L("\\F32-TST\\DEF123575\\AFTER\\"));
       
   727 	Compare(_L("\\F32-TST\\DEF123575\\SRCDIR\\*"),_L("\\F32-TST\\DEF123575\\AFTER\\*"));
       
   728 	//test that the files have been moved to the destination directory
       
   729 	MakeDir(_L("\\F32-TST\\DEF123575\\AFTER\\CommonDIR\\temp\\temp1.1\\"));
       
   730 	MakeFile(_L("\\F32-TST\\DEF123575\\AFTER\\CommonDIR\\temp\\temp1.1\\FILE1.TXT"));
       
   731 	Compare(_L("\\F32-TST\\DEF123575\\DSTDIR\\*"),_L("\\F32-TST\\DEF123575\\AFTER\\*"));
       
   732 	
       
   733 	//delete the entire directory structure
       
   734 	RmDir(_L("\\F32-TST\\DEF123575\\*"));
       
   735 	test.Next(_L("--TestDEF123575"));
       
   736 	}
       
   737 
       
   738 LOCAL_C void TestDEF125570()
       
   739 	{
       
   740 	test.Next(_L("++TestDEF125570"));
       
   741 	gFileMan->SetObserver(NULL);
       
   742 	TInt err = KErrNone; 
       
   743 	TFileName srcPath = _L("C:\\TestDEF125570\\src\\");
       
   744 	TFileName trgPath = _L("C:\\TestDEF125570\\trg\\");
       
   745 
       
   746 	// remove previous dirs
       
   747 	RmDir(srcPath);
       
   748 	RmDir(trgPath);
       
   749 
       
   750 	//create src
       
   751 	MakeDir(_L("C:\\TestDEF125570\\src\\DIR1\\"));
       
   752 	MakeFile(_L("C:\\TestDEF125570\\src\\DIR1\\File1.txt"),_L8("FILE PATH : C:\\TestDEF125570\\SRC\\DIR1\\File1.txt"));
       
   753 	MakeFile(_L("C:\\TestDEF125570\\src\\DIR1\\File2.txt"),_L8("FILE PATH : C:\\TestDEF125570\\SRC\\DIR1\\File2.txt"));
       
   754 	MakeDir(_L("C:\\TestDEF125570\\src\\DIR1\\DIR11\\"));
       
   755 	MakeFile(_L("C:\\TestDEF125570\\src\\DIR1\\DIR11\\File1.txt"),_L8("FILE PATH : C:\\TestDEF125570\\SRC\\DIR1\\DIR11\\File1.txt"));
       
   756 	MakeFile(_L("C:\\TestDEF125570\\src\\DIR1\\DIR11\\File2.txt"),_L8("FILE PATH : C:\\TestDEF125570\\SRC\\DIR1\\DIR11\\File2.txt"));
       
   757 	MakeDir(_L("C:\\TestDEF125570\\src\\DIR2\\"));
       
   758 	MakeFile(_L("C:\\TestDEF125570\\src\\DIR2\\File1.txt"),_L8("FILE PATH : C:\\TestDEF125570\\SRC\\DIR2\\File1.txt"));
       
   759 	MakeFile(_L("C:\\TestDEF125570\\src\\DIR2\\File2.txt"),_L8("FILE PATH : C:\\TestDEF125570\\SRC\\DIR2\\File2.txt"));
       
   760 	MakeDir(_L("C:\\TestDEF125570\\src\\DIR2\\DIR12\\"));
       
   761 	MakeFile(_L("C:\\TestDEF125570\\src\\DIR2\\DIR12\\File1.txt"),_L8("FILE PATH : C:\\TestDEF125570\\SRC\\DIR2\\DIR12\\File1.txt"));
       
   762 	MakeFile(_L("C:\\TestDEF125570\\src\\DIR2\\DIR12\\File2.txt"),_L8("FILE PATH : C:\\TestDEF125570\\SRC\\DIR2\\DIR12\\File2.txt"));
       
   763 
       
   764 	//trg has at least one of the src subfolders
       
   765 	MakeDir(_L("C:\\TestDEF125570\\trg\\DIR2\\"));
       
   766 	MakeFile(_L("C:\\TestDEF125570\\trg\\DIR2\\File1.txt"),_L8("FILE PATH : C:\\TestDEF125570\\TRG\\DIR2\\File1.txt"));
       
   767 	MakeFile(_L("C:\\TestDEF125570\\trg\\DIR2\\File2.txt"),_L8("FILE PATH : C:\\TestDEF125570\\TRG\\DIR2\\File2.txt"));
       
   768 
       
   769 	if(!gAsynch)
       
   770 		err = gFileMan->Move(srcPath, trgPath, CFileMan::ERecurse|CFileMan::EOverWrite);
       
   771 	else
       
   772 		err = gFileMan->Move(srcPath, trgPath, CFileMan::ERecurse|CFileMan::EOverWrite, gStat);
       
   773 	TestResult(err);
       
   774 	gFileMan->SetObserver(gObserver);
       
   775 	// remove previous dirs
       
   776 	RmDir(_L("C:\\TestDEF125570\\"));
       
   777 	test.Next(_L("--TestDEF125570"));
       
   778 	}
       
   779 
       
   780 LOCAL_C void TestDEF130404()
       
   781 	{
       
   782 	test.Printf(_L("++TestDEF130404"));
       
   783 	
       
   784 	TInt r = 0;
       
   785 	TFileName trgPath;
       
   786 	trgPath.Format(_L("%c:\\TestDEF130404\\Trg\\"), (TUint8)gDriveToTest);
       
   787 	TFileName srcPath;
       
   788 	srcPath.Format(_L("C:\\TestDEF130404\\Src\\DIR1\\"), (TUint8)gDriveToTest);
       
   789 
       
   790 	// clean up before testing
       
   791 	RmDir(srcPath);
       
   792 	RmDir(trgPath);
       
   793 	
       
   794 	MakeDir(srcPath);
       
   795 	srcPath.Append(_L("NODIR\\*.*"));
       
   796 	MakeDir(trgPath);
       
   797 	
       
   798 	if(!gAsynch)
       
   799 		r = gFileMan->Move(srcPath, trgPath, 0);
       
   800 	else
       
   801 	 	r = gFileMan->Move(srcPath, trgPath, 0, gStat);
       
   802 	TestResult(r,KErrPathNotFound);
       
   803 	
       
   804 	// clean up before leaving
       
   805 	trgPath.Format(_L("%c:\\TestDEF130404\\"), (TUint8)gDriveToTest);
       
   806 	RmDir(trgPath);
       
   807 	RmDir(_L("C:\\TestDEF130404\\"));
       
   808 	
       
   809 	test.Printf(_L("--TestDEF130404"));
       
   810 	}
       
   811 
       
   812 
       
   813 /**
       
   814 This is to test that moving files to overwrite folders with the same names 
       
   815 returns proper error code. 
       
   816 */
       
   817 void TestPDEF137716()
       
   818 	{
       
   819 	test.Next(_L("Test moving files to overwrite folders or folders to files"));
       
   820 
       
   821 	TInt err = KErrNone;
       
   822 	gFileMan->SetObserver(NULL);
       
   823 	
       
   824 #if defined(__WINS__)
       
   825 	_LIT(KFileToDirTargetName,			"Y:\\PDEF137716\\FileToDir_Target\\ITEM");
       
   826 	_LIT(KFileToDirTargetNameWild,		"Y:\\PDEF137716\\FileToDir_Target\\");
       
   827 
       
   828 	_LIT(KFixedTargetTestFolder,		"Y:\\PDEF137716\\");
       
   829 	_LIT(KFileToDirTargetCreatePath,	"Y:\\PDEF137716\\FileToDir_Target\\ITEM\\");
       
   830 #else
       
   831 	_LIT(KFileToDirTargetName,			"D:\\PDEF137716\\FileToDir_Target\\ITEM");
       
   832 	_LIT(KFileToDirTargetNameWild,		"D:\\PDEF137716\\FileToDir_Target\\");
       
   833 
       
   834 	_LIT(KFixedTargetTestFolder,		"D:\\PDEF137716\\");
       
   835 	_LIT(KFileToDirTargetCreatePath,	"D:\\PDEF137716\\FileToDir_Target\\ITEM\\");
       
   836 #endif
       
   837 
       
   838 	_LIT(KFixedSrouceTestFolder,		"\\PDEF137716\\");
       
   839 	_LIT(KFileToDirSourceName,			"\\PDEF137716\\FileToDir_Source\\ITEM");
       
   840 	_LIT(KFileToDirSourceNameWild,		"\\PDEF137716\\FileToDir_Source\\");
       
   841 	
       
   842 	RmDir(KFixedTargetTestFolder);
       
   843 	RmDir(KFixedSrouceTestFolder);
       
   844 	MakeDir(KFileToDirTargetCreatePath);
       
   845 	MakeFile(KFileToDirSourceName);
       
   846 	err = gFileMan->Move(KFileToDirSourceName, KFileToDirTargetNameWild, 0);
       
   847 	test(err == KErrAccessDenied);
       
   848 
       
   849 	RmDir(KFixedTargetTestFolder);
       
   850 	RmDir(KFixedSrouceTestFolder);
       
   851 	MakeDir(KFileToDirTargetCreatePath);
       
   852 	MakeFile(KFileToDirSourceName);
       
   853 	err = gFileMan->Move(KFileToDirTargetName, KFileToDirSourceNameWild, CFileMan::EOverWrite);
       
   854 	test(err == KErrAccessDenied);
       
   855 
       
   856 	RmDir(KFixedTargetTestFolder);
       
   857 	RmDir(KFixedSrouceTestFolder);
       
   858 	MakeDir(KFileToDirTargetCreatePath);
       
   859 	MakeFile(KFileToDirSourceName);
       
   860 	err = gFileMan->Move(KFileToDirSourceNameWild, KFileToDirTargetNameWild, 0);
       
   861 	test(err == KErrAccessDenied);
       
   862 
       
   863 	RmDir(KFixedTargetTestFolder);
       
   864 	RmDir(KFixedSrouceTestFolder);
       
   865 	MakeDir(KFileToDirTargetCreatePath);
       
   866 	MakeFile(KFileToDirSourceName);
       
   867 	err = gFileMan->Move(KFileToDirSourceNameWild, KFileToDirTargetNameWild, CFileMan::EOverWrite);
       
   868 	test(err == KErrAccessDenied);
       
   869 
       
   870 #if defined(__WINS__)
       
   871 	_LIT(KDirToFileTargetName,			"Y:\\PDEF137716\\DirToFile_Target\\ITEM");
       
   872 	_LIT(KDirToFileTargetNameWild,		"Y:\\PDEF137716\\DirToFile_Target\\");
       
   873 #else
       
   874 	_LIT(KDirToFileTargetName,			"D:\\PDEF137716\\DirToFile_Target\\ITEM");
       
   875 	_LIT(KDirToFileTargetNameWild,		"D:\\PDEF137716\\DirToFile_Target\\");
       
   876 #endif
       
   877 	
       
   878 	_LIT(KDirToFileSourceName,			"\\PDEF137716\\DirToFile_Source\\ITEM");
       
   879 	_LIT(KDirToFileSourceNameWild,		"\\PDEF137716\\DirToFile_Source\\");
       
   880 
       
   881 	_LIT(KDirToFileSourceCreatePath,	"\\PDEF137716\\DirToFile_Source\\ITEM\\");
       
   882 
       
   883 	RmDir(KFixedTargetTestFolder);
       
   884 	RmDir(KFixedSrouceTestFolder);
       
   885 	MakeFile(KDirToFileTargetName);
       
   886 	MakeDir(KDirToFileSourceCreatePath);
       
   887 	err = gFileMan->Move(KDirToFileSourceName, KDirToFileTargetName, 0);
       
   888 	test(err == KErrAccessDenied);
       
   889 
       
   890 	RmDir(KFixedTargetTestFolder);
       
   891 	RmDir(KFixedSrouceTestFolder);
       
   892 	MakeFile(KDirToFileTargetName);
       
   893 	MakeDir(KDirToFileSourceCreatePath);
       
   894 	err = gFileMan->Move(KDirToFileSourceName, KDirToFileTargetName, CFileMan::EOverWrite);
       
   895 	test(err == KErrAccessDenied);
       
   896 
       
   897 	RmDir(KFixedTargetTestFolder);
       
   898 	RmDir(KFixedSrouceTestFolder);
       
   899 	MakeFile(KDirToFileTargetName);
       
   900 	MakeDir(KDirToFileSourceCreatePath);
       
   901 	err = gFileMan->Move(KDirToFileSourceName, KDirToFileTargetNameWild, 0);
       
   902 	test(err == KErrAccessDenied);
       
   903 
       
   904 	RmDir(KFixedTargetTestFolder);
       
   905 	RmDir(KFixedSrouceTestFolder);
       
   906 	MakeFile(KDirToFileTargetName);
       
   907 	MakeDir(KDirToFileSourceCreatePath);
       
   908 	err = gFileMan->Move(KDirToFileSourceName, KDirToFileTargetNameWild, CFileMan::EOverWrite);
       
   909 	test(err == KErrAccessDenied);
       
   910 
       
   911 	RmDir(KFixedTargetTestFolder);
       
   912 	RmDir(KFixedSrouceTestFolder);
       
   913 	MakeFile(KDirToFileTargetName);
       
   914 	MakeDir(KDirToFileSourceCreatePath);
       
   915 	err = gFileMan->Move(KDirToFileSourceNameWild, KDirToFileTargetNameWild, 0);
       
   916 	test(err == KErrNotFound);
       
   917 
       
   918 	RmDir(KFixedTargetTestFolder);
       
   919 	RmDir(KFixedSrouceTestFolder);
       
   920 	MakeFile(KDirToFileTargetName);
       
   921 	MakeDir(KDirToFileSourceCreatePath);
       
   922 	err = gFileMan->Move(KDirToFileSourceNameWild, KDirToFileTargetNameWild, CFileMan::EOverWrite);
       
   923 	test(err == KErrNotFound);
       
   924 
       
   925 	RmDir(KFixedTargetTestFolder);
       
   926 	RmDir(KFixedSrouceTestFolder);
       
   927 	}
       
   928 
       
   929 LOCAL_C void TestMove()
       
   930 //
       
   931 // Test Move
       
   932 //
       
   933 	{
       
   934 
       
   935 	test.Next(_L("Test move"));
       
   936 	RmDir(_L("\\F32-TST\\TFMAN\\MOVEDIR\\*"));
       
   937 
       
   938 	MakeDir(_L("\\F32-TST\\TFMAN\\MOVEDIR\\"));
       
   939 	MakeDir(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EMPTY\\"));
       
   940 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"));
       
   941 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE2.TXT"));
       
   942 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE3.TXT"));
       
   943 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\FILE4.TXT"));
       
   944 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EXE1.BIN"));
       
   945 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\EXE2.BIN"));
       
   946 
       
   947 	TInt r=KErrNone;
       
   948 
       
   949 	if (testingInvalidPathLengths)
       
   950 //	Create a path of greater 256 characters by renaming a directory and check it can be
       
   951 //	manipulated (tests fix to F32)		
       
   952 		{
       
   953 		MakeDir(_L("\\START\\LONG\\"));
       
   954 		MakeDir(_L("\\FINISH\\"));
       
   955 		MakeFile(_L("\\START\\LONG\\ABCDEFGH01ABCDEFGH01ABCDEFGH01ABCDEFGH01.txt"));
       
   956 		MakeFile(_L("\\START\\LONG\\ELEPHANT01ELEPHANT02ELEPHANT03ELEPHANT04.txt"));
       
   957 		MakeFile(_L("\\START\\LONG\\DINOSAUR01DINOSAUR02DINOSAUR03DINOSAUR04.txt"));
       
   958 		MakeFile(_L("\\START\\LONG\\FILEFILE01FILEFILE02FILEFILE03FILEFILE04.txt"));
       
   959 		r=gFileMan->Rename(_L("\\START\\LONG"),_L("\\START\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff"),CFileMan::EOverWrite);
       
   960 		test(r==KErrNone);
       
   961 
       
   962 	//	Two long directory names - makes paths invalid
       
   963 		MakeDir(_L("\\TEST\\LONG\\NAME\\FGHIJ"));
       
   964 		MakeDir(_L("\\TEST\\LONG\\NAME\\FGHIJ\\DIRECTORY1DIRECTORY2DIRECTORY3DIRECTORY4\\"));
       
   965 		MakeFile(_L("\\TEST\\LONG\\NAME\\FGHIJ\\ELEPHANT01ELEPHANT02ELEPHANT03ELEPHANT04"));
       
   966 		MakeFile(_L("\\TEST\\LONG\\NAME\\FGHIJ\\FILEFILE01FILEFILE02FILEFILE03FILEFILE04"));
       
   967 		r=gFileMan->Rename(_L("\\TEST\\LONG"),_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds"),CFileMan::EOverWrite);
       
   968 		test(r==KErrNone);
       
   969 	
       
   970 		MakeDir(_L("\\START\\ASDFFDSA\\"));
       
   971 		}
       
   972 
       
   973 	//testing invalid source path at the beginning:
       
   974 	if (!gAsynch)
       
   975 		{
       
   976 		r=gFileMan->Move(_L(":C:\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"));
       
   977 		}
       
   978 	else
       
   979 		{
       
   980 		r=gFileMan->Move(_L(":C:\\F32-TST\\TFMAN\\DELDIR\\FILE?.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE*.TXT"),0,gStat);
       
   981 		}
       
   982 	TestResult(r,KErrBadName,KErrBadName);
       
   983 		
       
   984 	//testing invalid target path at the beginning:
       
   985 	if (!gAsynch)
       
   986 		{
       
   987 		r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),_L(":C:\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"));
       
   988 		}
       
   989 	else
       
   990 		{
       
   991 		r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE?.TXT"),_L(":C:\\F32-TST\\TFMAN\\DELDIR\\FILE*.TXT"),0,gStat);
       
   992 		}
       
   993 	TestResult(r,KErrBadName,KErrBadName);
       
   994 
       
   995 	//testing invalid source path at the middle:	
       
   996 	if (!gAsynch)
       
   997 		{
       
   998 		r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\:DELDIR\\FILE1.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"));
       
   999 		}
       
  1000 	else
       
  1001 		{
       
  1002 		r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\:DELDIR\\FILE?.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE*.TXT"),0,gStat);
       
  1003 		}
       
  1004 	TestResult(r,KErrBadName,KErrNone);
       
  1005 	
       
  1006 	//testing invalid target path at the middle:	
       
  1007 	if (!gAsynch)
       
  1008 		{
       
  1009 		r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),_L("\\F32-TST\\TFMAN\\:DELDIR\\FILE1.TXT"));
       
  1010 		}
       
  1011 	else
       
  1012 		{
       
  1013 		r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE?.TXT"),_L("\\F32-TST\\TFMAN\\:DELDIR\\FILE*.TXT"),0,gStat);
       
  1014 		}
       
  1015 	TestResult(r,KErrBadName,KErrNone);
       
  1016 
       
  1017 	//testing invalid source path at the end:	
       
  1018 	if (!gAsynch)
       
  1019 		{
       
  1020 		r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\:FILE1.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"));
       
  1021 		}
       
  1022 	else
       
  1023 		{
       
  1024 		r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\:FILE?.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE*.TXT"),0,gStat);
       
  1025 		}
       
  1026 	TestResult(r,KErrBadName,KErrNone);
       
  1027 	
       
  1028 	//testing invalid target path at the end:	
       
  1029 	if (!gAsynch)
       
  1030 		{
       
  1031 		r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\:FILE1.TXT"));
       
  1032 		}
       
  1033 	else
       
  1034 		{
       
  1035 		r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE?.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\:FILE*.TXT"),0,gStat);
       
  1036 		}
       
  1037 	TestResult(r,KErrBadName,KErrNone);	
       
  1038 	
       
  1039 
       
  1040 	if (!gAsynch)
       
  1041 		r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE?.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE*.TXT"));
       
  1042 	else
       
  1043 		r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE?.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE*.TXT"),0,gStat);
       
  1044 	TestResult(r,KErrNone);
       
  1045 
       
  1046 	if ((!gAsynch)&&(testingInvalidPathLengths))
       
  1047 		{
       
  1048 		r=gFileMan->Move(_L("\\START\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\*.*"),_L("\\FINISH\\"));
       
  1049 		test(r==KErrNone);
       
  1050 		
       
  1051 		r=gFileMan->Move(_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds\\*.*"),_L("\\FINISH\\"), CFileMan::EOverWrite | CFileMan::ERecurse);
       
  1052 		test(r==KErrNone);
       
  1053 
       
  1054 		r=gFileMan->RmDir(_L("\\START\\"));
       
  1055 		test(r==KErrNone);
       
  1056 		r=gFileMan->RmDir(_L("\\FINISH\\"));
       
  1057 		test(r==KErrNone);
       
  1058 		}
       
  1059 	if ((gAsynch)&&(testingInvalidPathLengths))
       
  1060 		{
       
  1061 		r=gFileMan->Move(_L("\\START\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\*.*"),_L("\\FINISH\\"),CFileMan::EOverWrite,gStat);
       
  1062 		User::WaitForRequest(gStat);
       
  1063 		test(r==KErrNone);
       
  1064 		r=gFileMan->Move(_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds\\*.*"),_L("\\FINISH\\"), CFileMan::EOverWrite | CFileMan::ERecurse,gStat);
       
  1065 		User::WaitForRequest(gStat);
       
  1066 		test(r==KErrNone);
       
  1067 		r=gFileMan->RmDir(_L("\\START\\"),gStat);
       
  1068 		WaitForSuccess();
       
  1069 		test(r==KErrNone);
       
  1070 		r=gFileMan->RmDir(_L("\\FINISH\\"),gStat);
       
  1071 		WaitForSuccess();
       
  1072 		test(r==KErrNone);
       
  1073 		}
       
  1074 
       
  1075 	if (!gAsynch)
       
  1076 		r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"));
       
  1077 	else
       
  1078 		r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),0,gStat);
       
  1079 	TestResult(r,KErrNone);
       
  1080 
       
  1081 	if (!gAsynch)
       
  1082 		r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\*.TXT"),_L("\\F32-TST\\TFMAN\\MOVEDIR\\"));
       
  1083 	else
       
  1084 		r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\*.TXT"),_L("\\F32-TST\\TFMAN\\MOVEDIR\\"),0,gStat);
       
  1085 	TestResult(r);
       
  1086 
       
  1087 	if (!gAsynch)
       
  1088 		r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\*.TXT"),_L("\\F32-TST\\TFMAN\\MoveDIR.\\FILE*.TXT"));
       
  1089 	else
       
  1090 		r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\*.TXT"),_L("\\F32-TST\\TFMAN\\MoveDIR\\FILE*.TXT"),0,gStat);
       
  1091 	TestResult(r,KErrNotFound);
       
  1092 
       
  1093 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"));
       
  1094 	if (!gAsynch)
       
  1095 		r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),_L("\\F32-TST\\TFMAN\\MoveDIR\\FILE1.TXT"),0);
       
  1096 	else
       
  1097 		r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),_L("\\F32-TST\\TFMAN\\MoveDIR\\FILE1.TXT"),0,gStat);
       
  1098 	TestResult(r,KErrAlreadyExists);
       
  1099 	r=TheFs.Delete(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"));
       
  1100 	test(r==KErrNone);
       
  1101 
       
  1102 	test.Next(_L("Check files have been moved"));
       
  1103 	RmDir(_L("\\F32-TST\\TFMAN\\AFTER\\*"));
       
  1104 	MakeDir(_L("\\F32-TST\\TFMAN\\AFTER\\DELTEST\\EMPTY\\"));
       
  1105 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\DELTEST\\FILE4.TXT"));
       
  1106 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\DELTEST\\EXE1.BIN"));
       
  1107 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\EXE2.BIN"));
       
  1108 	Compare(_L("\\F32-TST\\TFMAN\\AFTER\\*"),_L("\\F32-TST\\TFMAN\\DELDIR\\*"));
       
  1109 
       
  1110 	RmDir(_L("\\F32-TST\\TFMAN\\AFTER\\*"));
       
  1111 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FILE1.TXT"));
       
  1112 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FILE2.TXT"));
       
  1113 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FILE3.TXT"));
       
  1114 	Compare(_L("\\F32-TST\\TFMAN\\AFTER\\*"),_L("\\F32-TST\\TFMAN\\MOVEDIR\\*"));
       
  1115 
       
  1116 	if (testingInvalidPathLengths)
       
  1117 		{
       
  1118 		r=gFileMan->RmDir(_L("\\TEST\\"));
       
  1119 		test(r==KErrNone);
       
  1120 		}
       
  1121 	// Test moving directory to its subdirectory
       
  1122 	TestDEF121663();
       
  1123 	TestDEF123575();
       
  1124 	//Test Move when trg has at least one of the src dirs
       
  1125 	TestDEF125570();
       
  1126 	//Test move when the src doesn't fully exist 
       
  1127 	TestDEF130404();
       
  1128 	
       
  1129 	// Test moving files to overwrite folders that have the same names.
       
  1130 	TestPDEF137716();
       
  1131 	}
       
  1132 
       
  1133 LOCAL_C void TestSimultaneous()
       
  1134 //
       
  1135 // Create and run two CFileMen simultaneously
       
  1136 //
       
  1137 	{
       
  1138 
       
  1139 	test.Next(_L("Create and run two CFileMans simultaneously"));
       
  1140 	RmDir(_L("\\F32-TST\\TFMAN\\fman2\\"));
       
  1141 
       
  1142 	MakeDir(_L("\\F32-TST\\TFMAN\\FMAN1\\"));
       
  1143 	MakeDir(_L("\\F32-TST\\TFMAN\\FMAN2\\"));
       
  1144 	MakeFile(_L("\\F32-TST\\TFMAN\\FMAN1\\ROD.TXT"));
       
  1145 	MakeFile(_L("\\F32-TST\\TFMAN\\FMAN1\\JANE.TXT"));
       
  1146 	MakeFile(_L("\\F32-TST\\TFMAN\\FMAN1\\FREDDY.TXT"));
       
  1147 	MakeFile(_L("\\F32-TST\\TFMAN\\FMAN2\\BORIS.TXT"));
       
  1148 	MakeFile(_L("\\F32-TST\\TFMAN\\FMAN2\\FREDRICK.TXT"));
       
  1149 	MakeFile(_L("\\F32-TST\\TFMAN\\FMAN2\\PETER.TXT"));
       
  1150 
       
  1151 	CFileMan* fman=CFileMan::NewL(TheFs);
       
  1152 	TRequestStatus stat1;
       
  1153 	TInt r=fman->Delete(_L("\\F32-TST\\TFMAN\\FMAN1\\*.*"),0,stat1);
       
  1154 	test(r==KErrNone);
       
  1155 	r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\FMAN2\\*.TXT"),_L("\\F32-TST\\TFMAN\\FMAN2\\*.EXT"),0,gStat);
       
  1156 	test(r==KErrNone);
       
  1157 	FOREVER
       
  1158 		{
       
  1159 		if (stat1!=KRequestPending && gStat!=KRequestPending)
       
  1160 			break;
       
  1161 		User::WaitForAnyRequest();
       
  1162 		}
       
  1163 	test(stat1==KErrNone && gStat==KErrNone);
       
  1164 	delete fman;
       
  1165 	
       
  1166 	test.Next(_L("Check all files"));
       
  1167 	RmDir(_L("\\F32-TST\\TFMAN\\AFTER\\*"));
       
  1168 
       
  1169 	MakeDir(_L("\\F32-TST\\TFMAN\\AFTER\\"));
       
  1170 	Compare(_L("\\F32-TST\\TFMAN\\After\\*"),_L("\\F32-TST\\TFMAN\\FMAN1\\*"));
       
  1171 
       
  1172 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\BORIS.EXT"));
       
  1173 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FREDRICK.EXT"));
       
  1174 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\PETER.EXT"));
       
  1175 	Compare(_L("\\F32-TST\\TFMAN\\After\\*"),_L("\\F32-TST\\TFMAN\\FMAN2\\*"));
       
  1176 	}
       
  1177 
       
  1178 LOCAL_C void TestDEF092084()
       
  1179 	{
       
  1180 	if(gAsynch)  
       
  1181 		{
       
  1182 		return;
       
  1183 		}
       
  1184 	MakeDir(_L("\\DEF092084"));
       
  1185 	MakeFile(_L("\\DEF092084\\FILE1.TXT"));
       
  1186 	
       
  1187 	TInt r = gFileMan->Rename(_L("\\DEF092084\\*.TXT"),_L("\\DEF092084\\*.DDB"), CFileMan::EOverWrite);
       
  1188 	test(r==KErrNone); 
       
  1189 	CheckFileExists(_L("\\DEF092084\\FILE1.DDB"), KErrNone);
       
  1190 	
       
  1191 	r = gFileMan->Rename(_L("\\DEF092084\\?*.DD?"),_L("\\DEF092084\\?*.TXT"), CFileMan::EOverWrite);
       
  1192 	test(r==KErrNone); 
       
  1193 	CheckFileExists(_L("\\DEF092084\\FILE1.TXT"), KErrNone);
       
  1194 	
       
  1195 	RmDir(_L("\\DEF092084\\"));  
       
  1196 	}
       
  1197   
       
  1198 //--------------------------------------------- 
       
  1199 //! @SYMTestCaseID			PBASE-T_FMAN-0542
       
  1200 //! @SYMTestType			UT 
       
  1201 //! @SYMREQ					INC109754
       
  1202 //! @SYMTestCaseDesc		1. Tests that CFileMan::Rename() does not incorrectly remove empty source directory
       
  1203 //! @SYMTestActions			Renames the only file from source directory to target directory, then check if 
       
  1204 //!							the empty source directory still exists.
       
  1205 //!							2. Tests the trailing backslash ("\") is interpreted to ("\*.*").
       
  1206 //! @SYMTestExpectedResults	The operation completes with error code KErrNone;
       
  1207 //!							The empty source directory still exists.
       
  1208 //! @SYMTestPriority		High
       
  1209 //! @SYMTestStatus			Implemented 
       
  1210 //--------------------------------------------- 	
       
  1211 void TestINC109754()
       
  1212 	{
       
  1213 	test.Next(_L("Test empty source directory should exist after contents being renamed (INC109754)"));
       
  1214 	TInt r = KErrNone;
       
  1215 	// Setting up comparing dir
       
  1216 	RmDir(		_L("\\F32-TST\\TFMAN\\INC109754_C\\"));
       
  1217 	MakeDir(	_L("\\F32-TST\\TFMAN\\INC109754_C\\SRC\\"));
       
  1218 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC109754_C\\TRG\\FILE.TXT"));
       
  1219 
       
  1220 	// Setting up testing dir
       
  1221 	RmDir(		_L("\\F32-TST\\TFMAN\\INC109754\\"));
       
  1222 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC109754\\SRC\\FILE.TXT"));
       
  1223 	MakeDir(	_L("\\F32-TST\\TFMAN\\INC109754\\TRG\\"));
       
  1224 
       
  1225 	// Test case 1: CFileMan::Rename(_L("C:\\SRC\\"), 	_L("C:\\TRG\\"));
       
  1226 	if (!gAsynch)
       
  1227 		r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\INC109754\\SRC\\"),_L("\\F32-TST\\TFMAN\\INC109754\\TRG\\"));
       
  1228 	else
       
  1229 		r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\INC109754\\SRC\\"),_L("\\F32-TST\\TFMAN\\INC109754\\TRG\\"),0,gStat);
       
  1230 	TestResult(r);
       
  1231 	Compare(_L("\\F32-TST\\TFMAN\\INC109754\\"), _L("\\F32-TST\\TFMAN\\INC109754_C\\"));
       
  1232 	
       
  1233 	// Setting up testing dir
       
  1234 	RmDir(		_L("\\F32-TST\\TFMAN\\INC109754\\"));
       
  1235 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC109754\\SRC\\FILE.TXT"));
       
  1236 	MakeDir(	_L("\\F32-TST\\TFMAN\\INC109754\\TRG\\"));
       
  1237 
       
  1238 	// Test case 2: CFileMan::Rename(_L("C:\\SRC\\*.*"), 	_L("C:\\TRG\\"));
       
  1239 	if (!gAsynch)
       
  1240 		r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\INC109754\\SRC\\*.*"),_L("\\F32-TST\\TFMAN\\INC109754\\TRG\\"));
       
  1241 	else
       
  1242 		r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\INC109754\\SRC\\*.*"),_L("\\F32-TST\\TFMAN\\INC109754\\TRG\\"),0,gStat);
       
  1243 	TestResult(r);
       
  1244 	Compare(_L("\\F32-TST\\TFMAN\\INC109754\\"), _L("\\F32-TST\\TFMAN\\INC109754_C\\"));
       
  1245 	}
       
  1246 
       
  1247 
       
  1248 /*
       
  1249 Test code for INC111038() and executed with Cache enabled and FS_NOT_RUGGED.
       
  1250 */
       
  1251 
       
  1252 LOCAL_C void TestINC111038()
       
  1253 	{
       
  1254 	////////////////////////////////////////////////////////
       
  1255 	////
       
  1256 
       
  1257 	TInt r;
       
  1258 
       
  1259 	test.Next(_L("Example of incorrect attribute flushing"));
       
  1260 	////
       
  1261 	////////////////////////////////////////////////////////
       
  1262 	////
       
  1263 	_LIT(KTestFile, "\\TESTFILE.TXT");
       
  1264 	
       
  1265 	
       
  1266 	////////////////////////////////////////////////////////
       
  1267 	//// 2: Create Test File
       
  1268 	////
       
  1269 	test.Printf(_L("2: Create Test File\n"));
       
  1270 	RFile testFile;
       
  1271 	r = testFile.Create(TheFs, KTestFile, EFileRead | EFileWrite);
       
  1272 	test(r == KErrNone);
       
  1273 
       
  1274 	////////////////////////////////////////////////////////
       
  1275 	//// 3: Populate Data
       
  1276 	////
       
  1277 	test.Printf(_L("\n3: Populate testFile1 Data\n"));
       
  1278 	r = testFile.Write(_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
       
  1279 	test(r == KErrNone);
       
  1280 
       
  1281 
       
  1282 	////////////////////////////////////////////////////////
       
  1283 	//// 4: Get Initial Attributes
       
  1284 	////
       
  1285 	test.Printf(_L("\n4: Get Initial Attributes\n"));
       
  1286 	TUint atts = 0;
       
  1287 	r = testFile.Att(atts);
       
  1288 	test(r == KErrNone);
       
  1289 	test.Printf(_L("\n   Attributes: %08x"), atts);
       
  1290 
       
  1291 	////////////////////////////////////////////////////////
       
  1292 	//// 5: Set KEntryAttHidden Attribute
       
  1293 	////
       
  1294 	test.Printf(_L("\n5: Set KEntryAttHidden Attribute"));
       
  1295 	r = testFile.SetAtt(KEntryAttHidden, 0);
       
  1296 	test(r == KErrNone);
       
  1297 
       
  1298 	
       
  1299 	////////////////////////////////////////////////////////
       
  1300 	//// 6: Verify KEntryAttHidden Attribute is set
       
  1301 	////
       
  1302 	test.Printf(_L("\n6: Verify KEntryAttHidden Attribute is set for testFile1"));
       
  1303 	r = testFile.Att(atts);
       
  1304 	test(r == KErrNone);
       
  1305 	test(atts & KEntryAttHidden);
       
  1306 
       
  1307 
       
  1308   	////////////////////////////////////////////////////////
       
  1309 	//// 7: Read Data from beginning of file
       
  1310 	////
       
  1311 	test.Printf(_L("\n7: Read Data from beginning of file testFile1\n"));
       
  1312 	TBuf8<4> data;
       
  1313 	r = testFile.Read(0, data);
       
  1314 	test(r == KErrNone);
       
  1315 
       
  1316 
       
  1317      ////////////////////////////////////////////////////////
       
  1318 	//// 8: Close file
       
  1319 	////
       
  1320 	test.Printf(_L("\n8: Close all the testFiles"));
       
  1321 	testFile.Close();
       
  1322 	
       
  1323 
       
  1324    	////////////////////////////////////////////////////////
       
  1325 	//// 9: Verify KEntryAttHidden is present
       
  1326 	////
       
  1327 	test.Printf(_L("\n9: Verify KEntryAttHidden is present"));
       
  1328 	r = TheFs.Att(KTestFile, atts);
       
  1329 	test(r == KErrNone);
       
  1330 	test.Printf(_L(" \n Finally, attributes are : %08x"), atts);
       
  1331 	test(atts & KEntryAttHidden);
       
  1332 	
       
  1333 	
       
  1334 	test.Printf(_L("10: Delete Test File"));
       
  1335 	 r = TheFs.Delete(KTestFile);
       
  1336 	test(r == KErrNone || r == KErrNotFound);
       
  1337 
       
  1338 	}
       
  1339 	
       
  1340 LOCAL_C void TestDEF113299()
       
  1341 	{
       
  1342 	test.Next(_L("TestDEF113299"));
       
  1343 	
       
  1344 	TInt err =0;
       
  1345 	TFileName srcFileName = _L("C:\\F32-TST\\TFMAN\\DEF113299\\src\\corner.html");
       
  1346 	TFileName trgFileName = _L("C:\\F32-TST\\TFMAN\\DEF113299\\src\\mi?d**dle.html");
       
  1347 	TFileName trgInvalidFileName = _L("C:\\F32-TST\\TFMAN\\DEF113299\\src\\mi?d**dle>.html"); // Invalid filename
       
  1348 	TFileName renamedFileName = _L("C:\\F32-TST\\TFMAN\\DEF113299\\src\\mirderdle.html");
       
  1349 	
       
  1350 	RmDir(_L("C:\\F32-TST\\TFMAN\\DEF113299\\"));
       
  1351 	MakeFile(srcFileName,_L8("Test Data"));
       
  1352 	if (!gAsynch)
       
  1353 		err = gFileMan->Rename(srcFileName,trgInvalidFileName);
       
  1354 	else
       
  1355 		err = gFileMan->Rename(srcFileName,trgInvalidFileName, 0, gStat);
       
  1356 	TestResult(err,KErrBadName);
       
  1357 		
       
  1358 	if(!gAsynch)
       
  1359 		err = gFileMan->Rename(srcFileName,trgFileName);
       
  1360 	else
       
  1361 		err = gFileMan->Rename(srcFileName,trgFileName, 0, gStat);
       
  1362 	TestResult(err,KErrNone);
       
  1363 		
       
  1364 	CheckFileExists(renamedFileName,KErrNone,ETrue);
       
  1365 	}
       
  1366 	
       
  1367 LOCAL_C void TestRename()
       
  1368 //
       
  1369 // Test rename with wildcards
       
  1370 //
       
  1371 	{
       
  1372 
       
  1373 	test.Next(_L("Rename with wildcards"));
       
  1374 	RmDir(_L("\\F32-TST\\TFMAN\\rename\\dest\\"));
       
  1375 	
       
  1376 	MakeDir(_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\"));
       
  1377 	MakeDir(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\DirTest\\"));
       
  1378 	MakeFile(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\abcDEF.TXT"));
       
  1379 	MakeFile(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\abxx.TXT"));
       
  1380 	MakeFile(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\HELLO.SPG"));
       
  1381 	MakeFile(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\SHEET1.SPR"));
       
  1382 	MakeFile(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\DirTest.TXT\\Unchanged.txt"));
       
  1383 
       
  1384 	TInt r;
       
  1385 
       
  1386 	if (testingInvalidPathLengths)
       
  1387 //	Create a path of greater 256 characters by renaming a directory and check it can be
       
  1388 //	manipulated (tests fix to F32)		
       
  1389 		{
       
  1390 		MakeDir(_L("\\LONGNAME\\"));
       
  1391 		MakeDir(_L("\\LONGNAME\\DIRECTORY1DIRECTORY2DIRECTORY3DIRECTORY4\\"));
       
  1392 		MakeFile(_L("\\LONGNAME\\ELEPHANT01ELEPHANT02ELEPHANT03ELEPHANT04.txt"));
       
  1393 		MakeFile(_L("\\LONGNAME\\DINOSAUR01DINOSAUR02DINOSAUR03DINOSAUR04.txt"));
       
  1394 		MakeFile(_L("\\LONGNAME\\FILEFILE01FILEFILE02FILEFILE03FILEFILE04.bin"));
       
  1395 		r=gFileMan->Rename(_L("\\LONGNAME"),_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff"),CFileMan::EOverWrite);
       
  1396 		test(r==KErrNone);
       
  1397 
       
  1398 	//	Two long directory names - makes paths invalid
       
  1399 		MakeDir(_L("\\TEST\\LONG\\NAME\\FGHIJ"));
       
  1400 		MakeDir(_L("\\TEST\\LONG\\NAME\\FGHIJ\\DIRECTORY1DIRECTORY2DIRECTORY3DIRECTORY4\\"));
       
  1401 		MakeFile(_L("\\TEST\\LONG\\NAME\\FGHIJ\\ELEPHANT01ELEPHANT02ELEPHANT03ELEPHANT.txt"));
       
  1402 		MakeFile(_L("\\TEST\\LONG\\NAME\\FGHIJ\\FILEFILE01FILEFILE02FILEFILE03FILEFILE.txt"));
       
  1403 		r=gFileMan->Rename(_L("\\TEST\\LONG"),_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds"),CFileMan::EOverWrite);
       
  1404 		test(r==KErrNone);
       
  1405 		}
       
  1406 
       
  1407 	//testing invalid source path at the beginning:
       
  1408 	if (!gAsynch)
       
  1409 		{
       
  1410 		r=gFileMan->Rename(_L("::C\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite);
       
  1411 		}
       
  1412 	else
       
  1413 		{
       
  1414 		r=gFileMan->Rename(_L("::C\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite,gStat);
       
  1415 		}
       
  1416 		TestResult(r,KErrBadName,KErrBadName);
       
  1417 		
       
  1418 	//testing invalid target path at the beginning:  
       
  1419 		
       
  1420 	if (!gAsynch)
       
  1421 		{
       
  1422 		r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("::C\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite);
       
  1423 		}
       
  1424 	else
       
  1425 		{
       
  1426 		r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("::C\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite,gStat);
       
  1427 		}
       
  1428 		TestResult(r,KErrBadName,KErrBadName);
       
  1429 	
       
  1430 	//testing invalid source path at the middle:	
       
  1431 	if (!gAsynch)
       
  1432 		{
       
  1433 		r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\:RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite);
       
  1434 		}
       
  1435 	else
       
  1436 		{
       
  1437 		r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\:RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite,gStat);
       
  1438 		}
       
  1439 		TestResult(r,KErrBadName,KErrNone);
       
  1440 	
       
  1441 	//testing invalid target path at the middle:	
       
  1442 	if (!gAsynch)
       
  1443 		{
       
  1444 		r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\:RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite);
       
  1445 		}
       
  1446 	else
       
  1447 		{
       
  1448 		r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\:RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite,gStat);
       
  1449 		}
       
  1450 		TestResult(r,KErrBadName,KErrNone);
       
  1451 
       
  1452 		//testing invalid source path at the end:	
       
  1453 	if (!gAsynch)
       
  1454 		{
       
  1455 		r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\:*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite);
       
  1456 		}
       
  1457 	else
       
  1458 		{
       
  1459 		r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\:*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite,gStat);
       
  1460 		}
       
  1461 		TestResult(r,KErrBadName,KErrNone);	
       
  1462 	
       
  1463 	//testing invalid target path at the end:	
       
  1464 	if (!gAsynch)
       
  1465 		{
       
  1466 		r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\:*.DDB"),CFileMan::EOverWrite);
       
  1467 		}
       
  1468 	else
       
  1469 		{
       
  1470 		r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\:*.DDB"),CFileMan::EOverWrite,gStat);
       
  1471 		}
       
  1472 		TestResult(r,KErrBadName,KErrNone);
       
  1473 	
       
  1474 	if (!gAsynch)
       
  1475 		{
       
  1476 		r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite);
       
  1477 		test(r==KErrNone);
       
  1478 		if (testingInvalidPathLengths)
       
  1479 			{
       
  1480 			r=gFileMan->Rename(_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\elephant01elephant02elephant03elephant04.txt"),_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\elephant01elephant02elephant03elephant04.bin"));
       
  1481 			test(r==KErrBadName);
       
  1482 			r=gFileMan->Rename(_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff"),_L("\\Shortened"),CFileMan::EOverWrite);
       
  1483 			test(r==KErrNone);
       
  1484 			r=gFileMan->Rename(_L("\\Shortened\\*.txt"),_L("\\Shortened\\*.cat"));
       
  1485 			test(r==KErrNone);
       
  1486 			r=gFileMan->RmDir(_L("\\Shortened\\"));
       
  1487 			test(r==KErrNone);
       
  1488 
       
  1489 			r=gFileMan->Rename(_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds"),_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\NotSoShortened"),CFileMan::EOverWrite);
       
  1490 			test(r==KErrNone);
       
  1491 			r=gFileMan->Rename(_L("\\TEST"),_L("\\OXO!"));
       
  1492 			test(r==KErrNone);
       
  1493 			r=gFileMan->Rename(_L("\\OXO!\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as"),_L("\\OXO!\\Shorter"));
       
  1494 			test(r==KErrNone);
       
  1495 			r=gFileMan->Rename(_L("\\OXO!\\Shorter\\NotSoShortened\\NAME\\FGHIJ\\*.txt"),_L("\\TEST\\Shorter\\NotSoShortened\\NAME\\FGHIJ\\*.cat"));
       
  1496 			test(r==KErrNone);
       
  1497 			r=gFileMan->RmDir(_L("\\OXO!\\"));
       
  1498 			test(r==KErrNone);
       
  1499 
       
  1500 			}
       
  1501 		}
       
  1502 	else
       
  1503 		{
       
  1504 		r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite,gStat);
       
  1505 		WaitForSuccess();
       
  1506 		if (testingInvalidPathLengths)
       
  1507 			{
       
  1508 			r=gFileMan->Rename(_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\elephant01elephant02elephant03elephant04.txt"),_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\elephant01elephant02elephant03elephant04.bin"));
       
  1509 			test(r==KErrBadName);
       
  1510 			r=gFileMan->Rename(_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff"),_L("\\Shortened"),CFileMan::EOverWrite,gStat);
       
  1511 			WaitForSuccess();
       
  1512 			r=gFileMan->Rename(_L("\\Shortened\\*.txt"),_L("\\Shortened\\*.bin"),0,gStat);
       
  1513 			WaitForSuccess();
       
  1514 			r=gFileMan->RmDir(_L("\\Shortened\\"),gStat);
       
  1515 			WaitForSuccess();
       
  1516 
       
  1517 			r=gFileMan->Rename(_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds"),_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\NotSoShortened"),CFileMan::EOverWrite,gStat);
       
  1518 			WaitForSuccess();
       
  1519 			test(r==KErrNone);
       
  1520 			r=gFileMan->Rename(_L("\\TEST"),_L("\\OXO!"),CFileMan::EOverWrite,gStat);
       
  1521 			WaitForSuccess();
       
  1522 			test(r==KErrNone);
       
  1523 			r=gFileMan->Rename(_L("\\OXO!\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as"),_L("\\OXO!\\Shorter"),CFileMan::EOverWrite,gStat);
       
  1524 			WaitForSuccess();
       
  1525 			test(r==KErrNone);
       
  1526 			r=gFileMan->Rename(_L("\\OXO!\\Shorter\\NotSoShortened\\NAME\\FGHIJ\\*.txt"),_L("\\TEST\\Shorter\\NotSoShortened\\NAME\\FGHIJ\\*.cat"),CFileMan::EOverWrite,gStat);
       
  1527 			WaitForSuccess();
       
  1528 			test(r==KErrNone);
       
  1529 			r=gFileMan->RmDir(_L("\\OXO!\\"));
       
  1530 			test(r==KErrNone);
       
  1531 			r=gFileMan->RmDir(_L("\\TEST\\"));
       
  1532 			test(r==KErrNone);
       
  1533 			}
       
  1534 		}
       
  1535 	RmDir(_L("\\F32-TST\\TFMAN\\after\\"));
       
  1536 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\abcDEF.DDB"));
       
  1537 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\abxx.DDB"));
       
  1538 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\DirTest.DDB\\Unchanged.txt"));
       
  1539 	Compare(_L("\\F32-TST\\TFMAN\\AFTER\\*"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*"));
       
  1540 
       
  1541 	RmDir(_L("\\F32-TST\\TFMAN\\after\\"));
       
  1542 	MakeDir(_L("\\F32-TST\\TFMAN\\AFTER\\DirTest\\"));
       
  1543 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\HELLO.SPG"));
       
  1544 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\SHEET1.SPR"));
       
  1545 	Compare(_L("\\F32-TST\\TFMAN\\AFTER\\*"),_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*"));
       
  1546 
       
  1547 	if (!gAsynch)
       
  1548 		r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.TXT"));
       
  1549 	else
       
  1550 		r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.TXT"),0,gStat);
       
  1551 	TestResult(r);
       
  1552 
       
  1553 	RmDir(_L("\\F32-TST\\TFMAN\\after\\"));
       
  1554 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\abcDEF.TXT"));
       
  1555 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\abxx.TXT"));
       
  1556 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\DirTest.TXT\\Unchanged.txt"));
       
  1557 	Compare(_L("\\F32-TST\\TFMAN\\AFTER\\*"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*"));
       
  1558 
       
  1559 	test.Next(_L("Test rename case of filenames"));
       
  1560 	MakeFile(_L("\\F32-TST\\TFMAN\\CASETEST\\FileName1"));
       
  1561 
       
  1562 	if (!gAsynch)
       
  1563 		r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\CASETEST\\FileName1"),_L("\\F32-TST\\TFMAN\\CASETEST\\FILENAME1"));
       
  1564 	else
       
  1565 		r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\CASETEST\\FileName1"),_L("\\F32-TST\\TFMAN\\CASETEST\\FILENAME1"),0,gStat);
       
  1566 	TestResult(r);
       
  1567 	CheckFileExists(_L("\\F32-TST\\TFMAN\\CASETEST\\FileName1"),KErrNone,EFalse);
       
  1568 	CheckFileExists(_L("\\F32-TST\\TFMAN\\CASETEST\\FILENAME1"),KErrNone,ETrue);
       
  1569 
       
  1570 	if (!gAsynch)
       
  1571 		r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\CASETEST\\FILENAME1"),_L("\\F32-TST\\TFMAN\\CASETEST\\FILENAME1"),CFileMan::EOverWrite);
       
  1572 	else
       
  1573 		r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\CASETEST\\FILENAME1"),_L("\\F32-TST\\TFMAN\\CASETEST\\FILENAME1"),CFileMan::EOverWrite,gStat);
       
  1574 	TestResult(r);
       
  1575 	CheckFileExists(_L("\\F32-TST\\TFMAN\\CASETEST\\FILENAME1"),KErrNone,ETrue);
       
  1576 
       
  1577 	// Test behaviour for omitted parameters
       
  1578 	// For this, default should be session path
       
  1579 	TFileName sessionPath;
       
  1580 	TInt err=TheFs.SessionPath(sessionPath);
       
  1581 	test(err==KErrNone);
       
  1582 
       
  1583 	SetupDirectories(ETrue, NULL);
       
  1584 	err=TheFs.SetSessionPath(_L("\\F32-TST\\TFMAN\\dest\\"));
       
  1585 	test(err == KErrNone);
       
  1586 
       
  1587 	err = gFileMan->Rename(_L("\\F32-TST\\TFMAN\\source"), _L(""));
       
  1588 	test(err == KErrNone);
       
  1589 	Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), _L("\\F32-TST\\TFMAN\\dest\\source\\*"));
       
  1590 
       
  1591 	RmDir(_L("\\F32-TST\\TFMAN\\dest\\"));
       
  1592 	RmDir(_L("\\F32-TST\\TFMAN\\source\\"));
       
  1593 	SetupDirectories(ETrue, NULL);
       
  1594 	err=TheFs.SetSessionPath(_L("\\F32-TST\\TFMAN\\source\\"));
       
  1595 	test(err == KErrNone);
       
  1596 
       
  1597 	err = gFileMan->Rename(_L(""), _L("\\F32-TST\\TFMAN\\dest\\"));
       
  1598 	test(err == KErrNone);
       
  1599 	Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), _L("\\F32-TST\\TFMAN\\dest\\*"));
       
  1600 		
       
  1601 	err=TheFs.SetSessionPath(sessionPath);
       
  1602 	test(err==KErrNone);
       
  1603 	
       
  1604 	TestINC109754();
       
  1605 	TestDEF092084();
       
  1606 	TestDEF113299();
       
  1607 	}
       
  1608 
       
  1609 LOCAL_C void TestAttribs()
       
  1610 //
       
  1611 // Test attribs
       
  1612 //
       
  1613 	{
       
  1614 
       
  1615 	test.Next(_L("Set file attributes"));
       
  1616 	MakeFile(_L("\\F32-TST\\TFMAN\\ATTRIBS\\Attrib1.AT"));
       
  1617 	MakeFile(_L("\\F32-TST\\TFMAN\\ATTRIBS\\Attrib2.at"));
       
  1618 
       
  1619 	TUint legalAttMask=KEntryAttMaskSupported&~(KEntryAttDir|KEntryAttVolume);
       
  1620 	TUint setMask=KEntryAttReadOnly;
       
  1621 	TUint clearMask=KEntryAttHidden|KEntryAttArchive;
       
  1622 	if (!gAsynch)
       
  1623 		{
       
  1624 		TInt r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\ATTRIBS\\AT*.AT"),setMask,clearMask,TTime(0));
       
  1625 		test(r==KErrNone);
       
  1626 		}
       
  1627 	else
       
  1628 		{
       
  1629 		TInt r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\ATTRIBS\\AT*.AT"),setMask,clearMask,TTime(0),0,gStat);
       
  1630 		test(r==KErrNone);
       
  1631 		WaitForSuccess();
       
  1632 		}
       
  1633 	
       
  1634 	CDirScan* scan=CDirScan::NewL(TheFs);
       
  1635 	scan->SetScanDataL(_L("\\F32-TST\\TFMAN\\ATTRIBS\\*"),KEntryAttMaskSupported,ESortByName);
       
  1636 	CDir* entryList;
       
  1637 	scan->NextL(entryList);
       
  1638 	TInt count=entryList->Count();
       
  1639 	test(count==2);
       
  1640 	TEntry entry=(*entryList)[0];
       
  1641 	test(entry.iName.MatchF(_L("attrib1.AT"))!=KErrNotFound);
       
  1642 	test(entry.iAtt==KEntryAttReadOnly);
       
  1643 	entry=(*entryList)[1];
       
  1644 	test(entry.iName.MatchF(_L("attrib2.AT"))!=KErrNotFound);
       
  1645 	test(entry.iAtt==KEntryAttReadOnly);
       
  1646 	delete entryList;
       
  1647 
       
  1648 	TDateTime dateTime(1990,ENovember,20,9,5,0,0);
       
  1649 	TTime time(dateTime); // FAT loses microseconds if try to convert HomeTime()
       
  1650 
       
  1651 	if (!gAsynch)
       
  1652 		{
       
  1653 		TInt r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\ATTRIBS\\AT*.AT"),0,legalAttMask,time);
       
  1654 		test(r==KErrNone);
       
  1655 		}
       
  1656 	else
       
  1657 		{
       
  1658 		TInt r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\ATTRIBS\\AT*.AT"),0,legalAttMask,time,0,gStat);
       
  1659 		test(r==KErrNone);
       
  1660 		WaitForSuccess();
       
  1661 		}
       
  1662 	
       
  1663 	scan->SetScanDataL(_L("\\F32-TST\\TFMAN\\ATTRIBS\\*"),KEntryAttMaskSupported,ESortByName);
       
  1664 	scan->NextL(entryList);
       
  1665 	count=entryList->Count();
       
  1666 	test(count==2);
       
  1667 	entry=(*entryList)[0];
       
  1668 	test(entry.iName.MatchF(_L("attrib1.AT"))!=KErrNotFound);
       
  1669 	test(entry.iAtt==0);
       
  1670 	TDateTime dt=(entry.iModified).DateTime();
       
  1671 	test(dt.Year()==dateTime.Year());
       
  1672 	test(dt.Month()==dateTime.Month());
       
  1673 	test(dt.Day()==dateTime.Day());
       
  1674 	test(dt.Hour()==dateTime.Hour());
       
  1675 	test(dt.Minute()==dateTime.Minute());
       
  1676 	test(dt.Second()==dateTime.Second());
       
  1677 	test(entry.iModified==time);
       
  1678 	entry=(*entryList)[1];
       
  1679 	test(entry.iName.MatchF(_L("attrib2.AT"))!=KErrNotFound);
       
  1680 	test(entry.iAtt==0);
       
  1681 	test(entry.iModified==time);
       
  1682 	delete entryList;
       
  1683 	delete scan;
       
  1684 	TestINC111038();
       
  1685 	}
       
  1686 	
       
  1687 LOCAL_C void  TestINC091841()
       
  1688 	{
       
  1689 	if(gAsynch)  
       
  1690 		{
       
  1691 		return;
       
  1692 		}
       
  1693 
       
  1694 	MakeDir(_L("\\12345678\\Book\\12345678\\"));
       
  1695 	TFileName longname;
       
  1696 	longname.Copy(_L("\\12345678\\Book\\12345678\\12345678901234567890123456789012345678901234567890.x"));
       
  1697 	MakeFile(longname);
       
  1698 	TFileName oldname = longname;
       
  1699 	TInt ret = KErrNone;
       
  1700 	while(ret == KErrNone)
       
  1701 		{
       
  1702 		oldname = longname;
       
  1703 		longname.Append(_L("xxxxx"));
       
  1704 		ret = TheFs.Replace(oldname, longname);
       
  1705 		}
       
  1706 	if(oldname.Length() >= KMaxFileName-5) // if not, it means that we won't be calling ShrinkNames !!
       
  1707 		{
       
  1708 		TInt r = gFileMan->Rename(_L("\\12345678\\Book\\12345678"),_L("\\INC091841\\Book\\012-235-abcd"),0);
       
  1709 		test(r==KErrNone);  
       
  1710 		CDir* dir;
       
  1711 		r = TheFs.GetDir(_L("\\INC091841\\Book\\012-235-abcd\\"), KEntryAttNormal, ESortNone, dir);
       
  1712 		test(r==KErrNone);   
       
  1713 		r = KErrNotFound;
       
  1714 		TInt dirlen = sizeof("\\INC091841\\Book\\012-235-abcd\\");
       
  1715 		for(TInt i=0; r==KErrNotFound && i<dir->Count(); i++)
       
  1716 			{
       
  1717 			if((*dir)[i].iName.Length() + dirlen > oldname.Length())
       
  1718 				{
       
  1719 				r = KErrNone;
       
  1720 				}
       
  1721 			}
       
  1722 		delete dir;
       
  1723 		test(r==KErrNone);  
       
  1724 		r = gFileMan->RmDir(_L("\\INC091841\\"));
       
  1725 		test(r==KErrNone);  
       
  1726 		}
       
  1727 	RmDir(_L("\\12345678\\"));
       
  1728 	}
       
  1729 
       
  1730 LOCAL_C void TestRmDir()
       
  1731 //
       
  1732 // Test rmdir function
       
  1733 //
       
  1734 	{
       
  1735 
       
  1736 	test.Next(_L("Test rmdir function"));
       
  1737 
       
  1738 	MakeDir(_L("\\F32-TST\\TFMAN\\RMDIR\\EMPTY\\"));
       
  1739 	MakeFile(_L("\\F32-TST\\TFMAN\\RMDIR\\ALFRED.txt"));
       
  1740 	MakeFile(_L("\\F32-TST\\TFMAN\\RMDIR\\RICHARD.txt"));
       
  1741 	MakeFile(_L("\\F32-TST\\TFMAN\\RMDIR\\RMSUBDIR1\\RMSUBSUBDIR\\CHARLES.txt"));
       
  1742 	MakeFile(_L("\\F32-TST\\TFMAN\\RMDIR\\RMSUBDIR2\\EDMUND.txt"));
       
  1743 	MakeDir(_L("\\F32-TST\\TFMAN\\TESTDIR\\"));
       
  1744 	MakeFile(_L("\\F32-TST\\TFMAN\\TESTDIR\\DEF123044.txt"));
       
  1745 	
       
  1746 	TInt r;
       
  1747 	
       
  1748 	if (testingInvalidPathLengths)
       
  1749 //	Create a path of greater 256 characters by renaming a directory and check it can be
       
  1750 //	manipulated (tests fix to F32)		
       
  1751 		{
       
  1752 		MakeDir(_L("\\LONGNAMETEST\\"));
       
  1753 		MakeDir(_L("\\LONGNAMETEST\\DIRECTORY1DIRECTORY2DIRECTORY3DIRECTORY4\\"));
       
  1754 		MakeFile(_L("\\LONGNAMETEST\\ELEPHANT01ELEPHANT02ELEPHANT03ELEPHANT04"));
       
  1755 		MakeFile(_L("\\LONGNAMETEST\\FILEFILE01FILEFILE02FILEFILE03FILEFILE04"));
       
  1756 		r=gFileMan->Rename(_L("\\LONGNAMETEST"),_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff"),CFileMan::EOverWrite);
       
  1757 		test(r==KErrNone);
       
  1758 		}
       
  1759 
       
  1760 	//testing invalid source path at the beginning:
       
  1761 	if (!gAsynch)
       
  1762 		{
       
  1763 		r=gFileMan->RmDir(_L(":C:\\F32-TST\\TFMAN\\RMDIR\\*.AT"));
       
  1764 		}
       
  1765 	else
       
  1766 		{
       
  1767 		r=gFileMan->RmDir(_L(":C:\\F32-TST\\TFMAN\\RMDIR\\*.AT"),gStat);
       
  1768 		}
       
  1769 	TestResult(r,KErrBadName,KErrBadName);
       
  1770 	
       
  1771 	//testing invalid source path at the middle:	
       
  1772 	if (!gAsynch)
       
  1773 		{
       
  1774 		r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\:RMDIR\\*.AT"));
       
  1775 		}
       
  1776 	else
       
  1777 		{
       
  1778 		r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\:RMDIR\\*.AT"),gStat);
       
  1779 		}
       
  1780 	TestResult(r,KErrBadName,KErrNone);
       
  1781 
       
  1782 	//testing invalid source path at the end:	
       
  1783 	if (!gAsynch)
       
  1784 		{
       
  1785 		r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\TESTDIR\\:DEF.txt"));
       
  1786 		}
       
  1787 	else
       
  1788 		{
       
  1789 		r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\TESTDIR\\:DEF.txt"),gStat);
       
  1790 		}
       
  1791 	TestResult(r,KErrNone,KErrNone);
       
  1792 	
       
  1793 	if (!gAsynch)
       
  1794 		{
       
  1795 		r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\RMDIR\\*.AT"));
       
  1796 		test(r==KErrNone);
       
  1797 			if (testingInvalidPathLengths)
       
  1798 			{
       
  1799 			r=gFileMan->RmDir(_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\"));
       
  1800 			test(r==KErrNone);
       
  1801 			}
       
  1802 		}
       
  1803 	else
       
  1804 		{
       
  1805 		r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\RMDIR\\*.AT"),gStat);
       
  1806 		test(r==KErrNone);
       
  1807 		WaitForSuccess();
       
  1808 		if (testingInvalidPathLengths)
       
  1809 			{
       
  1810 			r=gFileMan->RmDir(_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\"),gStat);
       
  1811 			test(r==KErrNone);
       
  1812 			WaitForSuccess();
       
  1813 			}
       
  1814 
       
  1815 		}
       
  1816 
       
  1817 	TEntry entry;
       
  1818 	r=TheFs.Entry(_L("\\F32-TST\\TFMAN\\RMDIR"),entry);
       
  1819 	test(r==KErrNotFound);
       
  1820 
       
  1821 	MakeDir(_L("\\F32-TST\\TFMAN\\READONLY\\"));
       
  1822 	r=TheFs.SetAtt(_L("\\F32-TST\\TFMAN\\READONLY\\"),KEntryAttReadOnly,0);
       
  1823 	test(r==KErrNone);
       
  1824 
       
  1825 	if (!gAsynch)
       
  1826 		{
       
  1827 		r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\READONLY\\"));
       
  1828 		test(r==KErrAccessDenied);
       
  1829 		}
       
  1830 	else
       
  1831 		{
       
  1832 		r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\READONLY\\"),gStat);
       
  1833 		test(r==KErrNone);
       
  1834 		WaitForResult(KErrAccessDenied);
       
  1835 		}
       
  1836 
       
  1837 	r=TheFs.SetAtt(_L("\\F32-TST\\TFMAN\\READONLY\\"),0,KEntryAttReadOnly);
       
  1838 	test(r==KErrNone);
       
  1839 
       
  1840 	r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\READONLY\\"));
       
  1841 	test(r==KErrNone);
       
  1842 	
       
  1843 	// Test behaviour for omitted parameters
       
  1844 	// For this, default should be session path
       
  1845 	TFileName sessionPath;
       
  1846 	r=TheFs.SessionPath(sessionPath);
       
  1847 	test(r==KErrNone);
       
  1848 
       
  1849 	SetupDirectories(ETrue, NULL);
       
  1850 	r=TheFs.SetSessionPath(_L("\\F32-TST\\TFMAN\\source\\"));
       
  1851 
       
  1852 	// Default removal of session path
       
  1853 	r=gFileMan->RmDir(_L(""));
       
  1854 	test(r==KErrNone);
       
  1855 
       
  1856 	r=TheFs.SetSessionPath(sessionPath);
       
  1857 	
       
  1858 	r = gFileMan->Rename(_L("\\F32-TST\\TFMAN\\source\\subdir"), _L("\\F32-TST\\TFMAN\\source\\tofail"), CFileMan::ERecurse);
       
  1859 	test(r == KErrPathNotFound);
       
  1860 	
       
  1861 	r = gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\"));
       
  1862 	test(r==KErrNone);
       
  1863 	MakeDir(_L("\\F32-TST\\TFMAN\\"));
       
  1864 	
       
  1865 	if(testingInvalidPathLengths)
       
  1866 		{
       
  1867 		TestINC091841();
       
  1868 		}
       
  1869 
       
  1870 	//--------------------------------------------- 
       
  1871 	//! @SYMTestCaseID			PBASE-T_FMAN-0316
       
  1872 	//! @SYMTestType			UT 
       
  1873 	//! @SYMREQ					DEF099820
       
  1874 	//! @SYMTestCaseDesc		Test that CFileMan::RmDir() works when deleting a directory containing open files.
       
  1875 	//! @SYMTestActions			Open a file within a directory and try to remove the directory.
       
  1876 	//! @SYMTestExpectedResults	The operation completes with the error code KErrInUse.
       
  1877 	//! @SYMTestPriority		High
       
  1878 	//! @SYMTestStatus			Implemented 
       
  1879 	//--------------------------------------------- 	
       
  1880 
       
  1881 	gFileMan->SetObserver(NULL);
       
  1882 
       
  1883 	MakeDir(_L("\\F32-TST\\TFMAN\\OPENFILE\\"));
       
  1884 	MakeFile(_L("\\F32-TST\\TFMAN\\OPENFILE\\FILE.TXT"));
       
  1885 
       
  1886 	RFile file;
       
  1887 	r = file.Open(TheFs,_L("\\F32-TST\\TFMAN\\OPENFILE\\FILE.TXT"), EFileRead | EFileShareExclusive);
       
  1888 	test(r==KErrNone);
       
  1889 
       
  1890 	if (!gAsynch)
       
  1891 		{
       
  1892 		r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\OPENFILE\\"));
       
  1893 		test(r==KErrInUse);
       
  1894 		
       
  1895 		file.Close();
       
  1896 		
       
  1897 		r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\OPENFILE\\"));
       
  1898 		test(r==KErrNone);
       
  1899 		}
       
  1900 	else
       
  1901 		{
       
  1902 		r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\OPENFILE\\"), gStat);
       
  1903 		test(r==KErrNone);
       
  1904 		WaitForResult(KErrInUse);
       
  1905 
       
  1906 		file.Close();
       
  1907 
       
  1908 		r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\OPENFILE\\"), gStat);
       
  1909 		test(r==KErrNone);
       
  1910 		WaitForResult(KErrNone);
       
  1911 		}
       
  1912 
       
  1913 	gFileMan->SetObserver(gObserver);
       
  1914 	}
       
  1915 
       
  1916 LOCAL_C void TestRecursiveCopy()
       
  1917 //
       
  1918 // Test the recursive copy function
       
  1919 //
       
  1920 	{
       
  1921 
       
  1922 	test.Next(_L("Test recursive copy"));
       
  1923 	RmDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
       
  1924 
       
  1925 	MakeDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
       
  1926 	MakeDir(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EMPTY\\"));
       
  1927 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"));
       
  1928 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE2.TXT"));
       
  1929 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE3.TXT"));
       
  1930 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\FILE4.TXT"));
       
  1931 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EXE1.BIN"));
       
  1932 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\EXE2.BIN"));
       
  1933 
       
  1934 	TInt r;
       
  1935 	if (!gAsynch)
       
  1936 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\"),_L("\\F32-TST\\TFMAN\\COPYDIR"),CFileMan::ERecurse);
       
  1937 	else
       
  1938 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\"),_L("\\F32-TST\\TFMAN\\COPYDIR"),CFileMan::ERecurse,gStat);
       
  1939 	TestResult(r);
       
  1940 
       
  1941 	Compare(_L("\\F32-TST\\TFMAN\\DELDIR\\*"),_L("\\F32-TST\\TFMAN\\COPYDIR\\*"));
       
  1942 	RmDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
       
  1943 	MakeDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
       
  1944 
       
  1945 	if (!gAsynch)
       
  1946 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\*.BIN"),_L("\\F32-TST\\TFMAN\\COPYDIR\\*.EXT"),CFileMan::ERecurse);
       
  1947 	else
       
  1948 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\*.BIN"),_L("\\F32-TST\\TFMAN\\COPYDIR\\*.EXT"),CFileMan::ERecurse,gStat);
       
  1949 	TestResult(KErrNone);
       
  1950 
       
  1951 	RmDir(_L("\\F32-TST\\TFMAN\\after\\"));
       
  1952 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\DELTEST\\EXE1.EXT"));
       
  1953 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\EXE2.EXT"));
       
  1954 	Compare(_L("\\F32-TST\\TFMAN\\AFTER\\*"),_L("\\F32-TST\\TFMAN\\COPYDIR\\*"));
       
  1955 
       
  1956 	// Test behaviour for omitted parameters
       
  1957 	// For this, default should be session path
       
  1958 	TFileName sessionPath;
       
  1959 	r=TheFs.SessionPath(sessionPath);
       
  1960 	test(r==KErrNone);
       
  1961 
       
  1962 	RmDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
       
  1963 	MakeDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
       
  1964 	r=TheFs.SetSessionPath(_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
       
  1965 
       
  1966 	// Default copy to session path
       
  1967 	if (!gAsynch)
       
  1968 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\"),_L(""),CFileMan::ERecurse);
       
  1969 	else
       
  1970 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\"),_L(""),CFileMan::ERecurse,gStat);
       
  1971 	TestResult(KErrNone);
       
  1972 	Compare(_L("\\F32-TST\\TFMAN\\DELDIR\\*"),_L("\\F32-TST\\TFMAN\\COPYDIR\\*"));
       
  1973 
       
  1974 	RmDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
       
  1975 	MakeDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
       
  1976 	r=TheFs.SetSessionPath(_L("\\F32-TST\\TFMAN\\DELDIR\\"));
       
  1977 
       
  1978 	// Default copy from session path
       
  1979 	if (!gAsynch)
       
  1980 		r=gFileMan->Copy(_L(""),_L("\\F32-TST\\TFMAN\\COPYDIR\\"),CFileMan::ERecurse);
       
  1981 	else
       
  1982 		r=gFileMan->Copy(_L(""),_L("\\F32-TST\\TFMAN\\COPYDIR\\"),CFileMan::ERecurse,gStat);
       
  1983 	TestResult(KErrNone);
       
  1984 	Compare(_L("\\F32-TST\\TFMAN\\DELDIR\\*"),_L("\\F32-TST\\TFMAN\\COPYDIR\\*"));
       
  1985 
       
  1986 	RmDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
       
  1987 	RmDir(_L("\\F32-TST\\TFMAN\\DELDIR\\"));
       
  1988 	r=TheFs.SetSessionPath(sessionPath);
       
  1989 	test(r==KErrNone);
       
  1990 	}
       
  1991 	
       
  1992 LOCAL_C void TestRecursiveAttribs()
       
  1993 //
       
  1994 // Test set attribs recursively
       
  1995 //
       
  1996 	{
       
  1997 
       
  1998 	test.Next(_L("Test recursive attribs"));
       
  1999 	MakeFile(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\Attrib1.AT"));
       
  2000 	MakeFile(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\Attrib2.at"));
       
  2001 	MakeFile(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\SUBDIR\\ATFILE.TXT"));
       
  2002 
       
  2003 	if (!gAsynch)
       
  2004 		{
       
  2005 		TInt r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\"),KEntryAttReadOnly,0,TTime(0),CFileMan::ERecurse);
       
  2006 		test(r==KErrNone);
       
  2007 		}
       
  2008 	else
       
  2009 		{
       
  2010 		TInt r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\"),KEntryAttReadOnly,0,TTime(0),CFileMan::ERecurse,gStat);
       
  2011 		test(r==KErrNone);
       
  2012 		WaitForSuccess();
       
  2013 		}
       
  2014 
       
  2015 	CDir* entryList;
       
  2016 	CDirScan* scan=CDirScan::NewL(TheFs);
       
  2017 	scan->SetScanDataL(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\*"),KEntryAttMaskSupported,ESortByName);
       
  2018 	scan->NextL(entryList);
       
  2019 	TInt count=entryList->Count();
       
  2020 	test(count==3);
       
  2021 	TEntry entry=(*entryList)[0];
       
  2022 	test(entry.iName.MatchF(_L("ATTRIB1.AT"))!=KErrNotFound);
       
  2023 	if (!IsTestingLFFS())
       
  2024 		test(entry.iAtt==(KEntryAttReadOnly|KEntryAttArchive));
       
  2025 	else
       
  2026 		test(entry.iAtt&KEntryAttReadOnly); // ???
       
  2027 	entry=(*entryList)[1];
       
  2028 	test(entry.iName.MatchF(_L("ATTRIB2.AT"))!=KErrNotFound);
       
  2029 	if (!IsTestingLFFS())
       
  2030 		test(entry.iAtt==(KEntryAttReadOnly|KEntryAttArchive));
       
  2031 	else
       
  2032 		test(entry.iAtt&KEntryAttReadOnly); // ???
       
  2033 	entry=(*entryList)[2];
       
  2034 	test(entry.iName.MatchF(_L("SUBDIR"))!=KErrNotFound);
       
  2035 	delete entryList;
       
  2036 
       
  2037 	scan->NextL(entryList);
       
  2038 	count=entryList->Count();
       
  2039 	test(count==1);
       
  2040 	entry=(*entryList)[0];
       
  2041 	test(entry.iName.MatchF(_L("ATFILE.TXT"))!=KErrNotFound);
       
  2042 	if (!IsTestingLFFS())
       
  2043 		test(entry.iAtt==(KEntryAttReadOnly|KEntryAttArchive));
       
  2044 	else
       
  2045 		test(entry.iAtt&KEntryAttReadOnly); // ???
       
  2046 	delete entryList;
       
  2047 
       
  2048 	scan->NextL(entryList);
       
  2049 	test(entryList==NULL);
       
  2050 
       
  2051 	if (!gAsynch)
       
  2052 		{
       
  2053 		TInt r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\"),0,KEntryAttReadOnly|KEntryAttArchive,TTime(0),CFileMan::ERecurse);
       
  2054 		test(r==KErrNone);
       
  2055 		}
       
  2056 	else
       
  2057 		{
       
  2058 		TInt r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\"),0,KEntryAttReadOnly|KEntryAttArchive,TTime(0),CFileMan::ERecurse,gStat);
       
  2059 		test(r==KErrNone);
       
  2060 		WaitForSuccess();
       
  2061 		}
       
  2062 
       
  2063 	scan->SetScanDataL(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\*"),KEntryAttMaskSupported,ESortByName);
       
  2064 	scan->NextL(entryList);
       
  2065 	count=entryList->Count();
       
  2066 	test(count==3);
       
  2067 	entry=(*entryList)[0];
       
  2068 	test(entry.iName.MatchF(_L("ATTRIB1.AT"))!=KErrNotFound);
       
  2069 	test(entry.iAtt==KEntryAttNormal);
       
  2070 	entry=(*entryList)[1];
       
  2071 	test(entry.iName.MatchF(_L("ATTRIB2.AT"))!=KErrNotFound);
       
  2072 	test(entry.iAtt==KEntryAttNormal);
       
  2073 	entry=(*entryList)[2];
       
  2074 	test(entry.iName.MatchF(_L("SUBDIR"))!=KErrNotFound);
       
  2075 	delete entryList;
       
  2076 
       
  2077 	scan->NextL(entryList);
       
  2078 	count=entryList->Count();
       
  2079 	test(count==1);
       
  2080 	entry=(*entryList)[0];
       
  2081 	test(entry.iName.MatchF(_L("ATFILE.TXT"))!=KErrNotFound);
       
  2082 	test(entry.iAtt==KEntryAttNormal);
       
  2083 	delete entryList;
       
  2084 
       
  2085 	scan->NextL(entryList);
       
  2086 	test(entryList==NULL);
       
  2087 	delete scan;
       
  2088 	}
       
  2089 
       
  2090 LOCAL_C void TestRecursiveDelete()
       
  2091 //
       
  2092 // Test Recursive delete
       
  2093 //
       
  2094 	{
       
  2095 
       
  2096 	test.Next(_L("Test recursive delete"));
       
  2097 	MakeFile(_L("\\F32-TST\\TFMAN\\RECDELETE\\FULL\\GRAPE.TXT"));
       
  2098 	MakeFile(_L("\\F32-TST\\TFMAN\\RECDELETE\\FULL\\GRAPE.PLP"));
       
  2099 	MakeFile(_L("\\F32-TST\\TFMAN\\RECDELETE\\GRAPE.PLP"));
       
  2100 	MakeFile(_L("\\F32-TST\\TFMAN\\RECDELETE\\FILE1.TXT"));
       
  2101 
       
  2102 	if (!gAsynch)
       
  2103 		{
       
  2104 		TInt r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\RECDELETE\\*.PLP"),CFileMan::ERecurse);
       
  2105 		test(r==KErrNone);
       
  2106 		}
       
  2107 	else
       
  2108 		{
       
  2109 		TInt r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\RECDELETE\\*.PLP"),CFileMan::ERecurse,gStat);
       
  2110 		test(r==KErrNone);
       
  2111 		WaitForSuccess();
       
  2112 		}
       
  2113 
       
  2114 	RmDir(_L("\\F32-TST\\TFMAN\\after\\"));
       
  2115 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FULL\\GRAPE.TXT"));
       
  2116 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FILE1.TXT"));
       
  2117 	Compare(_L("\\F32-TST\\TFMAN\\after\\*"),_L("\\F32-TST\\TFMAN\\RecDelete\\*"));
       
  2118 	}
       
  2119 
       
  2120 LOCAL_C void TestINC108401()
       
  2121   {
       
  2122    	
       
  2123    	test.Next(_L("Test INC108401 : starts"));
       
  2124    	TInt err = 0;
       
  2125    	
       
  2126 	TFileName trgPath = _L("?:\\F32-TST\\");
       
  2127 
       
  2128 	if (gSessionPath[0]!='D'&& gSessionPath[0]!='Y')
       
  2129 		{
       
  2130 #if !defined(__WINS__)
       
  2131 		trgPath[0] = 'D';
       
  2132 #else
       
  2133 		trgPath[0] = 'Y';
       
  2134 #endif
       
  2135 		}
       
  2136 	else
       
  2137 		return;
       
  2138 
       
  2139 	TFileName trgDir = trgPath;
       
  2140 	trgDir.Append(_L("TFMAN\\INC108401\\dest\\"));
       
  2141 	
       
  2142 	// Moving files and dirs ACROSS DRIVE.
       
  2143   	err = 0;
       
  2144 	MakeDir(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\"));
       
  2145 	MakeDir(trgDir);
       
  2146 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file1"));
       
  2147 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file2"));
       
  2148 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1"));
       
  2149 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2"));
       
  2150 	// Synchronously
       
  2151 	if (!gAsynch)
       
  2152 		err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), trgDir, 0);
       
  2153 	else // Asynchronously
       
  2154 		err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), trgDir, 0, gStat);
       
  2155 	test.Next(_L("Test INC108401 : ACROSS DRIVES with 0"));
       
  2156 	TestResult(err);
       
  2157 	// cleanup the current drive
       
  2158 	RmDir(trgPath);
       
  2159 	// remove the F32-TST dir on the C: drive
       
  2160 	RmDir(_L("\\F32-TST\\TFMAN\\"));
       
  2161 	
       
  2162 	err = 0;
       
  2163 	MakeDir(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\"));
       
  2164 	MakeDir(trgDir);
       
  2165 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file1"));
       
  2166 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file2"));
       
  2167 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1"));
       
  2168 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2"));
       
  2169 	// Synchronously
       
  2170 	if (!gAsynch)
       
  2171 		err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), trgDir, CFileMan::EOverWrite);
       
  2172 	else // Asynchronously
       
  2173 		err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), trgDir, CFileMan::EOverWrite, gStat);
       
  2174 	test.Next(_L("Test INC108401 : ACROSS DRIVES with CFileMan::EOverWrite"));
       
  2175 	TestResult(err);
       
  2176 	// cleanup the current drive
       
  2177 	RmDir(trgPath);
       
  2178 	// remove the F32-TST dir on the C: drive
       
  2179 	RmDir(_L("\\F32-TST\\"));
       
  2180 	
       
  2181 	err = 0;
       
  2182 	MakeDir(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\"));
       
  2183 	MakeDir(trgDir);
       
  2184 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file1"));
       
  2185 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file2"));
       
  2186 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1"));
       
  2187 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2"));
       
  2188 	// Synchronously
       
  2189 	if (!gAsynch)
       
  2190 		err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), trgDir, CFileMan::ERecurse);
       
  2191 	else // Asynchronously
       
  2192 		err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), trgDir, CFileMan::ERecurse, gStat);
       
  2193 	test.Next(_L("Test INC108401 : ACROSS DRIVES with CFileMan::ERecurse"));
       
  2194 	TestResult(err);
       
  2195 	// cleanup the current drive
       
  2196 	RmDir(trgPath);
       
  2197 	// remove the F32-TST dir on the C: drive
       
  2198 	RmDir(_L("\\F32-TST\\"));
       
  2199 
       
  2200 
       
  2201 	// Moving files and dirs on the SAME DRIVE.
       
  2202 	// case for gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), 0);
       
  2203 	MakeDir(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\"));
       
  2204 	MakeDir(_L("\\F32-TST\\TFMAN\\INC108401\\dest\\"));
       
  2205 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file1"));
       
  2206 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file2"));
       
  2207 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1"));
       
  2208 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2"));
       
  2209 	// Synchronously
       
  2210 	if (!gAsynch)	
       
  2211 		err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), 0);
       
  2212 	else // Asynchronously	
       
  2213 		err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), 0, gStat);
       
  2214 	test.Next(_L("Test INC108401 : SAME DRIVE with 0"));
       
  2215 	TestResult(err);
       
  2216 	// test(err==KErrNone);
       
  2217 	RmDir(_L("\\F32-TST\\TFMAN\\INC108401\\"));
       
  2218 	
       
  2219 	// case for gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), CFileMan::EOverWrite);
       
  2220 	MakeDir(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\"));
       
  2221 	MakeDir(_L("\\F32-TST\\TFMAN\\INC108401\\dest\\"));
       
  2222 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file1"));
       
  2223 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file2"));
       
  2224 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1"));
       
  2225 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2"));
       
  2226 	// Synchronously
       
  2227 	if (!gAsynch)	
       
  2228 		err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), CFileMan::EOverWrite);
       
  2229 	else // Asynchronously	
       
  2230 		err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), CFileMan::EOverWrite, gStat);
       
  2231 	test.Next(_L("Test INC108401 : SAME DRIVE with CFileMan::EOverWrite"));
       
  2232 	TestResult(err);
       
  2233 	// test(err==KErrNone);
       
  2234 	RmDir(_L("\\F32-TST\\TFMAN\\INC108401\\"));
       
  2235 	
       
  2236 	// case for gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), CFileMan::EOverWrite|CFileMan::ERecurse);
       
  2237 	MakeDir(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\"));
       
  2238 	MakeDir(_L("\\F32-TST\\TFMAN\\INC108401\\dest\\"));
       
  2239 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file1"));
       
  2240 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file2"));
       
  2241 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1"));
       
  2242 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2"));
       
  2243 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\file1"));
       
  2244 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\file1"));
       
  2245 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\file1"));
       
  2246 	MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\file1"));
       
  2247 	// Synchronously
       
  2248 	if (!gAsynch)	
       
  2249 		err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), CFileMan::ERecurse|CFileMan::EOverWrite);
       
  2250 	else // Asynchronously	
       
  2251 		err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), CFileMan::ERecurse|CFileMan::EOverWrite, gStat);
       
  2252 	test.Next(_L("Test INC108401 : SAME DRIVES with CFileMan::ERecurse|CFileMan::EOverWrite"));
       
  2253 	TestResult(err);
       
  2254 	// test(err==KErrNone);
       
  2255 	RmDir(_L("\\F32-TST\\TFMAN\\INC108401\\"));
       
  2256 	
       
  2257 	// cleanup for the current drive
       
  2258 	RmDir(trgPath);
       
  2259 	RmDir(_L("\\F32-TST\\"));
       
  2260 
       
  2261 	test.Next(_L("Test INC108401 : ends"));
       
  2262   }
       
  2263 
       
  2264 LOCAL_C void TestINC089638()
       
  2265   {
       
  2266 	if(gAsynch)  
       
  2267 		{
       
  2268 		return;
       
  2269 		}
       
  2270 	RmDir(_L("\\INC089638\\source\\"));
       
  2271 	RmDir(_L("\\INC089638\\dest\\"));
       
  2272 	MakeFile(_L("\\INC089638\\source\\file1"));
       
  2273 	MakeFile(_L("\\INC089638\\source\\file2"));
       
  2274 	MakeFile(_L("\\INC089638\\source\\subdir1\\file3"));
       
  2275 	MakeFile(_L("\\INC089638\\source\\subdir1\\file4"));
       
  2276 	MakeFile(_L("\\INC089638\\source\\subdir2\\file5"));
       
  2277 	MakeFile(_L("\\INC089638\\source\\subdir2\\file6"));
       
  2278 	MakeDir(_L("\\INC089638\\dest\\"));
       
  2279 	test(TheFs.SetAtt(_L("\\INC089638\\source\\subdir1"), KEntryAttHidden, 0) == KErrNone);
       
  2280 	test(TheFs.SetAtt(_L("\\INC089638\\source\\subdir2"), KEntryAttReadOnly, 0) == KErrNone);
       
  2281 	
       
  2282 	TInt r = gFileMan->Move(_L("\\INC089638\\source\\"), _L("\\INC089638\\dest\\"), CFileMan::ERecurse);
       
  2283 	test(r==KErrNone);
       
  2284 	r = TheFs.RmDir(_L("\\INC089638\\source\\"));
       
  2285 	test(r==KErrNone);
       
  2286 	
       
  2287 	RmDir(_L("\\INC089638\\"));
       
  2288   }
       
  2289 
       
  2290 void TestINC101379()
       
  2291 	{
       
  2292 	TInt err;
       
  2293 	_LIT(KSourceDir,"\\INC101379\\dir\\");
       
  2294 	_LIT(KFile1, "\\INC101379\\dir\\file1.txt");
       
  2295 	_LIT(KFile2, "\\INC101379\\dir\\subdir\\file2.txt");
       
  2296 	_LIT(KFile3, "\\INC101379\\dir\\other\\file3.txt");
       
  2297 	MakeFile(KFile1, _L8("qwerty"));
       
  2298 	MakeFile(KFile2, _L8("abc"));
       
  2299 	MakeFile(KFile3, _L8("qwerty"));
       
  2300 	TFileName dest;
       
  2301 	dest.Copy(KSourceDir);
       
  2302 	dest.Append(_L("subdir"));
       
  2303 	gFileMan->SetObserver(NULL);
       
  2304 	if (!gAsynch)
       
  2305 		err = gFileMan->Move(KSourceDir, dest, CFileMan::ERecurse|CFileMan::EOverWrite);
       
  2306 	else
       
  2307 		err = gFileMan->Move(KSourceDir, dest, CFileMan::ERecurse|CFileMan::EOverWrite, gStat);
       
  2308 	test(err==KErrInUse); // Recursive move prohibited
       
  2309 	if (gAsynch)
       
  2310 		WaitForResult(KErrInUse);
       
  2311 	CheckFileContents(KFile1, _L8("qwerty"));
       
  2312 	CheckFileContents(KFile2, _L8("abc"));
       
  2313 	CheckFileContents(KFile3, _L8("qwerty"));
       
  2314 
       
  2315 	if (!gAsynch)
       
  2316 		err = gFileMan->Move(KSourceDir, dest, CFileMan::EOverWrite);
       
  2317 	else
       
  2318 		err = gFileMan->Move(KSourceDir, dest, CFileMan::EOverWrite, gStat);
       
  2319 	TestResult(err, KErrNone); // Non-recursive move must be OK
       
  2320 
       
  2321 	_LIT(KFile1Moved, "\\INC101379\\dir\\subdir\\file1.txt");
       
  2322 	CheckFileContents(KFile1Moved, _L8("qwerty"));
       
  2323 	CheckFileContents(KFile2, _L8("abc"));
       
  2324 	CheckFileContents(KFile3, _L8("qwerty"));
       
  2325 	gFileMan->SetObserver(gObserver);
       
  2326 	RmDir(KSourceDir);
       
  2327 	RmDir(_L("\\INC101379\\"));
       
  2328 	}
       
  2329 	
       
  2330  void TestINC099600() // and INC101061
       
  2331 	{
       
  2332 	_LIT(KDest,"C:\\DEST099600\\");
       
  2333 	TBuf<64> source;
       
  2334 	source.Format(_L("%c:\\INC099600\\"), (TUint) gDriveToTest);
       
  2335 	TBuf<64> src;
       
  2336 	TInt r;
       
  2337 	TBuf<64> dst;
       
  2338 	RmDir(source);
       
  2339 	RmDir(KDest);
       
  2340 	
       
  2341 	src = source;
       
  2342 	src.Append('a');
       
  2343 	MakeFile(src);
       
  2344 	TheFs.SetAtt(src, KEntryAttArchive, 0);
       
  2345 	src.Append('h');
       
  2346 	MakeFile(src);
       
  2347 	TheFs.SetAtt(src, KEntryAttArchive | KEntryAttHidden, 0);
       
  2348 	src.Append('s');
       
  2349 	MakeFile(src);
       
  2350 	TheFs.SetAtt(src, KEntryAttArchive | KEntryAttHidden | KEntryAttSystem, 0);
       
  2351 	src.Append('x');
       
  2352 	src.Append(KPathDelimiter);
       
  2353 	src.Append('a');
       
  2354 	MakeFile(src);
       
  2355 	TheFs.SetAtt(src, KEntryAttArchive, 0);
       
  2356 	src.Append('h');
       
  2357 	MakeFile(src);
       
  2358 	TheFs.SetAtt(src, KEntryAttArchive | KEntryAttHidden, 0);
       
  2359 
       
  2360 	dst.Copy(KDest);
       
  2361 	dst.Append(_L("ahsx\\"));
       
  2362 	MakeDir(dst);
       
  2363 
       
  2364 	TEntry entry;
       
  2365 	r = gFileMan->Move(src, KDest, 0); // ahsx\ah
       
  2366 	test(r == KErrNone);
       
  2367 	r = TheFs.Entry(src, entry);
       
  2368 	test(r == KErrNotFound);
       
  2369 
       
  2370 	src.SetLength(src.Length()-1); // ahsx\a
       
  2371 	r = gFileMan->Move(src, KDest, 0);
       
  2372 	test(r == KErrNone);
       
  2373 	r = TheFs.Entry(src, entry);
       
  2374 	test(r == KErrNotFound);
       
  2375 	
       
  2376 	src.SetLength(src.Length()-3); // ahs
       
  2377 	r = gFileMan->Move(src, KDest, 0);
       
  2378 	test(r == KErrNone);
       
  2379 	r = TheFs.Entry(src, entry);
       
  2380 	test(r == KErrNotFound);
       
  2381 	
       
  2382 	src.SetLength(src.Length()-1); // ah
       
  2383 	r = gFileMan->Move(src, KDest, 0);
       
  2384 	test(r == KErrAlreadyExists);
       
  2385 	r = TheFs.Entry(src, entry);
       
  2386 	test(r == KErrNone);
       
  2387 
       
  2388 	r = gFileMan->Move(src, KDest, CFileMan::EOverWrite); // ah
       
  2389 	test(r == KErrNone);
       
  2390 	r = TheFs.Entry(src, entry);
       
  2391 	test(r == KErrNotFound);
       
  2392 
       
  2393 	src.SetLength(src.Length()-1); // a
       
  2394 	r = gFileMan->Move(src, KDest, 0);
       
  2395 	test(r == KErrAlreadyExists);
       
  2396 	r = TheFs.Entry(src, entry);
       
  2397 	test(r == KErrNone);
       
  2398 
       
  2399 	r = gFileMan->Move(src, KDest, CFileMan::EOverWrite); // a
       
  2400 	test(r == KErrNone);
       
  2401 	r = TheFs.Entry(src, entry);
       
  2402 	test(r == KErrNotFound);
       
  2403 
       
  2404 	RmDir(source);
       
  2405 	RmDir(KDest);
       
  2406 	}
       
  2407 
       
  2408 void SetupDirectoriesForCase0520()
       
  2409 // Setup initial directory structure for test case PBASE-T_FMAN-0520
       
  2410 	{
       
  2411 	RmDir(		_L("\\F32-TST\\TFMAN\\INC106735\\"));
       
  2412 	MakeDir(	_L("\\F32-TST\\TFMAN\\INC106735\\"));
       
  2413 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC106735\\F_ROOT.TXT"), _L8("blahblahblah"));
       
  2414 	MakeDir(	_L("\\F32-TST\\TFMAN\\INC106735\\SUB\\"));
       
  2415 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC106735\\SUB\\F_SUB.TXT"), _L8("blahblahblah"));
       
  2416 	MakeDir(	_L("\\F32-TST\\TFMAN\\INC106735\\SUB01\\"));
       
  2417 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC106735\\SUB01\\F_SUB01.TXT"), _L8("blahblahblah"));
       
  2418 	MakeDir(	_L("\\F32-TST\\TFMAN\\INC106735\\SUB01\\SUB02\\"));
       
  2419 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC106735\\SUB01\\SUB02\\F_SUB02.TXT"), _L8("blahblahblah"));
       
  2420 	}
       
  2421 
       
  2422 void SetupDirectoriesForCase0520Compare1()
       
  2423 // Comparing directory structure for recursive Move() without wildcard
       
  2424 	{
       
  2425 	RmDir(		_L("\\F32-TST\\TFMAN\\INC106735_COM\\"));
       
  2426 	MakeDir(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\"));
       
  2427 	MakeDir(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\"));
       
  2428 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\F_ROOT.TXT"), _L8("blahblahblah"));
       
  2429 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\F_SUB.TXT"), _L8("blahblahblah"));
       
  2430 	MakeDir(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\"));
       
  2431 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\F_SUB01.TXT"), _L8("blahblahblah"));
       
  2432 	MakeDir(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\SUB02\\"));
       
  2433 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\SUB02\\F_SUB02.TXT"), _L8("blahblahblah"));
       
  2434 	}
       
  2435 
       
  2436 void SetupDirectoriesForCase0520Compare2()
       
  2437 // Comparing directory structure for recursive Move() with wildcard
       
  2438 	{
       
  2439 	RmDir(		_L("\\F32-TST\\TFMAN\\INC106735_COM\\"));
       
  2440 	MakeDir(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\"));
       
  2441 	MakeDir(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\"));
       
  2442 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\F_ROOT.TXT"), _L8("blahblahblah"));
       
  2443 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\F_SUB.TXT"), _L8("blahblahblah"));
       
  2444 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\SUB01\\F_SUB01.TXT"), _L8("blahblahblah"));
       
  2445 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\SUB01\\SUB02\\F_SUB02.TXT"), _L8("blahblahblah"));
       
  2446 	MakeDir(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\"));
       
  2447 	MakeDir(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\SUB02\\"));
       
  2448 	}
       
  2449 
       
  2450 void SetupDirectoriesForCase0520Compare3()
       
  2451 // Comparing directory structure for recursive Copy() without wildcard
       
  2452 	{
       
  2453 	RmDir(		_L("\\F32-TST\\TFMAN\\INC106735_COM\\"));
       
  2454 	MakeDir(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\"));
       
  2455 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\F_ROOT.TXT"), _L8("blahblahblah"));
       
  2456 	MakeDir(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\"));
       
  2457 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\F_ROOT.TXT"), _L8("blahblahblah"));
       
  2458 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\F_SUB.TXT"), _L8("blahblahblah"));
       
  2459 	MakeDir(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\"));
       
  2460 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\F_SUB01.TXT"), _L8("blahblahblah"));
       
  2461 	MakeDir(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\SUB02\\"));
       
  2462 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\SUB02\\F_SUB02.TXT"), _L8("blahblahblah"));
       
  2463 	}
       
  2464 
       
  2465 void SetupDirectoriesForCase0520Compare4()
       
  2466 // Comparing directory structure for recursive Copy() with wildcard
       
  2467 	{
       
  2468 	RmDir(		_L("\\F32-TST\\TFMAN\\INC106735_COM\\"));
       
  2469 	MakeDir(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\"));
       
  2470 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\F_ROOT.TXT"), _L8("blahblahblah"));
       
  2471 	MakeDir(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\"));
       
  2472 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\F_ROOT.TXT"), _L8("blahblahblah"));
       
  2473 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\F_SUB.TXT"), _L8("blahblahblah"));
       
  2474 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\SUB01\\F_SUB01.TXT"), _L8("blahblahblah"));
       
  2475 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\SUB01\\SUB02\\F_SUB02.TXT"), _L8("blahblahblah"));
       
  2476 	MakeDir(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\"));
       
  2477 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\F_SUB01.TXT"), _L8("blahblahblah"));
       
  2478 	MakeDir(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\SUB02\\"));
       
  2479 	MakeFile(	_L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\SUB02\\F_SUB02.TXT"), _L8("blahblahblah"));
       
  2480 	}
       
  2481 
       
  2482 LOCAL_C void TestRecursiveMove()
       
  2483 //
       
  2484 // Test recursive move
       
  2485 //
       
  2486 	{
       
  2487 	test.Next(_L("Test recursive move"));
       
  2488 	RmDir(_L("\\F32-TST\\TFMAN\\RecMove2\\"));
       
  2489 
       
  2490 	MakeFile(_L("\\F32-TST\\TFMAN\\RECMOVE\\FULL\\FILE2.PLP"));
       
  2491 	MakeFile(_L("\\F32-TST\\TFMAN\\RECMOVE\\FULL\\FILE3.PLP"));
       
  2492 	MakeFile(_L("\\F32-TST\\TFMAN\\RECMOVE\\FULL\\GRAPE.TXT"));
       
  2493 	MakeFile(_L("\\F32-TST\\TFMAN\\RECMOVE\\GRAPE.TXT"));
       
  2494 	MakeFile(_L("\\F32-TST\\TFMAN\\RECMOVE\\FILE1.PLP"));
       
  2495 
       
  2496 	TInt err;
       
  2497 	if (!gAsynch)
       
  2498 		err=gFileMan->Move(_L("\\F32-TST\\TFMAN\\RECMOVE\\*.PLP"),_L("\\F32-TST\\TFMAN\\RECMOVE2\\"),CFileMan::ERecurse);
       
  2499 	else
       
  2500 		err=gFileMan->Move(_L("\\F32-TST\\TFMAN\\RECMOVE\\*.PLP"),_L("\\F32-TST\\TFMAN\\RECMOVE2\\"),CFileMan::ERecurse,gStat);
       
  2501 	TestResult(err);
       
  2502 
       
  2503 	RmDir(_L("\\F32-TST\\TFMAN\\after\\"));
       
  2504 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FULL\\FILE2.PLP"));
       
  2505 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FULL\\FILE3.PLP"));
       
  2506 	MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FILE1.PLP"));
       
  2507 	Compare(_L("\\F32-TST\\TFMAN\\after\\*"),_L("\\F32-TST\\TFMAN\\RecMOve2\\*"));
       
  2508 
       
  2509 	//
       
  2510 	// Test moving empty directories (DEF073924)
       
  2511 	//
       
  2512 	test.Next(_L("Test moving empty directories"));
       
  2513 
       
  2514 	SetupDirectories(EFalse, NULL);
       
  2515 
       
  2516 	err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\"), _L("\\F32-TST\\TFMAN\\dest\\"), CFileMan::ERecurse);
       
  2517 	test(err == KErrNotFound);	// Expected - directory is empty
       
  2518 
       
  2519 	// Test that all directories are still present
       
  2520 	TEntry entry;
       
  2521 	err = TheFs.Entry(_L("\\F32-TST\\TFMAN\\source\\"), entry);
       
  2522 	test(err == KErrNone);
       
  2523 	err = TheFs.Entry(_L("\\F32-TST\\TFMAN\\dest\\"), entry);
       
  2524 	test(err == KErrNone);
       
  2525 
       
  2526 	SetupDirectories(EFalse, NULL);
       
  2527 
       
  2528 	err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source"), _L("\\F32-TST\\TFMAN\\dest\\"), CFileMan::ERecurse);
       
  2529 	test(err == KErrNone);		// Expected - should move (or rename) directory
       
  2530 
       
  2531 	// Test directory has been moved
       
  2532 	err = TheFs.Entry(_L("\\F32-TST\\TFMAN\\dest\\source\\"), entry);
       
  2533 	test(err == KErrNone);
       
  2534 	err = TheFs.Entry(_L("\\F32-TST\\TFMAN\\source\\"), entry);
       
  2535 	test(err == KErrNotFound);
       
  2536 
       
  2537 	RmDir(_L("\\F32-TST\\TFMAN\\dest\\source\\"));
       
  2538 
       
  2539 	//
       
  2540 	// Test moving when the source directory contains subdirectories (INC074828, INC078800)
       
  2541 	//
       
  2542 	test.Next(_L("Test moving a directory containing subdirectories"));
       
  2543 
       
  2544 	SetupDirectories(ETrue, NULL);
       
  2545 	err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\"), _L("\\F32-TST\\TFMAN\\dest\\"), CFileMan::ERecurse | CFileMan::EOverWrite);
       
  2546 	test(err == KErrNone);
       
  2547 
       
  2548 	Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), _L("\\F32-TST\\TFMAN\\dest\\*"));
       
  2549 
       
  2550 	//--------------------------------------------- 
       
  2551 	//! @SYMTestCaseID			PBASE-T_FMAN-0160
       
  2552 	//! @SYMTestType			UT 
       
  2553 	//! @SYMREQ					DEF087791
       
  2554 	//! @SYMTestCaseDesc		Test that CFileMan::Move() works when the destination paths does not exist.
       
  2555 	//! @SYMTestActions			Copy directory structures to a non-existant directory on the same drive.
       
  2556 	//! @SYMTestExpectedResults	Completes with no error, files are copied and intermediate directories are created.
       
  2557 	//! @SYMTestPriority		High
       
  2558 	//! @SYMTestStatus			Implemented 
       
  2559 	//--------------------------------------------- 	
       
  2560 	test.Next(_L("Test moving when the target directory does not exist"));
       
  2561 
       
  2562 	SetupDirectories(ETrue, NULL);
       
  2563 	
       
  2564 	RmDir(_L("\\F32-TST\\TFMAN\\dest\\"));
       
  2565 
       
  2566 	err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\"), _L("\\F32-TST\\TFMAN\\dest\\"), CFileMan::ERecurse);
       
  2567 	test(err == KErrNone);
       
  2568 
       
  2569 	Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), _L("\\F32-TST\\TFMAN\\dest\\*"));
       
  2570 
       
  2571 	SetupDirectories(ETrue, NULL);
       
  2572 	
       
  2573 	RmDir(_L("\\F32-TST\\TFMAN\\dest\\"));
       
  2574 
       
  2575 	err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\"), _L("\\F32-TST\\TFMAN\\dest"), CFileMan::ERecurse);
       
  2576 	test(err == KErrNone);
       
  2577 
       
  2578 	Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), _L("\\F32-TST\\TFMAN\\dest\\*"));
       
  2579 
       
  2580 	SetupDirectories(ETrue, NULL);
       
  2581 	
       
  2582 	RmDir(_L("\\F32-TST\\TFMAN\\dest\\"));
       
  2583 
       
  2584 	err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source"), _L("\\F32-TST\\TFMAN\\dest\\"), CFileMan::ERecurse);
       
  2585 	test(err == KErrNone);
       
  2586 
       
  2587 	MakeDir(_L("\\F32-TST\\TFMAN\\compare\\subdir\\"));
       
  2588 	Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), _L("\\F32-TST\\TFMAN\\dest\\source\\*"));
       
  2589 	RmDir(_L("\\F32-TST\\TFMAN\\compare\\subdir\\"));
       
  2590 
       
  2591 	SetupDirectories(ETrue, NULL);
       
  2592 
       
  2593 	RmDir(_L("\\F32-TST\\TFMAN\\dest\\"));
       
  2594 
       
  2595 	err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\File1.TXT"), _L("\\F32-TST\\TFMAN\\dest\\"), CFileMan::ERecurse);
       
  2596 	test(err == KErrNone);
       
  2597 
       
  2598 	CheckFileExists(_L("\\F32-TST\\TFMAN\\source\\File1.TXT"), KErrNotFound, ETrue);
       
  2599 	CheckFileExists(_L("\\F32-TST\\TFMAN\\dest\\File1.TXT"),   KErrNone,     ETrue);
       
  2600 
       
  2601 	RmDir(_L("\\F32-TST\\TFMAN\\dest\\"));
       
  2602 	RmDir(_L("\\F32-TST\\TFMAN\\source\\"));
       
  2603 
       
  2604 	// Test behaviour for omitted parameters
       
  2605 	// For this, default should be session path
       
  2606 	TFileName sessionPath;
       
  2607 	err=TheFs.SessionPath(sessionPath);
       
  2608 	test(err==KErrNone);
       
  2609 
       
  2610 	SetupDirectories(ETrue, NULL);
       
  2611 	err=TheFs.SetSessionPath(_L("\\F32-TST\\TFMAN\\dest\\"));
       
  2612 	test(err == KErrNone);
       
  2613 
       
  2614 	err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source"), _L(""), CFileMan::ERecurse);
       
  2615 	test(err == KErrNone);
       
  2616 	Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), _L("\\F32-TST\\TFMAN\\dest\\source\\*"));
       
  2617 
       
  2618 	RmDir(_L("\\F32-TST\\TFMAN\\dest\\"));
       
  2619 	RmDir(_L("\\F32-TST\\TFMAN\\source\\"));
       
  2620 	SetupDirectories(ETrue, NULL);
       
  2621 	err=TheFs.SetSessionPath(_L("\\F32-TST\\TFMAN\\source\\"));
       
  2622 	test(err == KErrNone);
       
  2623 
       
  2624 	err = gFileMan->Move(_L(""), _L("\\F32-TST\\TFMAN\\dest\\"), CFileMan::ERecurse);
       
  2625 	test(err == KErrNone);
       
  2626 	Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), _L("\\F32-TST\\TFMAN\\dest\\*"));
       
  2627 		
       
  2628 	err=TheFs.SetSessionPath(sessionPath);
       
  2629 	test(err==KErrNone);
       
  2630 
       
  2631 	//--------------------------------------------- 
       
  2632 	//! @SYMTestCaseID			PBASE-T_FMAN-0520
       
  2633 	//! @SYMTestType			UT 
       
  2634 	//! @SYMREQ					INC106735
       
  2635 	//! @SYMTestCaseDesc		Test that CFileMan::Move() (recursive mode) works properly when the destination
       
  2636 	//!							directory is sub-directory of the source directory. 
       
  2637 	//!							(e.g. "C:SRC\\*.TXT" -> "C:\\SRC\\SUB\\")
       
  2638 	//! @SYMTestActions			Move, copy files recursively from source directory to one of its sub-directory,
       
  2639 	//!							with or without wildcards applied.
       
  2640 	//! @SYMTestExpectedResults	Completes with no error, file(s) are moved or copied properly, and no redundant
       
  2641 	//!							movings or copyings are made for files in destination directory.
       
  2642 	//! @SYMTestPriority		High
       
  2643 	//! @SYMTestStatus			Implemented 
       
  2644 	//--------------------------------------------- 	
       
  2645 	test.Next(_L("Test recursive moving and copying to sub-directories"));
       
  2646 	// Testing recursive Move() without wildcard
       
  2647 	SetupDirectoriesForCase0520();
       
  2648 	SetupDirectoriesForCase0520Compare1();
       
  2649 	if (!gAsynch)
       
  2650 		err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC106735\\F_ROOT.TXT"), _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\*"), CFileMan::ERecurse);
       
  2651 	else
       
  2652 		err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC106735\\F_ROOT.TXT"), _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\*"), CFileMan::ERecurse, gStat);
       
  2653 	TestResult(err, KErrNone);
       
  2654 	Compare(_L("\\F32-TST\\TFMAN\\INC106735\\"), _L("\\F32-TST\\TFMAN\\INC106735_COM\\"));
       
  2655 
       
  2656 	// Testing recursive Move() with wildcard
       
  2657 	SetupDirectoriesForCase0520();
       
  2658 	SetupDirectoriesForCase0520Compare2();
       
  2659 	if (!gAsynch)
       
  2660 		err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC106735\\*.TXT"), _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\"), CFileMan::ERecurse);
       
  2661 	else
       
  2662 		err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC106735\\*.TXT"), _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\"), CFileMan::ERecurse, gStat);
       
  2663 	TestResult(err, KErrNone);
       
  2664 	Compare(_L("\\F32-TST\\TFMAN\\INC106735\\"), _L("\\F32-TST\\TFMAN\\INC106735_COM\\"));
       
  2665 
       
  2666 	// Testing recursive Copy() without wildcard
       
  2667 	SetupDirectoriesForCase0520();
       
  2668 	SetupDirectoriesForCase0520Compare3();
       
  2669 	if (!gAsynch)
       
  2670 		err = gFileMan->Copy(_L("\\F32-TST\\TFMAN\\INC106735\\F_ROOT.TXT"), _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\"), CFileMan::ERecurse);
       
  2671 	else
       
  2672 		err = gFileMan->Copy(_L("\\F32-TST\\TFMAN\\INC106735\\F_ROOT.TXT"), _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\"), CFileMan::ERecurse, gStat);
       
  2673 	TestResult(err, KErrNone);
       
  2674 	Compare(_L("\\F32-TST\\TFMAN\\INC106735\\"), _L("\\F32-TST\\TFMAN\\INC106735_COM\\"));
       
  2675 
       
  2676 	// Testing recursive Copy() with wildcard
       
  2677 	SetupDirectoriesForCase0520();
       
  2678 	SetupDirectoriesForCase0520Compare4();
       
  2679 	if (!gAsynch)
       
  2680 		err = gFileMan->Copy(_L("\\F32-TST\\TFMAN\\INC106735\\*.TXT"), _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\"), CFileMan::ERecurse);
       
  2681 	else
       
  2682 		err = gFileMan->Copy(_L("\\F32-TST\\TFMAN\\INC106735\\*.TXT"), _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\"), CFileMan::ERecurse, gStat);
       
  2683 	TestResult(err, KErrNone);
       
  2684 	Compare(_L("\\F32-TST\\TFMAN\\INC106735\\"), _L("\\F32-TST\\TFMAN\\INC106735_COM\\"));
       
  2685 
       
  2686 	TestINC089638();
       
  2687 	TestINC101379();
       
  2688 	TestINC099600();  // and INC101061
       
  2689 	}
       
  2690 
       
  2691 
       
  2692 //
       
  2693 // A complex test directory structure...
       
  2694 //
       
  2695 LOCAL_D const TInt KNumFiles = 8;
       
  2696 LOCAL_D const TFileName complexFile[] = 
       
  2697 	{
       
  2698 	_L("\\F32-TST\\TFMAN\\complex\\dir1\\file1.txt"),
       
  2699 	_L("\\F32-TST\\TFMAN\\complex\\dir1\\file2.txt"),
       
  2700 	_L("\\F32-TST\\TFMAN\\complex\\dir1\\subdir1\\file3.txt"),
       
  2701 	_L("\\F32-TST\\TFMAN\\complex\\dir1\\subdir1\\file4.txt"),
       
  2702 	_L("\\F32-TST\\TFMAN\\complex\\dir12\\dir1\\file1.txt"),
       
  2703 	_L("\\F32-TST\\TFMAN\\complex\\dir12\\dir1\\file2.txt"),
       
  2704 	_L("\\F32-TST\\TFMAN\\complex\\dir12\\dir1\\subdir1\\file3.txt"),
       
  2705 	_L("\\F32-TST\\TFMAN\\complex\\dir12\\dir1\\subdir1\\file4.txt")
       
  2706 	};
       
  2707 
       
  2708 //
       
  2709 // The expected result of moving the directory complex\\dir1 into complex\\dir2\\ *without* EOverWrite
       
  2710 //
       
  2711 LOCAL_D const TInt KNumFilesResult1 = 8;
       
  2712 LOCAL_D const TFileName complexResult1[] = 
       
  2713 	{
       
  2714 	_L("\\F32-TST\\TFMAN\\complex_result1\\dir1\\file1.txt"),
       
  2715 	_L("\\F32-TST\\TFMAN\\complex_result1\\dir1\\file2.txt"),
       
  2716 	_L("\\F32-TST\\TFMAN\\complex_result1\\dir1\\subdir1\\file3.txt"),
       
  2717 	_L("\\F32-TST\\TFMAN\\complex_result1\\dir1\\subdir1\\file4.txt"),
       
  2718 	_L("\\F32-TST\\TFMAN\\complex_result1\\dir12\\dir1\\file1.txt"),
       
  2719 	_L("\\F32-TST\\TFMAN\\complex_result1\\dir12\\dir1\\file2.txt"),
       
  2720 	_L("\\F32-TST\\TFMAN\\complex_result1\\dir12\\dir1\\subdir1\\file3.txt"),
       
  2721 	_L("\\F32-TST\\TFMAN\\complex_result1\\dir12\\dir1\\subdir1\\file4.txt")
       
  2722 	};
       
  2723 
       
  2724 //
       
  2725 // The expected result of moving the directory complex\\dir1 into complex\\dir2\\ *with* EOverWrite
       
  2726 //
       
  2727 LOCAL_D const TInt KNumFilesResult2 = 4;
       
  2728 LOCAL_D const TFileName complexResult2[] = 
       
  2729 	{
       
  2730 	_L("\\F32-TST\\TFMAN\\complex_result2\\dir12\\dir1\\file1.txt"),
       
  2731 	_L("\\F32-TST\\TFMAN\\complex_result2\\dir12\\dir1\\file2.txt"),
       
  2732 	_L("\\F32-TST\\TFMAN\\complex_result2\\dir12\\dir1\\subdir1\\file3.txt"),
       
  2733 	_L("\\F32-TST\\TFMAN\\complex_result2\\dir12\\dir1\\subdir1\\file4.txt"),
       
  2734 
       
  2735 	};
       
  2736 
       
  2737 
       
  2738 LOCAL_C void TestRecursiveMoveAcrossDrives()
       
  2739 //
       
  2740 // Test recursive move across drives
       
  2741 //
       
  2742 	{
       
  2743 
       
  2744 	test.Next(_L("Test recursive move across drives"));
       
  2745 
       
  2746 	TFileName trgDir   = _L("\\F32-TST\\TFMAN\\RECMOVE2\\");
       
  2747 	TFileName trgSpec  = _L("\\F32-TST\\TFMAN\\RECMOVE2\\*");
       
  2748 
       
  2749 
       
  2750 	if (gSessionPath[0]=='C')
       
  2751 		{
       
  2752 #if !defined(__WINS__)
       
  2753 		trgDir	   = _L("D:\\F32-TST\\TFMAN\\RECMOVE2\\");
       
  2754 		trgSpec	   = _L("D:\\F32-TST\\TFMAN\\RECMOVE2\\*");
       
  2755 #else
       
  2756 		trgDir     = _L("Y:\\F32-TST\\TFMAN\\RECMOVE2\\");
       
  2757 		trgSpec    = _L("Y:\\F32-TST\\TFMAN\\RECMOVE2\\*");
       
  2758 #endif
       
  2759 		}
       
  2760 
       
  2761 	RmDir(trgDir);
       
  2762 
       
  2763 	MakeFile(_L("C:\\F32-TST\\TFMAN\\RECMOVE\\FULL\\FILE2.PLP"));
       
  2764 	MakeFile(_L("C:\\F32-TST\\TFMAN\\RECMOVE\\FULL\\FILE3.PLP"));
       
  2765 	MakeFile(_L("C:\\F32-TST\\TFMAN\\RECMOVE\\FULL\\GRAPE.TXT"));
       
  2766 	MakeFile(_L("C:\\F32-TST\\TFMAN\\RECMOVE\\GRAPE.TXT"));
       
  2767 	MakeFile(_L("C:\\F32-TST\\TFMAN\\RECMOVE\\FILE1.PLP"));
       
  2768 
       
  2769 	TInt err;
       
  2770 	if (!gAsynch)
       
  2771 		err=gFileMan->Move(_L("C:\\F32-TST\\TFMAN\\RECMOVE\\*.PLP"),trgDir,CFileMan::ERecurse);
       
  2772 	else
       
  2773 		err=gFileMan->Move(_L("C:\\F32-TST\\TFMAN\\RECMOVE\\*.PLP"),trgDir,CFileMan::ERecurse,gStat);
       
  2774 	TestResult(err);
       
  2775 
       
  2776 	RmDir(_L("C:\\F32-TST\\TFMAN\\after\\"));
       
  2777 	MakeFile(_L("C:\\F32-TST\\TFMAN\\AFTER\\FULL\\FILE2.PLP"));
       
  2778 	MakeFile(_L("C:\\F32-TST\\TFMAN\\AFTER\\FULL\\FILE3.PLP"));
       
  2779 	MakeFile(_L("C:\\F32-TST\\TFMAN\\AFTER\\FILE1.PLP"));
       
  2780 	Compare(_L("C:\\F32-TST\\TFMAN\\after\\*"),trgSpec);
       
  2781 	RmDir(_L("C:\\F32-TST\\TFMAN\\AFTER\\"));
       
  2782 	RmDir(_L("C:\\F32-TST\\TFMAN\\RECMOVE\\"));
       
  2783 	
       
  2784 	//
       
  2785 	// Test moving empty directories (DEF073924)
       
  2786 	//
       
  2787 	test.Next(_L("Test moving empty directories"));
       
  2788 
       
  2789 	TFileName destOtherDrive;
       
  2790 	SetupDirectories(EFalse, &destOtherDrive);
       
  2791 
       
  2792 	err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\"), destOtherDrive, CFileMan::ERecurse);
       
  2793 	test(err == KErrNotFound);	// Expected - directory is empty
       
  2794 
       
  2795 	// Test that all directories are still present
       
  2796 	TEntry entry;
       
  2797 	err = TheFs.Entry(_L("\\F32-TST\\TFMAN\\source\\"), entry);
       
  2798 	test(err == KErrNone);
       
  2799 	err = TheFs.Entry(destOtherDrive, entry);
       
  2800 	test(err == KErrNone);
       
  2801 
       
  2802 	//--------------------------------------------- 
       
  2803 	//! @SYMTestCaseID			PBASE-T_FMAN-0571
       
  2804 	//! @SYMTestType			UT
       
  2805 	//! @SYMREQ					INC108401
       
  2806 	//! @SYMTestCaseDesc		This testcase tests the synchronous and asynchronous move operations exhaustively with flags set as 0, CFileMan::EOverWrite,
       
  2807 	//!							CFileMan::ERecurse on the SAME and ACROSS drives without trailing slash at the end of source dir path.
       
  2808 	//! @SYMTestActions			1. Copy directory structures to another directory across drive.
       
  2809 	//! 						2. Copy directory structures to another directory across drive overwriting duplicate files.
       
  2810 	//! 						3. Copy directory structures to another directory across drive.
       
  2811 	//! 						4. Copy directory structures to another directory on same drive.
       
  2812 	//! 						5. Copy directory structures to another directory on same drive overwriting duplicate files.
       
  2813 	//! 						6. Copy directory structures to another directory on same drive.
       
  2814 	//! @SYMTestExpectedResults 1. Completes with no error, the last directory and its contents are moved from the src directory to the destination directory.
       
  2815 	//!							2. Completes with no error, the last directory and its contents are moved from the src directory to the destination directory, duplicate files are updated.
       
  2816 	//!							3. Completes with no error, the last directory and its contents are moved from the src directory to the destination directory.
       
  2817 	//!							4. Completes with no error, the last directory and its contents are moved from the src directory to the destination directory.
       
  2818 	//!							5. Completes with no error, the last directory and its contents are moved from the src directory to the destination directory, duplicate files are updated.
       
  2819 	//!							6. Completes with no error, the last directory and its contents are moved from the src directory to the destination directory.
       
  2820 	//! @SYMTestPriority		High
       
  2821 	//! @SYMTestStatus			Implemented
       
  2822 	//--------------------------------------------- 	
       
  2823 
       
  2824 	TestINC108401();
       
  2825 
       
  2826 	//
       
  2827 	// Test moving when the source directory contains subdirectories (INC074828, INC078800)
       
  2828 	//
       
  2829 	test.Next(_L("Test moving a directory containing subdirectories"));
       
  2830 
       
  2831 	SetupDirectories(ETrue, &destOtherDrive);
       
  2832 	err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\"), destOtherDrive, CFileMan::ERecurse | CFileMan::EOverWrite);
       
  2833 	test(err == KErrNone);
       
  2834 
       
  2835 	destOtherDrive.Append(_L("*"));
       
  2836 	Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), destOtherDrive);
       
  2837 
       
  2838 	//--------------------------------------------- 
       
  2839 	//! @SYMTestCaseID			PBASE-T_FMAN-0161
       
  2840 	//! @SYMTestType			UT 
       
  2841 	//! @SYMREQ					DEF087791
       
  2842 	//! @SYMTestCaseDesc		Test that CFileMan::Move() works when the destination paths does not exist.
       
  2843 	//! @SYMTestActions			Copy directory structures to a non-existant directory on a different drive.
       
  2844 	//! @SYMTestExpectedResults Completes with no error, files are copied and intermediate directories are created.
       
  2845 	//! @SYMTestPriority		High
       
  2846 	//! @SYMTestStatus			Implemented 
       
  2847 	//--------------------------------------------- 	
       
  2848 	test.Next(_L("Test moving when the target directory does not exist"));
       
  2849 
       
  2850 	SetupDirectories(ETrue, &destOtherDrive);
       
  2851 	
       
  2852 	RmDir(destOtherDrive);
       
  2853 
       
  2854 	err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\"), destOtherDrive, CFileMan::ERecurse);
       
  2855 	test(err == KErrNone);
       
  2856 
       
  2857 	Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), destOtherDrive);
       
  2858 
       
  2859 	SetupDirectories(ETrue, &destOtherDrive);
       
  2860 	
       
  2861 	RmDir(destOtherDrive);
       
  2862 
       
  2863 	err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source"), destOtherDrive, CFileMan::ERecurse);
       
  2864 	test(err == KErrNone);
       
  2865 
       
  2866 	MakeDir(_L("\\F32-TST\\TFMAN\\compare\\subdir\\"));
       
  2867 	destOtherDrive.Append(_L("source\\"));
       
  2868 	Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), destOtherDrive);
       
  2869 	RmDir(_L("\\F32-TST\\TFMAN\\compare\\subdir\\"));
       
  2870 
       
  2871 	SetupDirectories(ETrue, &destOtherDrive);
       
  2872 
       
  2873 	RmDir(destOtherDrive);
       
  2874 
       
  2875 	err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\File1.TXT"), destOtherDrive, CFileMan::ERecurse);
       
  2876 	test(err == KErrNone);
       
  2877 
       
  2878 	CheckFileExists(_L("\\F32-TST\\TFMAN\\source\\File1.TXT"), KErrNotFound, ETrue);
       
  2879 	destOtherDrive.Append(_L("File1.TXT"));
       
  2880 	CheckFileExists(destOtherDrive, KErrNone, ETrue);
       
  2881 
       
  2882 	RmDir(destOtherDrive);
       
  2883 	RmDir(_L("\\F32-TST\\TFMAN\\source\\"));
       
  2884 
       
  2885 	//
       
  2886 	// Test recursive move of complex directory structure into itself (INC078759)
       
  2887 	//
       
  2888 
       
  2889 	test.Next(_L("Test recursive move of complex directory structure"));
       
  2890 
       
  2891 	// Set up the test directory
       
  2892 	TInt level = 0;
       
  2893 	for(level=0; level < KNumFiles; level++)
       
  2894 		{
       
  2895 		err = TheFs.MkDirAll(complexFile[level]);
       
  2896 		test(err == KErrNone || err == KErrAlreadyExists);
       
  2897 
       
  2898 		RFile file;
       
  2899 		err = file.Create(TheFs, complexFile[level], EFileRead | EFileWrite);
       
  2900 		test(err == KErrNone || err == KErrAlreadyExists || err == KErrBadName);
       
  2901 		file.Close();
       
  2902 		}
       
  2903 
       
  2904 	//
       
  2905 	// Move directory 'dir1' into 'dir12' *without* overwrite flag set
       
  2906 	//
       
  2907 	//  - This should fail, as 'dir12' already contains a directory called 'dir1'
       
  2908 	//  - No directories should be modified
       
  2909 	//
       
  2910 
       
  2911 	err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\complex\\dir1"), _L("\\F32-TST\\TFMAN\\complex\\dir12\\"), CFileMan::ERecurse);
       
  2912 	test(err == KErrAlreadyExists);
       
  2913 
       
  2914 	for(level=0; level < KNumFilesResult1; level++)
       
  2915 		{
       
  2916 		err = TheFs.MkDirAll(complexResult1[level]);
       
  2917 		test(err == KErrNone || err == KErrAlreadyExists);
       
  2918 
       
  2919 		RFile file;
       
  2920 		err = file.Create(TheFs, complexResult1[level], EFileRead | EFileWrite);
       
  2921 		test(err == KErrNone || err == KErrAlreadyExists || err == KErrBadName);
       
  2922 		file.Close();
       
  2923 		}
       
  2924 
       
  2925 	Compare(_L("\\F32-TST\\TFMAN\\complex_result1\\*"), _L("\\F32-TST\\TFMAN\\complex\\*"));
       
  2926 
       
  2927 	//
       
  2928 	// Move directory 'dir1' into 'dir12' *with* overwrite flag set
       
  2929 	//
       
  2930 	err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\complex\\dir1"), _L("\\F32-TST\\TFMAN\\complex\\dir12\\"), CFileMan::ERecurse | CFileMan::EOverWrite);
       
  2931 	test(err == KErrNone);
       
  2932 
       
  2933 	for(level=0; level < KNumFilesResult2; level++)
       
  2934 		{
       
  2935 		err = TheFs.MkDirAll(complexResult2[level]);
       
  2936 		test(err == KErrNone || err == KErrAlreadyExists);
       
  2937 
       
  2938 		RFile file;
       
  2939 		err = file.Create(TheFs, complexResult2[level], EFileRead | EFileWrite);
       
  2940 		test(err == KErrNone || err == KErrAlreadyExists || err == KErrBadName);
       
  2941 		file.Close();
       
  2942 		}
       
  2943 
       
  2944 	Compare(_L("\\F32-TST\\TFMAN\\complex_result2\\*"), _L("\\F32-TST\\TFMAN\\complex\\*"));
       
  2945 	
       
  2946 	// ...tidy up files
       
  2947 	for(level=0; level < KNumFiles; level++)
       
  2948 		TheFs.Delete(complexFile[level]);
       
  2949 	for(level=0; level < KNumFilesResult1; level++)
       
  2950 		TheFs.Delete(complexResult1[level]);
       
  2951 	for(level=0; level < KNumFilesResult2; level++)
       
  2952 		TheFs.Delete(complexResult2[level]);
       
  2953 
       
  2954 	// ...tidy up directories
       
  2955 	for(level=0; level < KNumFiles; level++)
       
  2956 		TheFs.RmDir(complexFile[level]);
       
  2957 	for(level=0; level < KNumFilesResult1; level++)
       
  2958 		TheFs.RmDir(complexResult1[level]);
       
  2959 	for(level=0; level < KNumFilesResult2; level++)
       
  2960 		TheFs.RmDir(complexResult2[level]);
       
  2961 
       
  2962 	TheFs.RmDir(_L("C:\\F32-TST\\TFMAN\\"));
       
  2963 	TheFs.RmDir(_L("C:\\F32-TST\\"));		
       
  2964 	}
       
  2965 
       
  2966 class CFileManCopyAllCancel : public CBase, public MFileManObserver
       
  2967 	{
       
  2968 public:
       
  2969 	CFileManCopyAllCancel(CFileMan* aFileMan);
       
  2970 	TControl NotifyFileManStarted();
       
  2971 	TControl NotifyFileManEnded();
       
  2972 	
       
  2973 private:
       
  2974 	CFileMan* iFileMan;
       
  2975 	};
       
  2976 
       
  2977 
       
  2978 CFileManCopyAllCancel::CFileManCopyAllCancel(CFileMan* aFileMan)
       
  2979 //
       
  2980 // Constructor
       
  2981 //
       
  2982 	{
       
  2983 
       
  2984 	__DECLARE_NAME(_S("CFileManCopyAllCancel"));
       
  2985 	iFileMan=aFileMan;
       
  2986 	}
       
  2987 
       
  2988 MFileManObserver::TControl CFileManCopyAllCancel::NotifyFileManStarted()
       
  2989 //
       
  2990 // Observer for TestCopyAllCancel tests
       
  2991 //
       
  2992 	{
       
  2993 	
       
  2994 	return(MFileManObserver::ECancel);
       
  2995 	}
       
  2996 
       
  2997 MFileManObserver::TControl CFileManCopyAllCancel::NotifyFileManEnded()
       
  2998 //
       
  2999 // Observer for TestCopyAllCancel tests
       
  3000 //
       
  3001 	{
       
  3002 	
       
  3003 	return(MFileManObserver::EContinue);
       
  3004 	}
       
  3005 	
       
  3006 
       
  3007 	
       
  3008 LOCAL_C void TestCopyAllCancel()
       
  3009 //
       
  3010 // Test copy ( all cancel)
       
  3011 //
       
  3012 	{
       
  3013 
       
  3014 	test.Next(_L("Test copy all cancel"));
       
  3015 	
       
  3016 	RmDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\*"));
       
  3017 	CFileManCopyAllCancel* fManObserver=new(ELeave) CFileManCopyAllCancel(gFileMan);
       
  3018 	CleanupStack::PushL(fManObserver);
       
  3019 	gFileMan->SetObserver(fManObserver);
       
  3020 	
       
  3021 
       
  3022 	MakeDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
       
  3023 	MakeDir(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EMPTY\\"));
       
  3024 	MakeFile(_L("\\F32-TST\\TFMAN\\NewDir\\ABC.DEF"));
       
  3025 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"));
       
  3026 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE2.TXT"));
       
  3027 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE3.TXT"));
       
  3028 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\FILE4.TXT"));
       
  3029 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EXE1.BIN"));
       
  3030 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\EXE2.BIN"));
       
  3031 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA1.TXT"));
       
  3032 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA2.TXT"));
       
  3033 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA3.TXT"));
       
  3034 	MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA4.TXT"));
       
  3035 
       
  3036 	test.Next(_L("Test cancel copy all the files "));
       
  3037 	TInt r;
       
  3038 	
       
  3039 	if (!gAsynch)
       
  3040 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0);
       
  3041 	else
       
  3042 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0,gStat);
       
  3043 	TestResult(r,KErrCancel);
       
  3044 	
       
  3045 	if (!gAsynch)
       
  3046 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.txt"),_L("\\F32-TST\\TFMAN\\file1.txt"),0);
       
  3047 	else
       
  3048 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.txt"),_L("\\F32-TST\\TFMAN\\file1.txt"),0,gStat);
       
  3049 	TestResult(r,KErrCancel);
       
  3050 	gFileMan->SetObserver(gObserver);
       
  3051 	CleanupStack::PopAndDestroy();
       
  3052 	
       
  3053 	}
       
  3054 
       
  3055 class CFileManObserverOverWrite : public CBase, public MFileManObserver
       
  3056 	{
       
  3057 public:
       
  3058 	CFileManObserverOverWrite(CFileMan* aFileMan);
       
  3059 	TControl NotifyFileManEnded();
       
  3060 private:
       
  3061 	CFileMan* iFileMan;
       
  3062 	};
       
  3063 
       
  3064 
       
  3065 CFileManObserverOverWrite::CFileManObserverOverWrite(CFileMan* aFileMan)
       
  3066 //
       
  3067 // Constructor
       
  3068 //
       
  3069 	{
       
  3070 
       
  3071 	__DECLARE_NAME(_S("CFileManObserverOverWrite"));
       
  3072 	iFileMan=aFileMan;
       
  3073 	}
       
  3074 
       
  3075 
       
  3076 MFileManObserver::TControl CFileManObserverOverWrite::NotifyFileManEnded()
       
  3077 //
       
  3078 // Observer for testoverwrite tests
       
  3079 //
       
  3080 	{
       
  3081 
       
  3082 	TInt lastError=iFileMan->GetLastError();
       
  3083 	if (lastError!=KErrNone)
       
  3084 		{
       
  3085 		test(lastError==KErrAlreadyExists);
       
  3086 		if (gAsynch==EFalse)
       
  3087 			{
       
  3088 			TFileName fileName=iFileMan->CurrentEntry().iName;
       
  3089 			test.Printf(_L("     %S already exists\n"),&fileName);
       
  3090 			}
       
  3091 		}
       
  3092 	return(MFileManObserver::EContinue);
       
  3093 	}
       
  3094 
       
  3095 LOCAL_C void TestOverWrite()
       
  3096 //
       
  3097 // Test overwrite for copy and rename
       
  3098 //
       
  3099 	{
       
  3100 
       
  3101 	test.Next(_L("Test overwrite option"));
       
  3102 	RmDir(_L("\\F32-TST\\TFMAN\\OVERWRITE\\"));
       
  3103 	CFileManObserverOverWrite* fManObserver=new(ELeave) CFileManObserverOverWrite(gFileMan);
       
  3104 	CleanupStack::PushL(fManObserver);
       
  3105 	gFileMan->SetObserver(fManObserver);
       
  3106 
       
  3107 	TBuf8<128> contentsFile1=_L8("Test file one contents");
       
  3108 	TBuf8<128> contentsFile2=_L8("Test file two contents");
       
  3109 
       
  3110 	MakeFile(_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\FILE1.TXT"));
       
  3111 	MakeFile(_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\FILE2.TXT"));
       
  3112 	MakeFile(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC\\FILE1.TXT"),contentsFile1);
       
  3113 	MakeFile(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC\\FILE2.TXT"),contentsFile2);
       
  3114 
       
  3115 	if (!gAsynch)
       
  3116 		{
       
  3117 		TInt r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC"),_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG"),0);
       
  3118 		test(r==KErrAlreadyExists);
       
  3119 		}
       
  3120 	else
       
  3121 		{
       
  3122 		TInt r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC"),_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG"),0,gStat);
       
  3123 		test(r==KErrNone);
       
  3124 		WaitForResult(KErrAlreadyExists);
       
  3125 		}
       
  3126 
       
  3127 	RFile f;
       
  3128 	TInt r=f.Open(TheFs,_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\FILE1.TXT"),EFileRead);
       
  3129 	test(r==KErrNone);
       
  3130 	TBuf8<128> data;
       
  3131 	r=f.Read(data);
       
  3132 	test(r==KErrNone);
       
  3133 	test(data.Length()==0);
       
  3134 	f.Close();
       
  3135 
       
  3136 	if (!gAsynch)
       
  3137 		{
       
  3138 		TInt r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC"),_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG"),CFileMan::EOverWrite);
       
  3139 		test(r==KErrNone);
       
  3140 		}
       
  3141 	else
       
  3142 		{
       
  3143 		TInt r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC"),_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG"),CFileMan::EOverWrite,gStat);
       
  3144 		test(r==KErrNone);
       
  3145 		WaitForSuccess();
       
  3146 		}
       
  3147 
       
  3148 	r=f.Open(TheFs,_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\FILE1.TXT"),EFileRead);
       
  3149 	test(r==KErrNone);
       
  3150 	r=f.Read(data);
       
  3151 	test(r==KErrNone);
       
  3152 	test(data==contentsFile1);
       
  3153 	f.Close();
       
  3154 
       
  3155 	RmDir(_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\"));
       
  3156 	MakeFile(_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\FILE1.TXT"));
       
  3157 	MakeFile(_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\FILE2.TXT"));
       
  3158 
       
  3159 	if (!gAsynch)
       
  3160 		{
       
  3161 	TInt r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC\\*"),_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\*"),0);
       
  3162 		test(r==KErrAlreadyExists);
       
  3163 		}
       
  3164 	else
       
  3165 		{
       
  3166 		TInt r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC\\*"),_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\*"),0,gStat);
       
  3167 		test(r==KErrNone);
       
  3168 		WaitForResult(KErrAlreadyExists);
       
  3169 		}
       
  3170 
       
  3171 	r=f.Open(TheFs,_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\FILE2.TXT"),EFileRead);
       
  3172 	test(r==KErrNone);
       
  3173 	r=f.Read(data);
       
  3174 	test(r==KErrNone);
       
  3175 	test(data.Length()==0);
       
  3176 	f.Close();
       
  3177 
       
  3178 	if (!gAsynch)
       
  3179 		{
       
  3180 		TInt r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC\\*"),_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\*"),CFileMan::EOverWrite);
       
  3181 		test(r==KErrNone);
       
  3182 		}
       
  3183 	else
       
  3184 		{
       
  3185 		TInt r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC\\*"),_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\*"),CFileMan::EOverWrite,gStat);
       
  3186 		test(r==KErrNone);
       
  3187 		WaitForSuccess();
       
  3188 		}
       
  3189 
       
  3190 	r=f.Open(TheFs,_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\FILE2.TXT"),EFileRead);
       
  3191 	test(r==KErrNone);
       
  3192 	r=f.Read(data);
       
  3193 	test(r==KErrNone);
       
  3194 	test(data==contentsFile2);
       
  3195 	f.Close();
       
  3196 	gFileMan->SetObserver(gObserver);
       
  3197 	CleanupStack::PopAndDestroy();
       
  3198 	}
       
  3199 
       
  3200 LOCAL_C void TestErrorHandling()
       
  3201 //
       
  3202 // Test bad paths etc
       
  3203 //
       
  3204 	{
       
  3205 
       
  3206 	test.Next(_L("Test error handling"));
       
  3207 	if (!gAsynch)
       
  3208 		{
       
  3209 		TInt r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\BADPATH\\*"));
       
  3210 		test(r==KErrPathNotFound);
       
  3211 		}
       
  3212 	else
       
  3213 		{
       
  3214 		TInt r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\BADPATH\\*"),0,gStat);
       
  3215 		test(r==KErrNone);
       
  3216 		WaitForResult(KErrPathNotFound);
       
  3217 		}
       
  3218 
       
  3219 	CFileMan* fMan=CFileMan::NewL(TheFs);
       
  3220 	TInt r;
       
  3221 	{
       
  3222 	for(TInt drvNum=EDriveA; drvNum<=EDriveZ; ++drvNum)
       
  3223 		{
       
  3224 		TDriveInfo drvInfo;
       
  3225 		if(KErrNone==TheFs.Drive(drvInfo, drvNum) && drvInfo.iType==EMediaNotPresent)
       
  3226 			{
       
  3227 			// found a non-extant drive, test it...
       
  3228 			_LIT(KBad,"?:\\BADPATH\\*");
       
  3229 			TBuf<16> bad(KBad);
       
  3230 			bad[0] = TUint16('A'+drvNum);
       
  3231 			TInt r=fMan->Delete(bad);
       
  3232 			test(r==KErrNotReady);
       
  3233 			break;
       
  3234 			}
       
  3235 		}
       
  3236 	}
       
  3237 	delete fMan;
       
  3238 
       
  3239 	MakeFile(_L("\\ONE\\TWO\\FILE1.TXT"));
       
  3240 	MakeFile(_L("\\ONE\\TWO\\FOUR"));
       
  3241 	test.Next(_L("Test cyclic copy"));
       
  3242 	if (!gAsynch)
       
  3243 		r=gFileMan->Copy(_L("\\ONE\\TWO\\*"),_L("\\ONE\\TWO\\THREE\\"),CFileMan::ERecurse);
       
  3244 	else
       
  3245 		r=gFileMan->Copy(_L("\\ONE\\TWO\\*"),_L("\\ONE\\TWO\\THREE\\"),CFileMan::ERecurse,gStat);
       
  3246 	test(r==KErrArgument);
       
  3247 
       
  3248 	test.Next(_L("Test src name == trg name"));
       
  3249 	if (!gAsynch)
       
  3250 		{
       
  3251 		r=gFileMan->Copy(_L("\\ONE\\TWO\\FOUR"),_L("\\ONE\\TWO\\FOUR")); // default aSwitch=EOverWrite
       
  3252 		test(r==KErrNone);
       
  3253 		r=gFileMan->Copy(_L("\\ONE\\TWO\\FOUR"),_L("\\ONE\\TWO\\FOUR"), 0);
       
  3254 		test(r==KErrAlreadyExists);
       
  3255 		r=gFileMan->Copy(_L("\\ONE\\TWO\\FOUR"),_L("\\ONE\\TWO\\FOUR"),CFileMan::ERecurse);
       
  3256 		test(r==KErrAlreadyExists);
       
  3257 		r=gFileMan->Copy(_L("\\ONE\\TWO\\F*R"),_L("\\ONE\\TWO\\FOUR"),CFileMan::ERecurse);
       
  3258 		test(r==KErrAlreadyExists);
       
  3259 		}
       
  3260 	else
       
  3261 		{
       
  3262 		r=gFileMan->Copy(_L("\\ONE\\TWO\\*.TXT"),_L("\\ONE\\TWO\\*.TXT"),0,gStat);
       
  3263 		test(r==KErrNone);
       
  3264 		WaitForResult(KErrAlreadyExists);
       
  3265 		r=gFileMan->Copy(_L("\\ONE\\TWO\\FOUR"),_L("\\ONE\\TWO\\F*R"),CFileMan::ERecurse,gStat);
       
  3266 		test(r==KErrNone);
       
  3267 		WaitForResult(KErrNone);
       
  3268 		}
       
  3269 	RmDir(_L("\\ONE\\"));
       
  3270 
       
  3271 	test.Next(_L("Test copy missing source and path"));
       
  3272 	if (!gAsynch)
       
  3273 		{
       
  3274 		r=gFileMan->Copy(_L("\\ONE\\TWO\\XXXYYY"),_L("\\ONE\\TWO\\asdfsadf"));
       
  3275 		test(r==KErrPathNotFound);
       
  3276 		r=gFileMan->Copy(_L("\\ONE\\TWO\\XXXYYY"),_L("\\ONE\\TWO\\asdfsadf"),CFileMan::ERecurse);
       
  3277 		test(r==KErrPathNotFound);
       
  3278 		}
       
  3279 	else
       
  3280 		{
       
  3281 		r=gFileMan->Copy(_L("\\ONE\\TWO\\*.TXT"),_L("\\ONE\\TWO\\*.YYY"),0,gStat);
       
  3282 		test(r==KErrNone);
       
  3283 		WaitForResult(KErrPathNotFound);
       
  3284 		r=gFileMan->Copy(_L("\\ONE\\TWO\\XXXYYY"),_L("\\ONE\\TWO\\asdfsadf"),CFileMan::ERecurse,gStat);
       
  3285 		test(r==KErrNone);
       
  3286 		WaitForResult(KErrPathNotFound);
       
  3287 		}
       
  3288 		
       
  3289 	test.Next(_L("Test copy missing source"));
       
  3290 	if (!gAsynch)
       
  3291 		{
       
  3292 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\*.LPQ"),_L("\\ONE\\TWO\\*.YYY"));
       
  3293 		test(r==KErrNotFound);
       
  3294 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\XXXYYY"),_L("\\ONE\\TWO\\asdfsadf"),CFileMan::ERecurse);
       
  3295 		test(r==KErrNotFound);
       
  3296 		}
       
  3297 	else
       
  3298 		{
       
  3299 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\XXXYYY"),_L("\\ONE\\TWO\\asdfsadf"),0,gStat);
       
  3300 		test(r==KErrNone);
       
  3301 		WaitForResult(KErrNotFound);
       
  3302 		r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\XXXYYY"),_L("\\ONE\\TWO\\asdfsadf"),CFileMan::ERecurse,gStat);
       
  3303 		test(r==KErrNone);
       
  3304 		WaitForResult(KErrNotFound);
       
  3305 		}
       
  3306 		
       
  3307 	RmDir(_L("\\EMPTYSRC\\"));
       
  3308  	MakeDir(_L("\\EMPTYSRC\\"));
       
  3309  	RmDir(_L("\\EMPTYTRG\\"));
       
  3310  	MakeDir(_L("\\EMPTYTRG\\"));
       
  3311  	test.Next(_L("Test copy empty source directory"));
       
  3312  	if (!gAsynch)
       
  3313  		{
       
  3314  		r=gFileMan->Copy(_L("\\EMPTYSRC\\"),_L("\\EMPTYTRG\\"));
       
  3315  		test(r==KErrNotFound);
       
  3316  		r=gFileMan->Copy(_L("\\EMPTYSRC\\"),_L("\\EMPTYTRG\\"), CFileMan::ERecurse);
       
  3317  		test(r==KErrNotFound);
       
  3318  		r=gFileMan->Copy(_L("\\EMPTYSRC"),_L("\\EMPTYTRG\\"));
       
  3319  		test(r==KErrNotFound);
       
  3320  		r=gFileMan->Copy(_L("\\EMPTYSRC"),_L("\\EMPTYTRG\\"), CFileMan::ERecurse);
       
  3321  		test(r==KErrNotFound);
       
  3322  		}
       
  3323  	else
       
  3324  		{
       
  3325  		r=gFileMan->Copy(_L("\\EMPTYSRC\\"),_L("\\EMPTYTRG\\"), 0, gStat);
       
  3326  		test(r==KErrNone);
       
  3327  		WaitForResult(KErrNotFound);
       
  3328  		r=gFileMan->Copy(_L("\\EMPTYSRC\\"),_L("\\EMPTYTRG\\"), CFileMan::ERecurse, gStat);
       
  3329  		test(r==KErrNone);
       
  3330  		WaitForResult(KErrNotFound);
       
  3331  		r=gFileMan->Copy(_L("\\EMPTYSRC"),_L("\\EMPTYTRG\\"), 0, gStat);
       
  3332  		test(r==KErrNone);
       
  3333  		WaitForResult(KErrNotFound);
       
  3334  		r=gFileMan->Copy(_L("\\EMPTYSRC"),_L("\\EMPTYTRG\\"), CFileMan::ERecurse, gStat);
       
  3335  		test(r==KErrNone);
       
  3336  		WaitForResult(KErrNotFound);
       
  3337  		}
       
  3338  	RmDir(_L("\\EMPTYSRC\\"));
       
  3339  	RmDir(_L("\\EMPTYTRG\\"));
       
  3340 	
       
  3341 
       
  3342 	MakeFile(_L("Dummyfile"));
       
  3343 	test.Next(_L("Illegal names"));
       
  3344 	r=gFileMan->Attribs(_L(":C:"),0,0,TTime(0),0);
       
  3345 	test(r==KErrBadName);
       
  3346 	r=gFileMan->Copy(_L(":C:"),_L("newname"),0);
       
  3347 	test(r==KErrBadName);
       
  3348 	r=gFileMan->Copy(_L("Dummyfile"),_L(":C:"),0);
       
  3349 	test(r==KErrBadName);
       
  3350 	r=gFileMan->Delete(_L(":C:"),0);
       
  3351 	test(r==KErrBadName);
       
  3352 	r=gFileMan->Move(_L(":C:"),_L("newname"),0);
       
  3353 	test(r==KErrBadName);
       
  3354 	r=gFileMan->Move(_L("dummyFile"),_L(":C:"),0);
       
  3355 	test(r==KErrBadName);
       
  3356 	r=gFileMan->Rename(_L(":C:"),_L("newname"),0);
       
  3357 	test(r==KErrBadName);
       
  3358 	r=gFileMan->Rename(_L("DummyFile"),_L(":C:"),0);
       
  3359 	test(r==KErrBadName);
       
  3360 	r=gFileMan->RmDir(_L("\\:C:\\"));
       
  3361 	test(r==KErrBadName);
       
  3362 
       
  3363 	r=gFileMan->Attribs(_L("::C:"),0,0,TTime(0),0);
       
  3364 	test(r==KErrBadName);
       
  3365 	r=gFileMan->Copy(_L("::C:"),_L("newname"),0);
       
  3366 	test(r==KErrBadName);
       
  3367 	r=gFileMan->Copy(_L("Dummyfile"),_L("::C:"),0);
       
  3368 	test(r==KErrBadName);
       
  3369 	r=gFileMan->Delete(_L("::C:"),0);
       
  3370 	test(r==KErrBadName);
       
  3371 	r=gFileMan->Move(_L("::C:"),_L("newname"),0);
       
  3372 	test(r==KErrBadName);
       
  3373 	r=gFileMan->Move(_L("dummyFile"),_L("::C:"),0);
       
  3374 	test(r==KErrBadName);
       
  3375 	r=gFileMan->Rename(_L("::C:"),_L("newname"),0);
       
  3376 	test(r==KErrBadName);
       
  3377 	r=gFileMan->Rename(_L("DummyFile"),_L("::C:"),0);
       
  3378 	test(r==KErrBadName);
       
  3379 	r=gFileMan->RmDir(_L("::C:"));
       
  3380 	test(r==KErrBadName);
       
  3381 	r=TheFs.Delete(_L("DummyFile"));
       
  3382 	test(r==KErrNone);
       
  3383 	// test copying two files with identical names that do not exist
       
  3384 	_LIT(KNonExistent,"\\azzzz.txt");
       
  3385 	r=gFileMan->Copy(KNonExistent,KNonExistent,0);
       
  3386 	test(r==KErrNotFound);
       
  3387 	}
       
  3388 
       
  3389 LOCAL_C void TestNameMangling()
       
  3390 //
       
  3391 // Synchronous test of name mangling
       
  3392 //
       
  3393 	{
       
  3394 
       
  3395 	gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\TRG\\"));
       
  3396 	MakeDir(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\TRG\\"));
       
  3397 	MakeFile(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\abc.def"));
       
  3398 	MakeFile(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\abcdefghijk.def"));
       
  3399 	MakeFile(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\abc.defgh"));
       
  3400 	MakeFile(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\abcdefghijk.defgh"));
       
  3401 	MakeFile(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\zyx.abc.def"));
       
  3402 	MakeFile(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\zyx.abcdefghijk.def"));
       
  3403 	MakeFile(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\zyx.abc.defgh"));
       
  3404 	MakeFile(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\zyx.abcdefghijk.defgh"));
       
  3405 
       
  3406 	TInt r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\*.*"),_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\TRG\\*.*"));
       
  3407 	test(r==KErrNone);
       
  3408 	Compare(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\*"),_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\TRG\\*"));
       
  3409 	r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\TRG\\*.*"));
       
  3410 	test(r==KErrNone);
       
  3411 	}
       
  3412 
       
  3413 LOCAL_C void TestLongNames()
       
  3414 //
       
  3415 // Synchronous test of name mangling
       
  3416 //
       
  3417 	{
       
  3418 #if defined(__WINS__)
       
  3419 	if (gSessionPath[0]=='C')
       
  3420 		return;
       
  3421 #endif
       
  3422 
       
  3423 	gFileMan->SetObserver(NULL);
       
  3424 	
       
  3425 	// Format the current drive
       
  3426 	Format(CurrentDrive());
       
  3427 	// Create Session Path
       
  3428 	CreateTestDirectory(_L("\\F32-TST\\TFMAN\\"));
       
  3429 	
       
  3430 	// Create 2 root directories with very long names
       
  3431 	TInt longFileLength = KMaxFileName-4;
       
  3432 	test.Next(_L("Test methods on long names"));
       
  3433 	TFileName longFileNameA;
       
  3434 	longFileNameA.SetLength(longFileLength);
       
  3435 	longFileNameA.Fill('A',longFileLength);
       
  3436 	TFileName longRootDirNameA=_L("\\");
       
  3437 	longRootDirNameA+=longFileNameA;
       
  3438 	longRootDirNameA+=_L("\\");
       
  3439 	TInt r=TheFs.MkDir(longRootDirNameA);
       
  3440 	test(r==KErrNone || r==KErrAlreadyExists);
       
  3441 	// Second folder
       
  3442 	TFileName longFileNameB;
       
  3443 	longFileNameB.SetLength(longFileLength);
       
  3444 	longFileNameB.Fill('B',longFileLength);
       
  3445 	TFileName longRootDirNameB=_L("\\");
       
  3446 	longRootDirNameB+=longFileNameB;
       
  3447 	longRootDirNameB+=_L("\\");
       
  3448 	r=TheFs.MkDir(longRootDirNameB);
       
  3449 	test(r==KErrNone || r==KErrAlreadyExists);
       
  3450 	
       
  3451 	TInt longFilePtrLength = KMaxFileName-3; // We do not want the trailing backslash
       
  3452 	TPtrC ptrLongFileA(longRootDirNameA.Ptr(),longFilePtrLength);
       
  3453 	TPtrC ptrLongFileB(longRootDirNameB.Ptr(),longFilePtrLength);
       
  3454 	
       
  3455 	// TInt CFileMan::Move(const TDesC& anOld,const TDesC& aNew,TUint aSwitch=EOverWrite);
       
  3456 	// Tries to move a folder with a long name into another
       
  3457 	// This test will return KErrGeneral because the new path will exceed the maximum length
       
  3458 	// See KMaxFileName
       
  3459 	r=gFileMan->Move(ptrLongFileA,ptrLongFileB);
       
  3460 	test(r==KErrGeneral);
       
  3461 	
       
  3462 	r=gFileMan->RmDir(longRootDirNameA);
       
  3463 	test(r==KErrNone);
       
  3464 	r=gFileMan->Rename(ptrLongFileB,ptrLongFileA);
       
  3465 	test(r==KErrNone);
       
  3466 	r=gFileMan->RmDir(longRootDirNameB);
       
  3467 	test(r==KErrPathNotFound);
       
  3468 	r=gFileMan->RmDir(longRootDirNameA);
       
  3469 	test(r==KErrNone);
       
  3470 
       
  3471 
       
  3472 	TFileName longSubDirName=_L("\\Files\\");
       
  3473 	TPtrC longSubDirFileName(longFileNameA.Ptr(),longFilePtrLength-longSubDirName.Length());
       
  3474 	longSubDirName+=longSubDirFileName;
       
  3475 	longSubDirName+=_L("\\");
       
  3476 	r=TheFs.MkDirAll(longSubDirName);
       
  3477 	test(r==KErrNone);
       
  3478 
       
  3479 	CDir* dirList;
       
  3480 	r=TheFs.GetDir(longSubDirName,KEntryAttMaskSupported,0,dirList);
       
  3481 	test(r==KErrNone);
       
  3482 	test(dirList->Count()==0);
       
  3483 	delete dirList;
       
  3484 
       
  3485 
       
  3486 	TPtrC ptrLongSubDirSrc(longSubDirName.Ptr(),longSubDirName.Length()-1);
       
  3487 	TPtrC ptrLongSubDirTrg(longRootDirNameA.Ptr(),longRootDirNameA.Length()-1);
       
  3488 	r=gFileMan->Copy(ptrLongSubDirSrc,ptrLongSubDirTrg);
       
  3489 	test(r==KErrNone);
       
  3490 	r=TheFs.MkDir(longRootDirNameB);
       
  3491 	test(r==KErrNone);
       
  3492 	r=gFileMan->Move(ptrLongSubDirSrc,longRootDirNameB);
       
  3493 	test(r==KErrBadName);
       
  3494 	r=TheFs.RmDir(longRootDirNameB);
       
  3495 	test(r==KErrNone);
       
  3496 	test(TheFs.RmDir(longSubDirName) == KErrNone);
       
  3497 	test(TheFs.RmDir(_L("\\Files\\")) == KErrNone);
       
  3498 	gFileMan->SetObserver(gObserver);
       
  3499 	}
       
  3500 
       
  3501 LOCAL_C void TestFileAttributes()
       
  3502 //
       
  3503 // Test file attributes are copied and new settings
       
  3504 //
       
  3505 	{
       
  3506 
       
  3507 	gFileMan->Delete(_L("\\F32-TST\\TFMAN\\FILEATT\\TRG\\*.*"));
       
  3508 	MakeDir(_L("\\F32-TST\\TFMAN\\FILEATT\\TRG\\"));
       
  3509 	MakeFile(_L("\\F32-TST\\TFMAN\\FILEATT\\SRC\\readonly.def"),KEntryAttReadOnly);
       
  3510 	MakeFile(_L("\\F32-TST\\TFMAN\\FILEATT\\SRC\\readonlyhidden.def"),KEntryAttReadOnly|KEntryAttHidden);
       
  3511 	MakeFile(_L("\\F32-TST\\TFMAN\\FILEATT\\SRC\\hiddensystem.def"),KEntryAttHidden|KEntryAttSystem);
       
  3512 	MakeFile(_L("\\F32-TST\\TFMAN\\FILEATT\\SRC\\systemarchive.def"),KEntryAttArchive|KEntryAttSystem);
       
  3513 
       
  3514 	TInt r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\FILEATT\\SRC\\*.*"),_L("\\F32-TST\\TFMAN\\FILEATT\\TRG\\*.*"));
       
  3515 	test(r==KErrNone);
       
  3516 	Compare(_L("\\F32-TST\\TFMAN\\FILEATT\\SRC\\*.*"),_L("\\F32-TST\\TFMAN\\FILEATT\\TRG\\*"));
       
  3517 	r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\FILEATT\\SRC\\*"),0,KEntryAttReadOnly,TTime(0));
       
  3518 	test(r==KErrNone);
       
  3519 	r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\FILEATT\\TRG\\*"),0,KEntryAttReadOnly,TTime(0));
       
  3520 	test(r==KErrNone);
       
  3521 	r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\FILEATT\\"));
       
  3522 	test(r==KErrNone);
       
  3523 	}	
       
  3524 
       
  3525 class CFileManObserverContinue : public CBase, public MFileManObserver
       
  3526 	{
       
  3527 public:
       
  3528 	CFileManObserverContinue(CFileMan* aFileMan);
       
  3529 	TControl NotifyFileManEnded();
       
  3530 private:
       
  3531 	CFileMan* iFileMan;
       
  3532 	};
       
  3533 
       
  3534 
       
  3535 CFileManObserverContinue::CFileManObserverContinue(CFileMan* aFileMan)
       
  3536 //
       
  3537 // Constructor
       
  3538 //
       
  3539 	{
       
  3540 
       
  3541 	__DECLARE_NAME(_S("CFileManObserverOverWrite"));
       
  3542 	iFileMan=aFileMan;
       
  3543 	}
       
  3544 
       
  3545 
       
  3546 MFileManObserver::TControl CFileManObserverContinue::NotifyFileManEnded()
       
  3547 //
       
  3548 // Observer for testoverwrite tests
       
  3549 //
       
  3550 	{
       
  3551 
       
  3552 	return(MFileManObserver::EContinue);
       
  3553 	}
       
  3554 
       
  3555 LOCAL_C void TestCopyOpenFile()
       
  3556 //
       
  3557 // Copy a file while it is open
       
  3558 //
       
  3559 	{
       
  3560 
       
  3561 	test.Next(_L("Copying open files"));
       
  3562 
       
  3563 	CFileManObserverContinue* fManObserver=new(ELeave) CFileManObserverContinue(gFileMan);
       
  3564 	gFileMan->SetObserver(fManObserver);
       
  3565 
       
  3566 	TBuf<256> contents;
       
  3567 	TPtrC8 bufPtr;
       
  3568 	CreateLongName(contents,gSeed,256);
       
  3569 	bufPtr.Set((TUint8*)contents.Ptr(),contents.Size());
       
  3570 
       
  3571 	MakeFile(_L("\\F32-TST\\TFMAN\\FILECOPY\\asdf.asdf"),bufPtr);
       
  3572 	RFile f;
       
  3573 	TInt r=f.Open(TheFs,_L("\\F32-TST\\TFMAN\\FILECOPY\\asdf.asdf"),EFileRead|EFileShareReadersOnly);
       
  3574 	test(r==KErrNone);
       
  3575 	r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\FILECOPY\\asdf.asdf"),_L("\\F32-TST\\TFMAN\\FILECOPY\\xxxx.xxxx"));
       
  3576 	test(r==KErrNone);
       
  3577 	f.Close();
       
  3578 	r=f.Open(TheFs,_L("\\F32-TST\\TFMAN\\FILECOPY\\xxxx.xxxx"),EFileRead);
       
  3579 	test(r==KErrNone);
       
  3580 	TBuf8<256*sizeof(TText)> temp;
       
  3581 	r=f.Read(temp);
       
  3582 	test(r==KErrNone);
       
  3583 	test(temp==bufPtr);
       
  3584 	r=f.Read(temp);
       
  3585 	test(r==KErrNone);
       
  3586 	test(temp.Length()==0);
       
  3587 	f.Close();
       
  3588 
       
  3589 	r=f.Open(TheFs,_L("\\F32-TST\\TFMAN\\FILECOPY\\asdf.asdf"),EFileRead);
       
  3590 	test(r==KErrNone);
       
  3591 	r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\FILECOPY\\asdf.asdf"),_L("\\F32-TST\\TFMAN\\FILECOPY\\xxxx.xxxx"));
       
  3592 	test(r==KErrInUse);
       
  3593 	f.Close();
       
  3594 
       
  3595 	gFileMan->SetObserver(gObserver);
       
  3596 	r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\FILECOPY\\"));
       
  3597 	test(r==KErrNone);
       
  3598 	delete fManObserver;
       
  3599 	}
       
  3600 
       
  3601 void TestINC101844()
       
  3602 	{
       
  3603 	_LIT(KDest,"C:\\DEST101844\\");
       
  3604 	TBuf<64> source;
       
  3605 	source.Format(_L("%c:\\INC101844\\"), (TUint) gDriveToTest);
       
  3606 	TBuf<64> src;
       
  3607 	RmDir(source);
       
  3608 	RmDir(KDest);
       
  3609 	MakeDir(KDest);
       
  3610 	TInt r;
       
  3611 		
       
  3612 	src = source;
       
  3613 	src.Append(_L("file1"));
       
  3614 	MakeFile(src, _L8("blah"));
       
  3615 	TheFs.SetAtt(src, KEntryAttReadOnly, 0);
       
  3616 	src = source;
       
  3617 	src.Append(_L("file2"));
       
  3618 	MakeFile(src, _L8("blah"));
       
  3619 	TheFs.SetAtt(src, KEntryAttHidden, 0);
       
  3620 	src = source;
       
  3621 	src.Append(_L("file3"));
       
  3622 	MakeFile(src, _L8("blah"));
       
  3623 	TheFs.SetAtt(src, KEntryAttSystem, 0);
       
  3624 	src = source;
       
  3625 	src.Append(_L("subdir1\\file4"));
       
  3626 	MakeFile(src, _L8("blah"));
       
  3627 	TheFs.SetAtt(src, KEntryAttArchive, 0);
       
  3628 	src = source;
       
  3629 	src.Append(_L("subdir1"));
       
  3630 	TheFs.SetAtt(src, KEntryAttSystem | KEntryAttHidden, KEntryAttArchive);
       
  3631 
       
  3632 	r = gFileMan->Move(source, KDest, 0);
       
  3633 	test(r==KErrNone);
       
  3634 	
       
  3635 	TEntry entry;
       
  3636 	src = KDest;
       
  3637 	src.Append(_L("file1"));
       
  3638 	r = TheFs.Entry(src, entry);
       
  3639 	test(r == KErrNone);
       
  3640 	test(entry.iAtt&KEntryAttReadOnly);
       
  3641 
       
  3642 	src = KDest;
       
  3643 	src.Append(_L("file2"));
       
  3644 	r = TheFs.Entry(src, entry);
       
  3645 	test(r == KErrNone);
       
  3646 	test(entry.iAtt&KEntryAttHidden);
       
  3647 
       
  3648 	src = KDest;
       
  3649 	src.Append(_L("file3"));
       
  3650 	r = TheFs.Entry(src, entry);
       
  3651 	test(r == KErrNone);
       
  3652 	test(entry.iAtt&KEntryAttSystem);
       
  3653 
       
  3654 	src = source;
       
  3655 	src.Append(_L("subdir1\\"));
       
  3656 	r = gFileMan->Move(src, source, 0);
       
  3657 	test(r == KErrNone);
       
  3658 
       
  3659 	r = TheFs.RmDir(src);
       
  3660 	test(r==KErrNone);
       
  3661 	src = source;
       
  3662 	src.Append(_L("file4"));
       
  3663 	r = TheFs.Delete(src);
       
  3664 	test(r==KErrNone);
       
  3665 	r = TheFs.RmDir(source);
       
  3666 	test(r==KErrNone);
       
  3667 	RmDir(KDest);	
       
  3668 	}
       
  3669 
       
  3670 LOCAL_C void TestMoveAcrossDrives()
       
  3671 //
       
  3672 // Move a file from C: to the target drive
       
  3673 //
       
  3674 	{
       
  3675 
       
  3676 	test.Next(_L("Move across drives"));
       
  3677 
       
  3678 	TFileName trgDrive   = _L("\\");
       
  3679 	TFileName trgFile    = _L("\\Sketch");
       
  3680 	TFileName trgDir     = _L("\\DRIVEMOVE\\");
       
  3681 	TFileName trgDirFile = _L("\\DRIVEMOVE\\Sketch");
       
  3682 
       
  3683 	if (gSessionPath[0]=='C')
       
  3684 		{
       
  3685 #if !defined(__WINS__)
       
  3686 		trgDrive   = _L("D:\\");
       
  3687 		trgFile    = _L("D:\\Sketch");
       
  3688 		trgDir     = _L("D:\\DRIVEMOVE\\");
       
  3689 		trgDirFile = _L("D:\\DRIVEMOVE\\Sketch");
       
  3690 #else
       
  3691 		trgDrive   = _L("Y:\\");
       
  3692 		trgFile    = _L("Y:\\Sketch");
       
  3693 		trgDir     = _L("Y:\\DRIVEMOVE\\");
       
  3694 		trgDirFile = _L("Y:\\DRIVEMOVE\\Sketch");
       
  3695 #endif
       
  3696 		}
       
  3697 
       
  3698 	RmDir(trgDir);
       
  3699 	RmDir(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\"));
       
  3700 
       
  3701 	MakeFile(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\Sketch"));
       
  3702 		
       
  3703 	// Move Sketch from the source to target
       
  3704 	gFileMan->Move(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\Sketch"),trgDrive);
       
  3705 	// Check Sketch no longer exists on source drive
       
  3706 	CheckFileExists(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\Sketch"),KErrNotFound);
       
  3707 	// Check Sketch exists on target drive
       
  3708 	CheckFileExists(trgFile,KErrNone);
       
  3709 
       
  3710 	MakeFile(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\Sketch"));
       
  3711 	// Move Directory DRIVEMOVE from the source to target
       
  3712 	gFileMan->Move(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE"),trgDrive);
       
  3713 	// Check DRIVEMOVE no longer exists on source drive
       
  3714 	CheckFileExists(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\Sketch"),KErrPathNotFound);
       
  3715 	// Check Sketch exists on target drive
       
  3716 	CheckFileExists(trgDirFile,KErrNone);
       
  3717 
       
  3718 	RmDir(trgDir);
       
  3719 	test(TheFs.Delete(trgFile) == KErrNone);	
       
  3720 
       
  3721 	TestINC101844();
       
  3722 	}
       
  3723 
       
  3724 class CFileManObserverCopyAbort : public CBase, public MFileManObserver
       
  3725 	{
       
  3726 public:
       
  3727 	CFileManObserverCopyAbort(CFileMan* aFileMan);
       
  3728 	TControl NotifyFileManEnded();
       
  3729 	void SetAbortStep(TInt aAbortStep);
       
  3730 private:
       
  3731 	CFileMan* iFileMan;
       
  3732 	TInt iCurrentStep;
       
  3733 	};
       
  3734 
       
  3735 
       
  3736 CFileManObserverCopyAbort::CFileManObserverCopyAbort(CFileMan* aFileMan)
       
  3737 //
       
  3738 // Constructor
       
  3739 //
       
  3740 	: iFileMan(aFileMan),
       
  3741 	  iCurrentStep(0)
       
  3742 	{
       
  3743 	__DECLARE_NAME(_S("CFileManObserverCopyAbort"));
       
  3744 	}
       
  3745 
       
  3746 
       
  3747 void CFileManObserverCopyAbort::SetAbortStep(TInt aAbortStep)
       
  3748 //
       
  3749 // Set the step at which to cancel the operation
       
  3750 //
       
  3751 	{
       
  3752 	iCurrentStep = aAbortStep;
       
  3753 	}
       
  3754 
       
  3755 
       
  3756 MFileManObserver::TControl CFileManObserverCopyAbort::NotifyFileManEnded()
       
  3757 //
       
  3758 // Observer for testoverwrite tests
       
  3759 //
       
  3760 	{
       
  3761 
       
  3762 	TInt lastError = iFileMan->GetLastError();
       
  3763 	test(lastError == KErrNone);
       
  3764 
       
  3765 	TFileName srcfile;
       
  3766 	iFileMan->GetCurrentSource(srcfile);
       
  3767 	
       
  3768 	TInt action = iFileMan->CurrentAction();
       
  3769 	test(action == CFileMan::EMove   ||
       
  3770 		 action == CFileMan::EDelete ||
       
  3771 		 action == CFileMan::ERmDir);
       
  3772 		
       
  3773 	iCurrentStep--;
       
  3774 	return(iCurrentStep ? MFileManObserver::EContinue : MFileManObserver::EAbort);
       
  3775 	}
       
  3776 
       
  3777 LOCAL_C void TestAbortedMoveAcrossDrives()
       
  3778 //
       
  3779 // Move a file from C: to Y:, and test various cancel conditions
       
  3780 //
       
  3781 	{
       
  3782 
       
  3783 	test.Next(_L("Cancel Move across drives"));
       
  3784 
       
  3785 	const TInt KNumFiles = 5;
       
  3786 
       
  3787 	TFileName trgDirRoot = _L("\\F32-TST\\TFMAN\\");
       
  3788 	TFileName trgDirFull = _L("\\F32-TST\\TFMAN\\CANCELMOVE\\");
       
  3789 	TFileName trgDirFile = _L("\\F32-TST\\TFMAN\\CANCELMOVE\\FILE");
       
  3790 
       
  3791 	if (gSessionPath[0]=='C')
       
  3792 		{
       
  3793 #if !defined(__WINS__)
       
  3794 		trgDirRoot = _L("D:\\F32-TST\\TFMAN\\");
       
  3795 		trgDirFull = _L("D:\\F32-TST\\TFMAN\\CANCELMOVE\\");
       
  3796         trgDirFile = _L("D:\\F32-TST\\TFMAN\\CANCELMOVE\\FILE");
       
  3797 #else
       
  3798 		trgDirRoot = _L("Y:\\F32-TST\\TFMAN\\");
       
  3799 		trgDirFull = _L("Y:\\F32-TST\\TFMAN\\CANCELMOVE\\");
       
  3800         trgDirFile = _L("Y:\\F32-TST\\TFMAN\\CANCELMOVE\\FILE");
       
  3801 #endif
       
  3802 		}
       
  3803 
       
  3804 	gFileMan->RmDir(_L("C:\\F32-TST\\TFMAN\\CANCELMOVE\\"));
       
  3805 
       
  3806 	CFileManObserverCopyAbort* fManObserver=new(ELeave) CFileManObserverCopyAbort(gFileMan);
       
  3807 	CleanupStack::PushL(fManObserver);
       
  3808 
       
  3809 // Check that source files exist when interrupting the copy step
       
  3810 	TInt step = 0;
       
  3811 	TInt i = 0;
       
  3812 	for(step = 1; step <= KNumFiles+1; ++step)
       
  3813 		{
       
  3814 		for (i = 0; i < KNumFiles; i++)
       
  3815 			{
       
  3816 			TFileName sourceFile =_L("C:\\F32-TST\\TFMAN\\CANCELMOVE\\FILE");
       
  3817 			sourceFile.AppendNum(i);
       
  3818             sourceFile.Append(_L(".TXT"));
       
  3819 			MakeFile(sourceFile);
       
  3820 			}
       
  3821 
       
  3822 		gFileMan->RmDir(trgDirFull);
       
  3823 
       
  3824 		fManObserver->SetAbortStep(step);
       
  3825 		gFileMan->SetObserver(fManObserver);
       
  3826 	
       
  3827 		TInt r;
       
  3828 		if (!gAsynch)
       
  3829 			r=gFileMan->Move(_L("C:\\F32-TST\\TFMAN\\CANCELMOVE"),trgDirRoot, CFileMan::EOverWrite);
       
  3830 		else
       
  3831 			r=gFileMan->Move(_L("C:\\F32-TST\\TFMAN\\CANCELMOVE"),trgDirRoot, CFileMan::EOverWrite, gStat);
       
  3832 		
       
  3833 		TestResult(r, (step <= KNumFiles) ? KErrCancel : KErrNone);
       
  3834 
       
  3835 		gFileMan->SetObserver(NULL);
       
  3836 		
       
  3837 		// Check that the expected target files exist...
       
  3838 		CheckFileExists(trgDirFull, KErrNone, EFalse);
       
  3839 		for (i = 0; i < Min(step, KNumFiles); i++)
       
  3840 			{
       
  3841 			TFileName trgAfterFile = trgDirFile;
       
  3842 			trgAfterFile.AppendNum(i);
       
  3843             trgAfterFile.Append(_L(".TXT"));
       
  3844 			CheckFileExists(trgAfterFile, KErrNone);
       
  3845 			}
       
  3846 
       
  3847 		// Check that the expected source files still exist after the abort...
       
  3848 		CheckFileExists(_L("C:\\F32-TST\\TFMAN\\CANCELMOVE\\"), (step <= KNumFiles) ? KErrNone : KErrNotFound, EFalse);
       
  3849 		for (; i < KNumFiles; i++)
       
  3850 			{
       
  3851 			TFileName srcAfterFile =_L("C:\\F32-TST\\TFMAN\\CANCELMOVE\\FILE");
       
  3852 			srcAfterFile.AppendNum(i);
       
  3853             srcAfterFile.Append(_L(".TXT"));
       
  3854 			CheckFileExists(srcAfterFile, KErrNone);
       
  3855 			}
       
  3856 		}
       
  3857 	
       
  3858 	gFileMan->SetObserver(NULL);
       
  3859 	CleanupStack::PopAndDestroy();
       
  3860 	
       
  3861 	RmDir(trgDirRoot); // "?:\\F32-TST\\TFMAN\\"
       
  3862 	TheFs.RmDir(trgDirRoot.Left(16));
       
  3863 	TheFs.RmDir(trgDirRoot.Left(10));
       
  3864 	TheFs.RmDir(_L("C:\\F32-TST\\TFMAN\\"));
       
  3865 	TheFs.RmDir(_L("C:\\F32-TST\\"));
       
  3866 	}
       
  3867 
       
  3868 
       
  3869 LOCAL_C void TestMoveEmptyDirectory()
       
  3870 //
       
  3871 //	"Try to move an empty directory C:\F32-TST\TFMAN\DRIVEMOVE\ to C:\"
       
  3872 //
       
  3873 	{
       
  3874 
       
  3875 	test.Next(_L("Move empty directory"));
       
  3876 
       
  3877 #if !defined(__WINS__)
       
  3878 	TFileName trgDrive=_L("D:\\");
       
  3879 #else
       
  3880 	if (gSessionPath[0]!='C')
       
  3881 		return;
       
  3882 	TFileName trgDrive=_L("C:\\");
       
  3883 #endif
       
  3884 
       
  3885 	MakeDir(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\"));
       
  3886 	TInt r=gFileMan->Move(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\*"),trgDrive,CFileMan::ERecurse);
       
  3887 	test (r==KErrNotFound);
       
  3888 	}
       
  3889 
       
  3890 LOCAL_C void TestCopyAndRename()
       
  3891 //
       
  3892 // Rename while copying files and directories
       
  3893 //
       
  3894 	{
       
  3895 	test.Next(_L("Rename while copying files and directories"));
       
  3896 	gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\CPMV"));
       
  3897 	MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\ONE\\ONE_1.TXT"));
       
  3898 	MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\ONE\\ONE_2.TXT"));
       
  3899 	MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\ONE\\ONE_3.TXT"));
       
  3900 	MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\ONE\\TWOTWO.TWO"));
       
  3901 	MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\ONE_4.TXT"));
       
  3902 	MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\ONE_5.TXT"));
       
  3903 	MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\TWO.TXT"));
       
  3904 	MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\TWO.GOD"));
       
  3905 	MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\TWO.BAD"));
       
  3906 
       
  3907 	TInt r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\TWO.*"), _L("\\F32-TST\\TFMAN\\THREE.*"), CFileMan::ERecurse);
       
  3908 	test(r==KErrNone);
       
  3909 
       
  3910 	CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE.TXT"), KErrNone);
       
  3911 	CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE.GOD"), KErrNone);
       
  3912 	CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE.BAD"), KErrNone);
       
  3913 	r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\CPMV\\THREE.*"));
       
  3914 	test(r==KErrNone);
       
  3915 
       
  3916 	MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\TWO2\\TWO__1.TXT"));
       
  3917 	MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\TWO2\\TWO__2.TXT"));
       
  3918 
       
  3919 // copy and rename dir
       
  3920 	r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\CPMV\\TWO2"), _L("\\F32-TST\\TFMAN\\CPMV\\THREE"), CFileMan::ERecurse);
       
  3921 	test(r==KErrNone);
       
  3922 	Compare(_L("\\F32-TST\\TFMAN\\CPMV\\TWO2\\*"), _L("\\F32-TST\\TFMAN\\CPMV\\THREE\\*"));
       
  3923 
       
  3924 // copy and move into another dir
       
  3925 	r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\CPMV\\TWO2"), _L("\\F32-TST\\TFMAN\\CPMV\\THREE\\TWO"), CFileMan::ERecurse);
       
  3926 	test(r==KErrNone);
       
  3927 	Compare(_L("\\F32-TST\\TFMAN\\CPMV\\TWO2\\*"), _L("\\F32-TST\\TFMAN\\CPMV\\THREE\\TWO\\*"));
       
  3928 
       
  3929 // copy and rename files and dirs in current dir
       
  3930 	r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\CPMV\\TWO*"), _L("\\F32-TST\\TFMAN\\CPMV\\THREE*"), CFileMan::ERecurse);
       
  3931 	test(r==KErrNone);
       
  3932 //	Compare(_L("\\F32-TST\\TFMAN\\CPMV\\TWO2\\*"), _L("\\F32-TST\\TFMAN\\CPMV\\THREE2\\*"));
       
  3933 
       
  3934 	CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\ONE\\THREEO.TWO"), KErrNone);
       
  3935 	CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE\\TWO__1.TXT"), KErrNone);
       
  3936 	CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE\\TWO__2.TXT"), KErrNone);
       
  3937 	CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE.TXT"), KErrNone);
       
  3938 	CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE.BAD"), KErrNone);
       
  3939 	CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE.GOD"), KErrNone);
       
  3940 	CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE\\THREE1.TXT"), KErrNone);
       
  3941 	CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE\\THREE2.TXT"), KErrNone);
       
  3942 	
       
  3943 	gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\CPMV\\"));
       
  3944 	}
       
  3945 
       
  3946 void TestStackUsage(TInt aLevel, TThreadStackInfo& aStack)
       
  3947 	{
       
  3948 	// DEF104115
       
  3949 	_LIT(KDir, "\\DEF104115\\");
       
  3950 	_LIT(KFile1,   "\\DEF104115\\file1veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryverylong.txt");
       
  3951 	_LIT(KFile2,   "\\DEF104115\\SUBDIR\\longfile2.txt");
       
  3952 	
       
  3953 	if(aLevel==0)
       
  3954 		{
       
  3955 		test.Next(_L("Test stack usage"));
       
  3956 		RmDir(KDir);
       
  3957 		MakeFile(KFile1, _L8("123456789012345678901234567890"));
       
  3958 		MakeFile(KFile2);
       
  3959 		}
       
  3960 	TInt r = KErrNone;
       
  3961 	char* start = NULL;
       
  3962 	char* end = NULL;
       
  3963 	TInt available = 0;
       
  3964 	TInt stacksize = aStack.iBase - aStack.iLimit;
       
  3965 	start = (char*)aStack.iLimit;
       
  3966 	end = (char*)&stacksize;
       
  3967 	available = (TInt)end - (TInt)start;
       
  3968 #ifdef __X86__
       
  3969 	if(available > 6 * 1024) // X86 uses about twice as much stack as ARM in debug mode, so double the number.
       
  3970 #else
       
  3971 	if(available > 3 * 1024) // don't touch this constant ... fix CFileMan instead!!
       
  3972 #endif
       
  3973 		{
       
  3974 		TestStackUsage(aLevel+1, aStack);
       
  3975 		return;
       
  3976 		}
       
  3977 		
       
  3978 	test.Printf(_L("Level:%d Available:%d\n"), aLevel, available);
       
  3979 	
       
  3980 	gFileMan->SetObserver(NULL);
       
  3981 	// Attribs
       
  3982 	r = gFileMan->Attribs(KDir, 0, 0, 0, CFileMan::ERecurse);
       
  3983 	test(r==KErrNone);
       
  3984 
       
  3985 	// Move
       
  3986 	r = gFileMan->Move(KFile1, KFile2, CFileMan::ERecurse);
       
  3987 	test(r==KErrAlreadyExists);
       
  3988 
       
  3989 	r = gFileMan->Move(KFile1, KFile2, CFileMan::ERecurse | CFileMan::EOverWrite);
       
  3990 	test(r==KErrNone);
       
  3991 
       
  3992 	// Copy
       
  3993 	r = gFileMan->Copy(KFile2, KFile1, CFileMan::ERecurse);
       
  3994 	test(r==KErrNone);
       
  3995 
       
  3996 	// Rename
       
  3997 	r = gFileMan->Rename(KFile1, KFile2, 0);
       
  3998 	test(r==KErrAlreadyExists);
       
  3999 
       
  4000 	r = gFileMan->Rename(KFile1, KFile2, CFileMan::EOverWrite);
       
  4001 	test(r==KErrNone);
       
  4002 
       
  4003 	// Delete
       
  4004 	r = gFileMan->Delete(KFile2, CFileMan::ERecurse);
       
  4005 	test(r==KErrNone);
       
  4006 
       
  4007 	// RmDir
       
  4008 	r = gFileMan->RmDir(KDir);
       
  4009 	test(r==KErrNone);
       
  4010 	
       
  4011 	gFileMan->SetObserver(gObserver);
       
  4012 	}
       
  4013 
       
  4014 LOCAL_C void InitialiseL()
       
  4015 //
       
  4016 // Set up test variables
       
  4017 //
       
  4018 	{
       
  4019 
       
  4020 	gFileMan=CFileMan::NewL(TheFs);
       
  4021 	gObserver=new(ELeave) CFileManObserver(gFileMan);
       
  4022 	gFileMan->SetObserver(gObserver);
       
  4023 	}
       
  4024 
       
  4025 LOCAL_C void Cleanup()
       
  4026 //
       
  4027 // Cleanup test variables
       
  4028 //
       
  4029 	{
       
  4030 
       
  4031 	delete gFileMan;
       
  4032 	delete gObserver;
       
  4033 	}
       
  4034 	
       
  4035 LOCAL_C void SetupDirStructure(TFileName& aSrcPath,TFileName& aTrgPath)
       
  4036 	{
       
  4037 	TFileName tmpName = aSrcPath;
       
  4038 	
       
  4039 	// Create the TrgPath dirs
       
  4040 	MakeDir(aTrgPath);
       
  4041 	
       
  4042 	// Create the aSrcPath dirs
       
  4043 	tmpName = aSrcPath;
       
  4044 	tmpName.Append(_L("EmptyDir01\\"));
       
  4045 	MakeDir(tmpName);
       
  4046 	
       
  4047 	tmpName = aSrcPath;
       
  4048 	tmpName.Append(_L("EmptyDir02\\"));
       
  4049 	MakeDir(tmpName);
       
  4050 	
       
  4051 	tmpName = aSrcPath;
       
  4052 	tmpName.Append(_L("EmptyDir03\\"));
       
  4053 	MakeDir(tmpName);
       
  4054 
       
  4055 	tmpName = aSrcPath;
       
  4056 	tmpName.Append(_L("FILE01.TXT"));
       
  4057 	MakeFile(tmpName);
       
  4058 	
       
  4059 	tmpName = aSrcPath;
       
  4060 	tmpName.Append(_L("FILE02.TXT"));
       
  4061 	MakeFile(tmpName);
       
  4062 	
       
  4063 	tmpName = aSrcPath;
       
  4064 	tmpName.Append(_L("FILE03.TXT"));
       
  4065 	MakeFile(tmpName);
       
  4066 	
       
  4067 	tmpName = aSrcPath;
       
  4068 	tmpName.Append(_L("SubDir01\\EmptyDir01\\"));
       
  4069 	MakeDir(tmpName);
       
  4070 	
       
  4071 	tmpName = aSrcPath;
       
  4072 	tmpName.Append(_L("SubDir02\\EmptyDir02\\"));
       
  4073 	MakeDir(tmpName);
       
  4074 	
       
  4075 	tmpName = aSrcPath;
       
  4076 	tmpName.Append(_L("SubDir03\\EmptyDir03\\"));
       
  4077 	MakeDir(tmpName);
       
  4078 
       
  4079 	tmpName = aSrcPath;
       
  4080 	tmpName.Append(_L("SubDir01\\FILE01.TXT"));
       
  4081 	MakeFile(tmpName);
       
  4082 	
       
  4083 	tmpName = aSrcPath;
       
  4084 	tmpName.Append(_L("SubDir01\\FILE02.TXT"));
       
  4085 	MakeFile(tmpName);
       
  4086 	
       
  4087 	tmpName = aSrcPath;
       
  4088 	tmpName.Append(_L("SubDir01\\FILE03.TXT"));
       
  4089 	MakeFile(tmpName);
       
  4090 	
       
  4091 	tmpName = aSrcPath;
       
  4092 	tmpName.Append(_L("SubDir02\\FILE01.TXT"));
       
  4093 	MakeFile(tmpName);
       
  4094 	
       
  4095 	tmpName = aSrcPath;
       
  4096 	tmpName.Append(_L("SubDir02\\FILE02.TXT"));
       
  4097 	MakeFile(tmpName);
       
  4098 	
       
  4099 	tmpName = aSrcPath;
       
  4100 	tmpName.Append(_L("SubDir02\\FILE03.TXT"));
       
  4101 	MakeFile(tmpName);
       
  4102 	
       
  4103 	tmpName = aSrcPath;
       
  4104 	tmpName.Append(_L("SubDir03\\FILE01.TXT"));
       
  4105 	MakeFile(tmpName);
       
  4106 	
       
  4107 	tmpName = aSrcPath;
       
  4108 	tmpName.Append(_L("SubDir03\\FILE02.TXT"));
       
  4109 	MakeFile(tmpName);
       
  4110 	
       
  4111 	tmpName = aSrcPath;
       
  4112 	tmpName.Append(_L("SubDir03\\FILE03.TXT"));
       
  4113 	MakeFile(tmpName);
       
  4114 	}
       
  4115 	
       
  4116 LOCAL_C void TestPDEF112148()
       
  4117 	{
       
  4118 	test.Next(_L("++TestPDEF112148 : \n"));
       
  4119 	
       
  4120 	TInt err = 0;
       
  4121 	
       
  4122 	TFileName trgPath;
       
  4123 	trgPath.Format(_L("%c:\\F32-TST\\TFMAN\\PDEF112148\\dest\\"), (TUint8)gDriveToTest);
       
  4124 	TFileName srcPath = _L("C:\\F32-TST\\TFMAN\\PDEF112148\\src\\");
       
  4125 		
       
  4126 	// Non-Recursive move
       
  4127 	// clean up before testing
       
  4128 	RmDir(srcPath);
       
  4129 	RmDir(trgPath);
       
  4130 	// Setup the directory structure
       
  4131 	SetupDirStructure(srcPath, trgPath);
       
  4132 	if(!gAsynch)
       
  4133 		err = gFileMan->Move(srcPath, trgPath, 0);
       
  4134 	else
       
  4135 	 	err = gFileMan->Move(srcPath, trgPath, 0, gStat);
       
  4136 	TestResult(err);
       
  4137 
       
  4138 	// Verify src contents after move operation
       
  4139 	CDir *dir = NULL;
       
  4140 	err = TheFs.GetDir(srcPath, KEntryAttMaskSupported, ESortNone, dir);
       
  4141 	test(6 == dir->Count());
       
  4142 	delete dir;
       
  4143 	// Verify dest contents after move operation
       
  4144 	err = TheFs.GetDir(trgPath, KEntryAttMaskSupported, ESortNone, dir);
       
  4145 	test(3 == dir->Count());
       
  4146 	delete dir;
       
  4147 	
       
  4148 	// Recursive move with "\\" at the end of srcPath
       
  4149 	// clean up before execution	
       
  4150 	RmDir(srcPath);
       
  4151 	RmDir(trgPath);
       
  4152 	// Setup the directory structure
       
  4153 	SetupDirStructure(srcPath, trgPath);
       
  4154 	if(!gAsynch)
       
  4155 		err = gFileMan->Move(srcPath, trgPath, CFileMan::ERecurse);
       
  4156 	else
       
  4157 		err = gFileMan->Move(srcPath, trgPath, CFileMan::ERecurse, gStat);
       
  4158 	TestResult(err);
       
  4159 	
       
  4160 	// Verify src has no content
       
  4161 	err = TheFs.GetDir(srcPath, KEntryAttMaskSupported, ESortNone, dir);
       
  4162 	test(0 == dir->Count());
       
  4163 	delete dir;
       
  4164 	// Verify dest contents after move operation
       
  4165 	err = TheFs.GetDir(trgPath, KEntryAttMaskSupported, ESortNone, dir);
       
  4166 	test(9 == dir->Count());
       
  4167 	delete dir;
       
  4168 	
       
  4169 	// Recursive move without "\\" at the end of srcPath
       
  4170 	// clean up before execution
       
  4171 	RmDir(srcPath);
       
  4172 	RmDir(trgPath);
       
  4173 	// Setup the directory structure
       
  4174 	SetupDirStructure(srcPath, trgPath);
       
  4175 	// Remove the "\\" at the end of srcPath for Recursive Move
       
  4176 	srcPath.Delete(srcPath.Length()-1,1);
       
  4177 	if(!gAsynch)
       
  4178 		err = gFileMan->Move(srcPath, trgPath, CFileMan::ERecurse);
       
  4179 	else
       
  4180 		err = gFileMan->Move(srcPath, trgPath, CFileMan::ERecurse, gStat);
       
  4181 	TestResult(err);
       
  4182 		
       
  4183 	// Add the "\\" at the end of srcPath for verification
       
  4184 	srcPath.Append(KPathDelimiter);
       
  4185 	// Verify src doesnt not exist
       
  4186 	err = gFileMan->RmDir(srcPath);
       
  4187 	test(err==KErrPathNotFound); // KErrPathNotFound expected as src has been moved to dest
       
  4188 	// Verify dest after move operation
       
  4189 	err = TheFs.GetDir(trgPath, KEntryAttMaskSupported, ESortNone, dir);
       
  4190 	test(1 == dir->Count());
       
  4191 	delete dir;
       
  4192 		
       
  4193 	// clean up before leaving
       
  4194 	RmDir(srcPath);
       
  4195 	RmDir(trgPath);
       
  4196 
       
  4197 	test.Next(_L("--TestPDEF112148 : \n"));
       
  4198 	}
       
  4199 //---------------------------------------------
       
  4200 //! @SYMTestCaseID			PBASE-T_FMAN-2398
       
  4201 //! @SYMTestType			UT 
       
  4202 //! @SYMREQ					DEF130678
       
  4203 //! @SYMTestCaseDesc		Tests that CFileMan::Move itself does not leak any memory
       
  4204 //! @SYMTestActions			Move files and keep checking the memory usage for each operation.
       
  4205 //! @SYMTestExpectedResults	Test completes without any crash and hence without any memory leak.
       
  4206 //! @SYMTestPriority		High
       
  4207 //! @SYMTestStatus			Implemented
       
  4208 //---------------------------------------------
       
  4209 void TestDEF130678()
       
  4210 {
       
  4211 	test.Next(_L("++TestDEF130678\n"));
       
  4212 	
       
  4213 	_LIT(KFromFile,"C:\\TestDEF130678\\FROM\\from_");
       
  4214 	_LIT(KToFile,"C:\\TestDEF130678\\TO\\");
       
  4215 
       
  4216 	TInt run;
       
  4217 	// choose a number that certainly tests all memory allocations.
       
  4218 	// it is used for memory allocation failure simulation.
       
  4219 	TInt maxRun = 50;
       
  4220 	// start OOM loop
       
  4221 	for(run=1; run<=maxRun; ++run)
       
  4222 		{
       
  4223 		TInt err = KErrNone;
       
  4224 		TFileName fromFile, toFile;
       
  4225 
       
  4226 		fromFile.Append(KFromFile);
       
  4227 		fromFile.AppendNum(run);
       
  4228 		fromFile.Append(_L(".txt"));
       
  4229 		MakeFile(fromFile);
       
  4230 		
       
  4231 		MakeDir(_L("C:\\TestDEF130678\\FROM\\"));
       
  4232 		MakeDir(_L("C:\\TestDEF130678\\TO\\"));
       
  4233 		toFile.Append(KToFile);
       
  4234 		
       
  4235 		// Check the memory usage
       
  4236 		__UHEAP_MARK;
       
  4237 		// set to fail every run-th memory allocation
       
  4238 		__UHEAP_SETFAIL(RAllocator::EDeterministic, run);
       
  4239 
       
  4240 		CFileMan* fileMan = NULL;
       
  4241 		TInt errTrap1 = KErrNone;
       
  4242 		TRAP(errTrap1,(fileMan=CFileMan::NewL(TheFs)));
       
  4243 		if (errTrap1 != KErrNone)
       
  4244 			{
       
  4245 			// reset the memory allocation failure and check for any leak
       
  4246 			__UHEAP_RESET;
       
  4247 			__UHEAP_MARKEND;
       
  4248 			continue;
       
  4249 			}
       
  4250 
       
  4251 		CleanupStack::PushL(fileMan);
       
  4252 		TInt errTrap2 = KErrNone;
       
  4253 		TRAP(errTrap2,(err = fileMan->Move(fromFile,toFile)));
       
  4254 		if (errTrap2 != KErrNone || err != KErrNone)
       
  4255 			{
       
  4256 			CleanupStack::PopAndDestroy(fileMan);
       
  4257 			// reset the memory allocation failure and check for any leak
       
  4258 			__UHEAP_RESET;
       
  4259 			__UHEAP_MARKEND;
       
  4260 			continue;
       
  4261 			}
       
  4262 		CleanupStack::PopAndDestroy(fileMan);
       
  4263 		// reset the memory allocation failure and check for any leak
       
  4264 		__UHEAP_RESET;
       
  4265 		__UHEAP_MARKEND;
       
  4266 		} // End of OOM loop
       
  4267 		
       
  4268 	// cleanup
       
  4269 	RmDir(_L("C:\\TestDEF130678\\"));
       
  4270 	test.Next(_L("--TestDEF130678\n"));		
       
  4271 }
       
  4272 
       
  4273 GLDEF_C void CallTestsL()
       
  4274 //
       
  4275 // Do tests
       
  4276 //
       
  4277 	{
       
  4278 	// T_FMAN is independent of all tests so format first
       
  4279 #ifndef __WINS__
       
  4280 	Format(CurrentDrive());
       
  4281 #endif
       
  4282 
       
  4283 	InitialiseL();
       
  4284 	CreateTestDirectory(_L("\\F32-TST\\TFMAN\\"));
       
  4285 //	May not be able to test handling of invalid path lengths because F32 fix 
       
  4286 //	to prevent paths >256 ever being created
       
  4287 	testingInvalidPathLengths = CheckIfShortPathsAreSupported();
       
  4288 	
       
  4289 	gAsynch=ETrue;
       
  4290 	
       
  4291 	test.Next(_L("Asynchronous tests ..."));
       
  4292 	TheFs.SetAllocFailure(gAllocFailOff);
       
  4293 
       
  4294 	TInt uid;
       
  4295 	test(HAL::Get(HAL::EMachineUid,uid)==KErrNone);
       
  4296 	TBool doTargetTests =  (!IsTestingLFFS() && 
       
  4297 							uid!=HAL::EMachineUid_Cogent && 
       
  4298 							uid!=HAL::EMachineUid_IQ80310 && 
       
  4299 							uid!=HAL::EMachineUid_X86PC);
       
  4300 
       
  4301 	if (doTargetTests)
       
  4302 		{
       
  4303 		TestMoveAcrossDrives();
       
  4304 		TestRecursiveMoveAcrossDrives();
       
  4305 		TestMoveEmptyDirectory();
       
  4306 		TestAbortedMoveAcrossDrives();
       
  4307 		TestPDEF112148();
       
  4308 		}
       
  4309 
       
  4310 	TestOverWrite();
       
  4311 	TestRename();
       
  4312 	TestErrorHandling();
       
  4313 
       
  4314 	TestRecursiveMove();
       
  4315 	TestRecursiveDelete();
       
  4316 	TestRecursiveAttribs();
       
  4317 	TestRecursiveCopy();
       
  4318 	
       
  4319 	TestRmDir();
       
  4320 	TestSimultaneous();
       
  4321 	TestAttribs();
       
  4322 	TestDelete();
       
  4323 	if (!IsTestingLFFS())
       
  4324 		TestCopy(); // ???
       
  4325 	TestMove();
       
  4326 	TestCopyAllCancel();
       
  4327 
       
  4328 	gAsynch=EFalse;
       
  4329 	test.Next(_L("Synchronous tests ..."));
       
  4330 	TheFs.SetAllocFailure(gAllocFailOn);
       
  4331 
       
  4332 	if (doTargetTests)
       
  4333 		{
       
  4334 		TestMoveAcrossDrives();
       
  4335 		TestRecursiveMoveAcrossDrives();
       
  4336 		TestMoveEmptyDirectory();
       
  4337 		TestAbortedMoveAcrossDrives();
       
  4338 		TestPDEF112148();
       
  4339 		}
       
  4340 
       
  4341 	TestCopyOpenFile();
       
  4342 	if(testingInvalidPathLengths)
       
  4343 		TestLongNames();
       
  4344 	TestNameMangling();
       
  4345 	TestFileAttributes();
       
  4346 	TestOverWrite();
       
  4347 	TestRename();
       
  4348 	TestErrorHandling();
       
  4349 	TestRecursiveMove();
       
  4350 	TestRecursiveDelete();
       
  4351 	TestRecursiveAttribs();
       
  4352 	TestRecursiveCopy();
       
  4353 	TestRmDir();
       
  4354 	TestSimultaneous();
       
  4355 	TestAttribs();
       
  4356 	TestDelete();
       
  4357 	TestCopy();
       
  4358 	TestMove();
       
  4359 	TestCopyAndRename();
       
  4360 	TestCopyAllCancel();
       
  4361 	
       
  4362 	// OOM testing
       
  4363 	TestDEF130678();
       
  4364 #ifndef __WINS__
       
  4365 	RThread t;
       
  4366 	TThreadStackInfo stack;
       
  4367 	test(t.StackInfo(stack)==KErrNone);
       
  4368 	TestStackUsage(0, stack);
       
  4369 #endif
       
  4370 
       
  4371 	Cleanup();
       
  4372 	DeleteTestDirectory();
       
  4373 	test(TheFs.RmDir(_L("\\F32-TST\\")) == KErrNone);
       
  4374 	}
       
  4375