Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
22 GLDEF_D RTest test(_L("T_FMAN"));
24 LOCAL_D CFileMan* gFileMan=NULL;
25 LOCAL_D TBool gAsynch=EFalse;
26 LOCAL_D TRequestStatus gStat;
27 LOCAL_D TBool testingInvalidPathLengths;
29 class CFileManObserver : public CBase, public MFileManObserver
32 CFileManObserver(CFileMan* aFileMan);
33 TControl NotifyFileManEnded();
38 LOCAL_D CFileManObserver* gObserver;
40 CFileManObserver::CFileManObserver(CFileMan* aFileMan)
45 __DECLARE_NAME(_S("CFileManObserver"));
49 MFileManObserver::TControl CFileManObserver::NotifyFileManEnded()
51 // Called back after each FMan tick
54 TInt lastError=iFileMan->GetLastError();
55 if (lastError!=KErrNone && lastError!=KErrBadName)
57 TFileName fileName=iFileMan->CurrentEntry().iName;
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);
63 return(MFileManObserver::EContinue);
66 LOCAL_C void WaitForSuccess()
68 // Wait for gStat to complete with KErrNone
71 User::WaitForRequest(gStat);
72 test(gStat==KErrNone);
75 LOCAL_C void WaitForResult(TInt aResult)
77 // Wait for gStat to complete with aResult
80 User::WaitForRequest(gStat);
84 LOCAL_C void TestResult(TInt aReturnVal, TInt aExpectedAsynchReturnStatus=KErrNone, TInt aExpectedSynchReturn=KErrNone)
86 // Test the result, wait for an asynchronous call
90 test(aReturnVal==aExpectedAsynchReturnStatus);
93 test(aReturnVal==aExpectedSynchReturn);
94 WaitForResult(aExpectedAsynchReturnStatus);
98 LOCAL_C void RmDir(const TDesC& aDirName)
100 // Remove a directory
103 gFileMan->Attribs(aDirName, 0, KEntryAttReadOnly, 0, CFileMan::ERecurse);
104 TInt r=gFileMan->RmDir(aDirName);
105 test(r==KErrNone || r==KErrNotFound || r==KErrPathNotFound);
108 LOCAL_C void Compare(const TDesC& aDir1,const TDesC& aDir2)
110 // Test that the contents of two directories are identical
113 CDirScan* scanDir1=CDirScan::NewL(TheFs);
114 scanDir1->SetScanDataL(aDir1,KEntryAttMaskSupported,ESortByName);
115 CDirScan* scanDir2=CDirScan::NewL(TheFs);
116 scanDir2->SetScanDataL(aDir2,KEntryAttMaskSupported,ESortByName);
123 scanDir1->NextL(entryList1);
124 scanDir2->NextL(entryList2);
126 if (entryList1==NULL || entryList2==NULL)
128 test(entryList1==NULL && entryList2==NULL);
132 TFileName abbPath1=scanDir1->AbbreviatedPath();
133 TFileName abbPath2=scanDir2->AbbreviatedPath();
134 test(abbPath1==abbPath2);
136 TInt count1=entryList1->Count();
137 TInt count2=entryList2->Count();
138 test(count1==count2);
142 TEntry entry1=(*entryList1)[count1];
143 TEntry entry2=(*entryList2)[count1];
144 test(entry1.iName==entry2.iName);
145 test(entry1.iAtt==entry2.iAtt);
156 LOCAL_C void SetupDirectories(TBool aCreateFiles, TFileName* aDestOtherDrive)
158 // Set up a directory structure and files to test copying/moving across drives
163 TFileName sourceName = _L("\\F32-TST\\TFMAN\\source\\");
164 TFileName sourceNameSubDir = _L("\\F32-TST\\TFMAN\\source\\subdir\\");
165 TFileName sourceCompare = _L("\\F32-TST\\TFMAN\\compare\\");
166 TFileName sourceCompareSubDir = _L("\\F32-TST\\TFMAN\\compare\\subdir\\");
167 TFileName destSameDrive = _L("\\F32-TST\\TFMAN\\dest\\"); // Target destination on the same drive
171 #if !defined(__WINS__)
172 *aDestOtherDrive = gSessionPath[0] == 'C' ? _L("D:\\F32-TST\\TFMAN\\dest\\") : _L("C:\\F32-TST\\TFMAN\\dest\\");
174 *aDestOtherDrive = gSessionPath[0] == 'C' ? _L("Y:\\F32-TST\\TFMAN\\dest\\") : _L("C:\\F32-TST\\TFMAN\\dest\\");
176 err = TheFs.MkDirAll(*aDestOtherDrive);
177 test(err == KErrNone || err == KErrAlreadyExists);
180 err = TheFs.MkDirAll(sourceName);
181 test(err == KErrNone || err == KErrAlreadyExists);
183 err = TheFs.MkDirAll(sourceCompare);
184 test(err == KErrNone || err == KErrAlreadyExists);
186 err = TheFs.MkDirAll(destSameDrive);
187 test(err == KErrNone || err == KErrAlreadyExists);
191 err = TheFs.MkDirAll(sourceNameSubDir);
192 test(err == KErrNone || err == KErrAlreadyExists);
194 err = TheFs.MkDirAll(sourceCompareSubDir);
195 test(err == KErrNone || err == KErrAlreadyExists);
197 for(TInt i=0; i<5; i++)
199 // Create a test file to be copied
200 TFileName name = sourceName;
201 name.Append(_L("File"));
203 name.Append(_L(".TXT"));
206 err = file.Create(TheFs,name,EFileRead|EFileWrite);
207 test(err == KErrNone || err == KErrAlreadyExists);
210 // ...and another to compare against
211 name = sourceCompare;
212 name.Append(_L("File"));
214 name.Append(_L(".TXT"));
216 err = file.Create(TheFs,name,EFileRead|EFileWrite);
217 test(err == KErrNone || err == KErrAlreadyExists);
223 TBool CheckIfShortPathsAreSupported()
227 _LIT(KTestFile, "\\longname1\\file");
228 RmDir(_L("\\longname1\\"));
230 TInt err = TheFs.GetShortName(_L("\\longname1\\"), buf);
233 buf.Insert(0, _L("\\"));
234 buf.Append(_L("\\file"));
235 err = TheFs.Delete(buf);
236 test(err == KErrNone);
239 RmDir(_L("\\longname1\\"));
243 LOCAL_C void TestDelete()
245 // Test files are deleted
248 test.Next(_L("Test delete - Set up files and start deleting"));
250 MakeDir(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EMPTY\\"));
251 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"));
252 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE2.TXT"));
253 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE3.TXT"));
254 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\FILE4.TXT"));
255 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EXE1.BIN"));
256 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\EXE2.BIN"));
259 // absolute path for code warrior two more than wins (\epoc32\winscw\c vs \epoc32\wins\c)
260 #if defined(__WINSCW__)
261 _LIT(KLongName1,"\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffd");
263 _LIT(KLongName1,"\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa");
266 _LIT(KInvalidLongName,"\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdffdsa23asdffdsa24asdffdsa25asdffdsa");
267 _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");
268 if (testingInvalidPathLengths)
269 // Create a path of greater 256 characters by renaming a directory and check it can be
270 // manipulated (tests fix to F32)
272 // One long directory name - makes paths invalid
273 MakeDir(_L("\\TEST\\LONG\\NAME\\ABCDE"));
274 MakeDir(_L("\\TEST\\LONG\\NAME\\ABCDE\\DIRECTORY1DIRECTORY2DIRECTORY3DIRECTORY4\\"));
275 MakeFile(_L("\\TEST\\LONG\\NAME\\ABCDE\\ELEPHANT01ELEPHANT02ELEPHANT03ELEPHANT04"));
276 MakeFile(_L("\\TEST\\LONG\\NAME\\ABCDE\\FILEFILE01FILEFILE02FILEFILE03FILEFILE04"));
277 TFileName name1(KLongName1);
278 r=gFileMan->Rename(_L("\\TEST\\LONG"),name1,CFileMan::EOverWrite);
280 // Two long directory names - makes paths invalid
281 MakeDir(_L("\\TEST\\LONG\\NAME\\FGHIJ"));
282 MakeDir(_L("\\TEST\\LONG\\NAME\\FGHIJ\\DIRECTORY1DIRECTORY2DIRECTORY3DIRECTORY4\\"));
283 MakeFile(_L("\\TEST\\LONG\\NAME\\FGHIJ\\ELEPHANT01ELEPHANT02ELEPHANT03ELEPHANT04"));
284 MakeFile(_L("\\TEST\\LONG\\NAME\\FGHIJ\\FILEFILE01FILEFILE02FILEFILE03FILEFILE04"));
286 // Testing invalid long file name (i.e. >256)
287 r=gFileMan->Rename(_L("\\TEST\\LONG"),KInvalidLongName,CFileMan::EOverWrite);
288 test(r==KErrBadName);
290 // Testing invalid long path (i.e. >256)
291 r=gFileMan->Rename(_L("\\TEST\\LONG"),KInvalidLongPath,CFileMan::EOverWrite);
292 test(r==KErrBadName);
294 r=gFileMan->Rename(_L("\\TEST\\LONG"),_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds"),CFileMan::EOverWrite);
298 //testing invalid source path at the beginning:
301 r=gFileMan->Delete(_L(":C\\F32-TST\\TFMAN\\DELDIR\\*.TXT"));
305 r=gFileMan->Delete(_L(":C\\F32-TST\\TFMAN\\DELDIR\\*.TXT"),0,gStat);
307 TestResult(r,KErrBadName,KErrBadName);
309 //testing invalid source path at the middle:
312 r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\:DELDIR\\*.TXT"));
316 r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\:DELDIR\\*.TXT"),0,gStat);
318 TestResult(r,KErrBadName,KErrNone);
320 //testing invalid source path at the end:
323 r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\DELDIR\\:*.TXT"));
327 r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\DELDIR\\:*.TXT"),0,gStat);
329 TestResult(r,KErrBadName,KErrNone);
333 r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\DELDIR\\*.TXT"));
335 if (testingInvalidPathLengths)
337 TFileName name1(KLongName1);
338 name1+=_L("\\NAME\\ABCDE\\*.*");
339 r=gFileMan->Delete(name1);
342 r=gFileMan->Delete(_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds\\NAME\\FGHIJ\\*.*"));
348 gFileMan->Delete(_L("\\F32-TST\\TFMAN\\DELDIR\\*.TXT"),0,gStat);
350 if (testingInvalidPathLengths)
352 TFileName name1(KLongName1);
353 name1+=_L("\\NAME\\ABCDE\\*.*");
354 r=gFileMan->Delete(name1,0,gStat);
358 r=gFileMan->Delete(_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds\\NAME\\FGHIJ\\*.*"),0,gStat);
364 test.Next(_L("Check files are deleted"));
365 RmDir(_L("\\F32-TST\\TFMAN\\After\\"));
366 MakeDir(_L("\\F32-TST\\TFMAN\\AFTER\\DELDIR\\DELTEST\\EMPTY\\"));
367 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\DELDIR\\DELTEST\\EXE1.BIN"));
368 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\DELDIR\\DELTEST\\FILE4.TXT"));
369 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\DELDIR\\EXE2.BIN"));
370 Compare(_L("\\F32-TST\\TFMAN\\DELDIR\\*"),_L("\\F32-TST\\TFMAN\\AFTER\\DELDIR\\*"));
372 if (testingInvalidPathLengths)
374 r=gFileMan->RmDir(_L("\\TEST\\"));
379 Test wild card matching in short file names
380 Note this test is only run on FAT file systems as 'short file names' are only
382 DEF130113: TTG:<Wild card characters cannot be handled in the short file names>
385 r=TheFs.CharToDrive(gDriveToTest,theDrive);
388 r = TheFs.FileSystemName(f, theDrive);
389 test(r == KErrNone || r == KErrNotFound);
390 if (f.FindF(_L("Fat")) == 0 )
392 test.Next(_L("Test wild card matching in short file names"));
393 MakeFile(_L("abcdefghi.txt"));
394 TInt err = gFileMan->Delete(_L("ABCDEF~*"));
395 test(err == KErrNone);
396 MakeFile(_L("abcdefghi.txt"));
397 err = gFileMan->Delete(_L("ABCDEF~*.TXT"));
398 test(err == KErrNone);
399 MakeFile(_L("abcdefghi.txt"));
400 err = gFileMan->Delete(_L("ABCDEF~*.?XT"));
401 test(err == KErrNone);
402 MakeFile(_L("abcdefghi.txt"));
403 err = gFileMan->Delete(_L("ABCDEF~1.*"));
404 test(err == KErrNone);
408 LOCAL_C void TestCopy()
413 test.Next(_L("Test copy"));
414 RmDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\*"));
416 MakeDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
417 MakeDir(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EMPTY\\"));
418 MakeFile(_L("\\F32-TST\\TFMAN\\NewDir\\ABC.DEF"));
419 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"));
420 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE2.TXT"));
421 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE3.TXT"));
422 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\FILE4.TXT"));
423 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EXE1.BIN"));
424 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\EXE2.BIN"));
425 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA1.TXT"));
426 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA2.TXT"));
427 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA3.TXT"));
428 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA4.TXT"));
430 test.Next(_L("Test copy files to the same directory"));
433 if (testingInvalidPathLengths)
434 // Create a path of greater than 256 characters by renaming a directory and
435 // check it can be manipulated (tests fix to F32)
437 MakeDir(_L("\\START\\LONG\\"));
438 MakeDir(_L("\\FINISH\\"));
439 MakeFile(_L("\\START\\LONG\\ABCDEFGH01ABCDEFGH01ABCDEFGH01ABCDEFGH01.txt"));
440 MakeFile(_L("\\START\\LONG\\ELEPHANT01ELEPHANT02ELEPHANT03ELEPHANT04.txt"));
441 MakeFile(_L("\\START\\LONG\\DINOSAUR01DINOSAUR02DINOSAUR03DINOSAUR04.txt"));
442 MakeFile(_L("\\START\\LONG\\FILEFILE01FILEFILE02FILEFILE03FILEFILE04.txt"));
443 r=gFileMan->Rename(_L("\\START\\LONG"),_L("\\START\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff"),CFileMan::EOverWrite);
445 MakeDir(_L("\\START\\ASDFFDSA\\"));
448 //testing invalid source path at the beginning:
451 r=gFileMan->Copy(_L(":C:\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0);
455 r=gFileMan->Copy(_L(":C:\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0,gStat);
457 TestResult(r,KErrBadName,KErrBadName);
459 //testing invalid target path at the beginning:
463 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L(":C:\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0);
467 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L(":C:\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0,gStat);
469 TestResult(r,KErrBadName,KErrBadName);
471 //testing invalid source path at the middle:
474 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\:DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0);
478 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\:DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0,gStat);
480 TestResult(r,KErrBadName,KErrNone);
482 //testing invalid target path at the middle:
485 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\:DELDIR\\rumba?.txt"),0);
489 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\:DELDIR\\rumba?.txt"),0,gStat);
491 TestResult(r,KErrBadName,KErrNone);
493 //testing invalid source path at the end:
496 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\:file?.txt"),_L("\\F32-TST\\TFMAN\\:DELDIR\\rumba?.txt"),0);
500 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\:file?.txt"),_L("\\F32-TST\\TFMAN\\:DELDIR\\rumba?.txt"),0,gStat);
502 TestResult(r,KErrBadName,KErrNone);
504 //testing invalid target path at the end:
507 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\:DELDIR\\:rumba?.txt"),0);
511 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\:DELDIR\\:rumba?.txt"),0,gStat);
513 TestResult(r,KErrBadName,KErrNone);
516 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0);
518 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0,gStat);
519 TestResult(r,KErrAlreadyExists);
522 r = gFileMan->Delete(_L("\\F32-TST\\TFMAN\\DELDIR\\rumba.txt"),0);
524 r = gFileMan->Delete(_L("\\F32-TST\\TFMAN\\DELDIR\\rumba.txt"),0,gStat);
525 TestResult(r,KErrNone);
528 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\file1.txt"),0);
530 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\file1.txt"),0,gStat);
531 TestResult(r,KErrAlreadyExists);
535 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\*.TXT"),_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
537 if (testingInvalidPathLengths)
539 test.Next(_L("Test invalid length paths"));
540 r=gFileMan->Copy(_L("\\START\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\*.*"),_L("\\FINISH\\"));
542 r=gFileMan->RmDir(_L("\\START\\"));
544 r=gFileMan->RmDir(_L("\\FINISH\\"));
550 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\*.TXT"),_L("\\F32-TST\\TFMAN\\COPYDIR\\"),0,gStat);
553 if (testingInvalidPathLengths)
555 test.Next(_L("Test invalid length paths (Asynch)"));
556 r=gFileMan->Copy(_L("\\START\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\*.*"),_L("\\FINISH\\"),0,gStat);
559 r=gFileMan->RmDir(_L("\\START\\"),gStat);
562 r=gFileMan->RmDir(_L("\\FINISH\\"),gStat);
569 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\NewDir\\*.*"),_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
571 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\NewDir\\*.*"),_L("\\F32-TST\\TFMAN\\COPYDIR\\"),0,gStat);
574 test.Next(_L("Check files have been copied"));
575 RmDir(_L("\\F32-TST\\TFMAN\\after\\"));
576 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FILE1.TXT"));
577 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FILE2.TXT"));
578 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FILE3.TXT"));
579 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\RUMBA1.TXT"));
580 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\RUMBA2.TXT"));
581 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\RUMBA3.TXT"));
582 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\RUMBA4.TXT"));
583 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\ABC.DEF"));
584 Compare(_L("\\F32-TST\\TFMAN\\AFTER\\*"),_L("\\F32-TST\\TFMAN\\COPYDIR\\*"));
586 TFileName fn = _L("Z:\\TEST\\T_FSRV.CPP");
587 fn[0] = gExeFileName[0];
589 r=gFileMan->Copy(fn,_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
591 r=gFileMan->Copy(fn,_L("\\F32-TST\\TFMAN\\COPYDIR\\"),0,gStat);
592 TestResult(KErrNone);
595 r=TheFs.Entry(_L("\\F32-TST\\TFMAN\\COPYDIR\\T_FSRV.CPP"),entry);
597 test(entry.iName.MatchF(_L("T_FSRV.CPP"))!=KErrNotFound);
598 #if defined (__WINS__)
599 test(entry.iAtt==KEntryAttArchive);
601 if (!IsTestingLFFS())
602 test(entry.iAtt==KEntryAttReadOnly);
604 test(entry.iAtt&KEntryAttReadOnly); // ???
606 r=TheFs.SetAtt(_L("\\F32-TST\\TFMAN\\COPYDIR\\T_FSRV.CPP"),0,KEntryAttReadOnly);
609 r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\AFTER\\RUMBA?.TXT"));
611 r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA?.TXT"));
615 LOCAL_C void TestDEF121663_Setup(TFileName& aSrcPath)
620 for(TInt index=0; index<10; index++)
623 fileName.Copy(aSrcPath);
624 fileName.Append(_L("FILE_"));fileName.AppendNum(index);fileName.Append(_L(".TXT"));
625 MakeFile(fileName, _L8("Some Data"));
629 LOCAL_C void TestDEF121663()
631 test.Next(_L("Test moving directory to its subdirectory (DEF121663)"));
633 gFileMan->SetObserver(NULL);
635 TFileName srcPath = _L("C:\\TestDEF121663\\");
637 TestDEF121663_Setup(srcPath);
640 err = gFileMan->Move(_L("C:\\TestDEF121663"),_L("C:\\TestDEF121663\\TestDEF121663"),CFileMan::EOverWrite);
644 err = gFileMan->Move(_L("C:\\TestDEF121663"),_L("C:\\TestDEF121663\\TestDEF121663"),CFileMan::EOverWrite, gStat);
646 TestResult(err,KErrInUse,KErrInUse);
648 TestDEF121663_Setup(srcPath);
651 err = gFileMan->Move(_L("C:\\TestDEF121663\\"),_L("C:\\TestDEF121663\\TestDEF121663\\"),CFileMan::EOverWrite);
655 err = gFileMan->Move(_L("C:\\TestDEF121663\\"),_L("C:\\TestDEF121663\\TestDEF121663\\"),CFileMan::EOverWrite, gStat);
657 TestResult(err,KErrPathNotFound);
659 TestDEF121663_Setup(srcPath);
662 err = gFileMan->Move(_L("C:\\TestDEF121663\\"),_L("C:\\TestDEF121663\\TestDEF121663"),CFileMan::EOverWrite);
666 err = gFileMan->Move(_L("C:\\TestDEF121663\\"),_L("C:\\TestDEF121663\\TestDEF121663"),CFileMan::EOverWrite, gStat);
668 TestResult(err,KErrPathNotFound);
670 TestDEF121663_Setup(srcPath);
673 err = gFileMan->Move(_L("C:\\TestDEF121663"),_L("C:\\TestDEF121663\\TestDEF121663\\"),CFileMan::ERecurse|CFileMan::EOverWrite);
677 err = gFileMan->Move(_L("C:\\TestDEF121663"),_L("C:\\TestDEF121663\\TestDEF121663\\"),CFileMan::ERecurse|CFileMan::EOverWrite, gStat);
679 TestResult(err,KErrInUse,KErrInUse);
681 TestDEF121663_Setup(srcPath);
684 err = gFileMan->Move(_L("C:\\TestDEF121663"),_L("C:\\TestDEF121663\\TestDEF121663"),CFileMan::ERecurse);
688 err = gFileMan->Move(_L("C:\\TestDEF121663"),_L("C:\\TestDEF121663\\TestDEF121663"),CFileMan::ERecurse, gStat);
690 TestResult(err,KErrInUse,KErrInUse);
692 gFileMan->SetObserver(gObserver);
693 // remove previous dirs
694 RmDir(_L("C:\\TestDEF121663\\"));
697 // Test moving directories where source and target have matching subdirectory structures
698 LOCAL_C void TestDEF123575()
700 test.Next(_L("Test moving directories with matching subdirectory structures (DEF123575)"));
704 //setup the initial directory structure
705 srcPath = _L("\\F32-TST\\DEF123575\\SRCDIR\\CommonDIR\\temp\\temp1.1\\");
706 destPath = _L("\\F32-TST\\DEF123575\\DSTDIR\\CommonDIR\\temp\\temp1.1\\");
709 MakeFile(_L("\\F32-TST\\DEF123575\\SRCDIR\\CommonDIR\\temp\\temp1.1\\FILE1.TXT"));
711 srcPath = _L("\\F32-TST\\DEF123575\\SRCDIR\\CommonDIR");
712 destPath = _L("\\F32-TST\\DEF123575\\DSTDIR\\");
715 err = gFileMan->Move(srcPath,destPath,CFileMan::EOverWrite);
719 err = gFileMan->Move(srcPath,destPath,CFileMan::EOverWrite, gStat);
721 TestResult(err,KErrNone,KErrNone);
723 //test that source directory is empty after move
724 MakeDir(_L("\\F32-TST\\DEF123575\\AFTER\\"));
725 Compare(_L("\\F32-TST\\DEF123575\\SRCDIR\\*"),_L("\\F32-TST\\DEF123575\\AFTER\\*"));
726 //test that the files have been moved to the destination directory
727 MakeDir(_L("\\F32-TST\\DEF123575\\AFTER\\CommonDIR\\temp\\temp1.1\\"));
728 MakeFile(_L("\\F32-TST\\DEF123575\\AFTER\\CommonDIR\\temp\\temp1.1\\FILE1.TXT"));
729 Compare(_L("\\F32-TST\\DEF123575\\DSTDIR\\*"),_L("\\F32-TST\\DEF123575\\AFTER\\*"));
731 //delete the entire directory structure
732 RmDir(_L("\\F32-TST\\DEF123575\\*"));
735 LOCAL_C void TestDEF125570()
737 test.Next(_L("Test move when trg has at least one of the src dirs (DEF125570)"));
738 gFileMan->SetObserver(NULL);
740 TFileName srcPath = _L("C:\\TestDEF125570\\src\\");
741 TFileName trgPath = _L("C:\\TestDEF125570\\trg\\");
743 // remove previous dirs
748 MakeDir(_L("C:\\TestDEF125570\\src\\DIR1\\"));
749 MakeFile(_L("C:\\TestDEF125570\\src\\DIR1\\File1.txt"),_L8("FILE PATH : C:\\TestDEF125570\\SRC\\DIR1\\File1.txt"));
750 MakeFile(_L("C:\\TestDEF125570\\src\\DIR1\\File2.txt"),_L8("FILE PATH : C:\\TestDEF125570\\SRC\\DIR1\\File2.txt"));
751 MakeDir(_L("C:\\TestDEF125570\\src\\DIR1\\DIR11\\"));
752 MakeFile(_L("C:\\TestDEF125570\\src\\DIR1\\DIR11\\File1.txt"),_L8("FILE PATH : C:\\TestDEF125570\\SRC\\DIR1\\DIR11\\File1.txt"));
753 MakeFile(_L("C:\\TestDEF125570\\src\\DIR1\\DIR11\\File2.txt"),_L8("FILE PATH : C:\\TestDEF125570\\SRC\\DIR1\\DIR11\\File2.txt"));
754 MakeDir(_L("C:\\TestDEF125570\\src\\DIR2\\"));
755 MakeFile(_L("C:\\TestDEF125570\\src\\DIR2\\File1.txt"),_L8("FILE PATH : C:\\TestDEF125570\\SRC\\DIR2\\File1.txt"));
756 MakeFile(_L("C:\\TestDEF125570\\src\\DIR2\\File2.txt"),_L8("FILE PATH : C:\\TestDEF125570\\SRC\\DIR2\\File2.txt"));
757 MakeDir(_L("C:\\TestDEF125570\\src\\DIR2\\DIR12\\"));
758 MakeFile(_L("C:\\TestDEF125570\\src\\DIR2\\DIR12\\File1.txt"),_L8("FILE PATH : C:\\TestDEF125570\\SRC\\DIR2\\DIR12\\File1.txt"));
759 MakeFile(_L("C:\\TestDEF125570\\src\\DIR2\\DIR12\\File2.txt"),_L8("FILE PATH : C:\\TestDEF125570\\SRC\\DIR2\\DIR12\\File2.txt"));
761 //trg has at least one of the src subfolders
762 MakeDir(_L("C:\\TestDEF125570\\trg\\DIR2\\"));
763 MakeFile(_L("C:\\TestDEF125570\\trg\\DIR2\\File1.txt"),_L8("FILE PATH : C:\\TestDEF125570\\TRG\\DIR2\\File1.txt"));
764 MakeFile(_L("C:\\TestDEF125570\\trg\\DIR2\\File2.txt"),_L8("FILE PATH : C:\\TestDEF125570\\TRG\\DIR2\\File2.txt"));
767 err = gFileMan->Move(srcPath, trgPath, CFileMan::ERecurse|CFileMan::EOverWrite);
769 err = gFileMan->Move(srcPath, trgPath, CFileMan::ERecurse|CFileMan::EOverWrite, gStat);
771 gFileMan->SetObserver(gObserver);
772 // remove previous dirs
773 RmDir(_L("C:\\TestDEF125570\\"));
776 LOCAL_C void TestDEF130404()
778 test.Printf(_L("Test move when the src doesn't fully exist (DEF130404)"));
782 trgPath.Format(_L("%c:\\TestDEF130404\\Trg\\"), (TUint8)gDriveToTest);
784 srcPath.Format(_L("C:\\TestDEF130404\\Src\\DIR1\\"), (TUint8)gDriveToTest);
786 // clean up before testing
791 srcPath.Append(_L("NODIR\\*.*"));
795 r = gFileMan->Move(srcPath, trgPath, 0);
797 r = gFileMan->Move(srcPath, trgPath, 0, gStat);
798 TestResult(r,KErrPathNotFound);
800 // clean up before leaving
801 trgPath.Format(_L("%c:\\TestDEF130404\\"), (TUint8)gDriveToTest);
803 RmDir(_L("C:\\TestDEF130404\\"));
808 This is to test that moving files to overwrite folders with the same names
809 and moving folders (directories) to overwrite files with the same names
810 across drives return proper error codes
812 void TestPDEF137716()
814 // Do not run tests if we cannot move across different drives
815 if (gSessionPath[0]=='C')
818 // Move FILE to overwrite FOLDER --------------------------------------------------------
819 test.Next(_L("Test moving files to overwrite folders with the same names"));
820 gFileMan->SetObserver(NULL);
822 _LIT(KFixedTargetTestFolder, "\\PDEF137716\\");
823 _LIT(KFileToDirTargetCreatePath, "\\PDEF137716\\FileToDir_Target\\ITEM\\");
824 _LIT(KFileToDirTargetNameWild, "\\PDEF137716\\FileToDir_Target\\");
826 _LIT(KFixedSourceTestFolder, "C:\\PDEF137716\\");
827 _LIT(KFileToDirSourceName, "C:\\PDEF137716\\FileToDir_Source\\ITEM");
828 _LIT(KFileToDirSourceNameWild, "C:\\PDEF137716\\FileToDir_Source\\");
830 RmDir(KFixedTargetTestFolder);
831 RmDir(KFixedSourceTestFolder);
832 MakeDir(KFileToDirTargetCreatePath);
833 MakeFile(KFileToDirSourceName);
838 err = gFileMan->Move(KFileToDirSourceName, KFileToDirTargetNameWild, 0);
842 err = gFileMan->Move(KFileToDirSourceName, KFileToDirTargetNameWild, 0, gStat);
844 TestResult(err,KErrAccessDenied);
846 RmDir(KFixedTargetTestFolder);
847 RmDir(KFixedSourceTestFolder);
848 MakeDir(KFileToDirTargetCreatePath);
849 MakeFile(KFileToDirSourceName);
852 err = gFileMan->Move(KFileToDirSourceName, KFileToDirTargetNameWild, CFileMan::EOverWrite);
856 err = gFileMan->Move(KFileToDirSourceName, KFileToDirTargetNameWild, CFileMan::EOverWrite, gStat);
858 TestResult(err,KErrAccessDenied);
860 RmDir(KFixedTargetTestFolder);
861 RmDir(KFixedSourceTestFolder);
862 MakeDir(KFileToDirTargetCreatePath);
863 MakeFile(KFileToDirSourceName);
866 err = gFileMan->Move(KFileToDirSourceNameWild, KFileToDirTargetNameWild, 0);
870 err = gFileMan->Move(KFileToDirSourceNameWild, KFileToDirTargetNameWild, 0, gStat);
872 TestResult(err,KErrAccessDenied);
874 RmDir(KFixedTargetTestFolder);
875 RmDir(KFixedSourceTestFolder);
876 MakeDir(KFileToDirTargetCreatePath);
877 MakeFile(KFileToDirSourceName);
880 err = gFileMan->Move(KFileToDirSourceNameWild, KFileToDirTargetNameWild, CFileMan::EOverWrite);
884 err = gFileMan->Move(KFileToDirSourceNameWild, KFileToDirTargetNameWild, CFileMan::EOverWrite, gStat);
886 TestResult(err,KErrAccessDenied);
889 // Move FOLDER to overwrite FILE --------------------------------------------------------
890 test.Next(_L("Test moving folders to overwrite files with the same names"));
892 _LIT(KDirToFileTargetName, "\\PDEF137716\\DirToFile_Target\\ITEM");
893 _LIT(KDirToFileTargetNameWild, "\\PDEF137716\\DirToFile_Target\\");
895 _LIT(KDirToFileSourceName, "C:\\PDEF137716\\DirToFile_Source\\ITEM");
896 _LIT(KDirToFileSourceNameWild, "C:\\PDEF137716\\DirToFile_Source\\");
898 _LIT(KDirToFileSourceCreatePath, "C:\\PDEF137716\\DirToFile_Source\\ITEM\\");
900 RmDir(KFixedTargetTestFolder);
901 RmDir(KFixedSourceTestFolder);
902 MakeFile(KDirToFileTargetName);
903 MakeDir(KDirToFileSourceCreatePath);
906 err = gFileMan->Move(KDirToFileSourceName, KDirToFileTargetName, 0);
910 err = gFileMan->Move(KDirToFileSourceName, KDirToFileTargetName, 0, gStat);
912 TestResult(err,KErrAccessDenied,KErrAccessDenied);
914 RmDir(KFixedTargetTestFolder);
915 RmDir(KFixedSourceTestFolder);
916 MakeFile(KDirToFileTargetName);
917 MakeDir(KDirToFileSourceCreatePath);
920 err = gFileMan->Move(KDirToFileSourceName, KDirToFileTargetName, CFileMan::EOverWrite);
924 err = gFileMan->Move(KDirToFileSourceName, KDirToFileTargetName, CFileMan::EOverWrite, gStat);
926 TestResult(err,KErrAccessDenied,KErrAccessDenied);
928 RmDir(KFixedTargetTestFolder);
929 RmDir(KFixedSourceTestFolder);
930 MakeFile(KDirToFileTargetName);
931 MakeDir(KDirToFileSourceCreatePath);
934 err = gFileMan->Move(KDirToFileSourceName, KDirToFileTargetNameWild, 0);
938 err = gFileMan->Move(KDirToFileSourceName, KDirToFileTargetNameWild, 0, gStat);
940 TestResult(err,KErrAccessDenied,KErrAccessDenied);
942 RmDir(KFixedTargetTestFolder);
943 RmDir(KFixedSourceTestFolder);
944 MakeFile(KDirToFileTargetName);
945 MakeDir(KDirToFileSourceCreatePath);
948 err = gFileMan->Move(KDirToFileSourceName, KDirToFileTargetNameWild, CFileMan::EOverWrite);
952 err = gFileMan->Move(KDirToFileSourceName, KDirToFileTargetNameWild, CFileMan::EOverWrite, gStat);
954 TestResult(err,KErrAccessDenied,KErrAccessDenied);
956 RmDir(KFixedTargetTestFolder);
957 RmDir(KFixedSourceTestFolder);
958 MakeFile(KDirToFileTargetName);
959 MakeDir(KDirToFileSourceCreatePath);
960 err = gFileMan->Move(KDirToFileSourceNameWild, KDirToFileTargetNameWild, 0);
963 err = gFileMan->Move(KDirToFileSourceNameWild, KDirToFileTargetNameWild, 0);
967 err = gFileMan->Move(KDirToFileSourceNameWild, KDirToFileTargetNameWild, 0, gStat);
969 TestResult(err,KErrNotFound);
971 RmDir(KFixedTargetTestFolder);
972 RmDir(KFixedSourceTestFolder);
973 MakeFile(KDirToFileTargetName);
974 MakeDir(KDirToFileSourceCreatePath);
977 err = gFileMan->Move(KDirToFileSourceNameWild, KDirToFileTargetNameWild, CFileMan::EOverWrite);
981 err = gFileMan->Move(KDirToFileSourceNameWild, KDirToFileTargetNameWild, CFileMan::EOverWrite, gStat);
983 TestResult(err,KErrNotFound);
985 RmDir(KFixedTargetTestFolder);
986 RmDir(KFixedSourceTestFolder);
987 gFileMan->SetObserver(gObserver);
990 LOCAL_C void TestMove()
995 test.Next(_L("Test move"));
996 RmDir(_L("\\F32-TST\\TFMAN\\MOVEDIR\\*"));
998 MakeDir(_L("\\F32-TST\\TFMAN\\MOVEDIR\\"));
999 MakeDir(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EMPTY\\"));
1000 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"));
1001 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE2.TXT"));
1002 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE3.TXT"));
1003 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\FILE4.TXT"));
1004 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EXE1.BIN"));
1005 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\EXE2.BIN"));
1009 if (testingInvalidPathLengths)
1010 // Create a path of greater 256 characters by renaming a directory and check it can be
1011 // manipulated (tests fix to F32)
1013 MakeDir(_L("\\START\\LONG\\"));
1014 MakeDir(_L("\\FINISH\\"));
1015 MakeFile(_L("\\START\\LONG\\ABCDEFGH01ABCDEFGH01ABCDEFGH01ABCDEFGH01.txt"));
1016 MakeFile(_L("\\START\\LONG\\ELEPHANT01ELEPHANT02ELEPHANT03ELEPHANT04.txt"));
1017 MakeFile(_L("\\START\\LONG\\DINOSAUR01DINOSAUR02DINOSAUR03DINOSAUR04.txt"));
1018 MakeFile(_L("\\START\\LONG\\FILEFILE01FILEFILE02FILEFILE03FILEFILE04.txt"));
1019 r=gFileMan->Rename(_L("\\START\\LONG"),_L("\\START\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff"),CFileMan::EOverWrite);
1022 // Two long directory names - makes paths invalid
1023 MakeDir(_L("\\TEST\\LONG\\NAME\\FGHIJ"));
1024 MakeDir(_L("\\TEST\\LONG\\NAME\\FGHIJ\\DIRECTORY1DIRECTORY2DIRECTORY3DIRECTORY4\\"));
1025 MakeFile(_L("\\TEST\\LONG\\NAME\\FGHIJ\\ELEPHANT01ELEPHANT02ELEPHANT03ELEPHANT04"));
1026 MakeFile(_L("\\TEST\\LONG\\NAME\\FGHIJ\\FILEFILE01FILEFILE02FILEFILE03FILEFILE04"));
1027 r=gFileMan->Rename(_L("\\TEST\\LONG"),_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds"),CFileMan::EOverWrite);
1030 MakeDir(_L("\\START\\ASDFFDSA\\"));
1033 //testing invalid source path at the beginning:
1036 r=gFileMan->Move(_L(":C:\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"));
1040 r=gFileMan->Move(_L(":C:\\F32-TST\\TFMAN\\DELDIR\\FILE?.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE*.TXT"),0,gStat);
1042 TestResult(r,KErrBadName,KErrBadName);
1044 //testing invalid target path at the beginning:
1047 r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),_L(":C:\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"));
1051 r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE?.TXT"),_L(":C:\\F32-TST\\TFMAN\\DELDIR\\FILE*.TXT"),0,gStat);
1053 TestResult(r,KErrBadName,KErrBadName);
1055 //testing invalid source path at the middle:
1058 r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\:DELDIR\\FILE1.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"));
1062 r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\:DELDIR\\FILE?.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE*.TXT"),0,gStat);
1064 TestResult(r,KErrBadName,KErrNone);
1066 //testing invalid target path at the middle:
1069 r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),_L("\\F32-TST\\TFMAN\\:DELDIR\\FILE1.TXT"));
1073 r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE?.TXT"),_L("\\F32-TST\\TFMAN\\:DELDIR\\FILE*.TXT"),0,gStat);
1075 TestResult(r,KErrBadName,KErrNone);
1077 //testing invalid source path at the end:
1080 r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\:FILE1.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"));
1084 r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\:FILE?.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE*.TXT"),0,gStat);
1086 TestResult(r,KErrBadName,KErrNone);
1088 //testing invalid target path at the end:
1091 r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\:FILE1.TXT"));
1095 r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE?.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\:FILE*.TXT"),0,gStat);
1097 TestResult(r,KErrBadName,KErrNone);
1101 r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE?.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE*.TXT"));
1103 r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE?.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE*.TXT"),0,gStat);
1104 TestResult(r,KErrNone);
1106 if ((!gAsynch)&&(testingInvalidPathLengths))
1108 r=gFileMan->Move(_L("\\START\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\*.*"),_L("\\FINISH\\"));
1111 r=gFileMan->Move(_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds\\*.*"),_L("\\FINISH\\"), CFileMan::EOverWrite | CFileMan::ERecurse);
1114 r=gFileMan->RmDir(_L("\\START\\"));
1116 r=gFileMan->RmDir(_L("\\FINISH\\"));
1119 if ((gAsynch)&&(testingInvalidPathLengths))
1121 r=gFileMan->Move(_L("\\START\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\*.*"),_L("\\FINISH\\"),CFileMan::EOverWrite,gStat);
1122 User::WaitForRequest(gStat);
1124 r=gFileMan->Move(_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds\\*.*"),_L("\\FINISH\\"), CFileMan::EOverWrite | CFileMan::ERecurse,gStat);
1125 User::WaitForRequest(gStat);
1127 r=gFileMan->RmDir(_L("\\START\\"),gStat);
1130 r=gFileMan->RmDir(_L("\\FINISH\\"),gStat);
1136 r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"));
1138 r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),0,gStat);
1139 TestResult(r,KErrNone);
1142 r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\*.TXT"),_L("\\F32-TST\\TFMAN\\MOVEDIR\\"));
1144 r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\*.TXT"),_L("\\F32-TST\\TFMAN\\MOVEDIR\\"),0,gStat);
1148 r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\*.TXT"),_L("\\F32-TST\\TFMAN\\MoveDIR.\\FILE*.TXT"));
1150 r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\*.TXT"),_L("\\F32-TST\\TFMAN\\MoveDIR\\FILE*.TXT"),0,gStat);
1151 TestResult(r,KErrNotFound);
1153 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"));
1155 r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),_L("\\F32-TST\\TFMAN\\MoveDIR\\FILE1.TXT"),0);
1157 r=gFileMan->Move(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"),_L("\\F32-TST\\TFMAN\\MoveDIR\\FILE1.TXT"),0,gStat);
1158 TestResult(r,KErrAlreadyExists);
1159 r=TheFs.Delete(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"));
1162 test.Next(_L("Check files have been moved"));
1163 RmDir(_L("\\F32-TST\\TFMAN\\AFTER\\*"));
1164 MakeDir(_L("\\F32-TST\\TFMAN\\AFTER\\DELTEST\\EMPTY\\"));
1165 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\DELTEST\\FILE4.TXT"));
1166 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\DELTEST\\EXE1.BIN"));
1167 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\EXE2.BIN"));
1168 Compare(_L("\\F32-TST\\TFMAN\\AFTER\\*"),_L("\\F32-TST\\TFMAN\\DELDIR\\*"));
1170 RmDir(_L("\\F32-TST\\TFMAN\\AFTER\\*"));
1171 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FILE1.TXT"));
1172 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FILE2.TXT"));
1173 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FILE3.TXT"));
1174 Compare(_L("\\F32-TST\\TFMAN\\AFTER\\*"),_L("\\F32-TST\\TFMAN\\MOVEDIR\\*"));
1176 if (testingInvalidPathLengths)
1178 r=gFileMan->RmDir(_L("\\TEST\\"));
1182 TestDEF121663(); // Test moving directory to its subdirectory
1183 TestDEF123575(); // Test moving directories where src and trg have matching subdirectory structures
1184 TestDEF125570(); // Test move when trg has at least one of the src dirs
1185 TestDEF130404(); // Test move when the src doesn't fully exist
1186 if (!IsTestingLFFS())
1187 TestPDEF137716(); // Test moving files to overwrite folders that have the same names
1190 LOCAL_C void TestSimultaneous()
1192 // Create and run two CFileMen simultaneously
1195 test.Next(_L("Test create and run two CFileMans simultaneously"));
1196 RmDir(_L("\\F32-TST\\TFMAN\\fman2\\"));
1198 MakeDir(_L("\\F32-TST\\TFMAN\\FMAN1\\"));
1199 MakeDir(_L("\\F32-TST\\TFMAN\\FMAN2\\"));
1200 MakeFile(_L("\\F32-TST\\TFMAN\\FMAN1\\ROD.TXT"));
1201 MakeFile(_L("\\F32-TST\\TFMAN\\FMAN1\\JANE.TXT"));
1202 MakeFile(_L("\\F32-TST\\TFMAN\\FMAN1\\FREDDY.TXT"));
1203 MakeFile(_L("\\F32-TST\\TFMAN\\FMAN2\\BORIS.TXT"));
1204 MakeFile(_L("\\F32-TST\\TFMAN\\FMAN2\\FREDRICK.TXT"));
1205 MakeFile(_L("\\F32-TST\\TFMAN\\FMAN2\\PETER.TXT"));
1207 CFileMan* fman=CFileMan::NewL(TheFs);
1208 TRequestStatus stat1;
1209 TInt r=fman->Delete(_L("\\F32-TST\\TFMAN\\FMAN1\\*.*"),0,stat1);
1211 r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\FMAN2\\*.TXT"),_L("\\F32-TST\\TFMAN\\FMAN2\\*.EXT"),0,gStat);
1215 if (stat1!=KRequestPending && gStat!=KRequestPending)
1217 User::WaitForAnyRequest();
1219 test(stat1==KErrNone && gStat==KErrNone);
1222 test.Next(_L("Check all files"));
1223 RmDir(_L("\\F32-TST\\TFMAN\\AFTER\\*"));
1225 MakeDir(_L("\\F32-TST\\TFMAN\\AFTER\\"));
1226 Compare(_L("\\F32-TST\\TFMAN\\After\\*"),_L("\\F32-TST\\TFMAN\\FMAN1\\*"));
1228 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\BORIS.EXT"));
1229 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FREDRICK.EXT"));
1230 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\PETER.EXT"));
1231 Compare(_L("\\F32-TST\\TFMAN\\After\\*"),_L("\\F32-TST\\TFMAN\\FMAN2\\*"));
1234 // Test wildcards are replaced with letters from the matched file (CFileMan::CreateTargetNameFromSource)
1235 LOCAL_C void TestDEF092084()
1241 test.Next(_L("Test wildcards are replaced with letters from the matched file (DEF092084)"));
1242 MakeDir(_L("\\DEF092084"));
1243 MakeFile(_L("\\DEF092084\\FILE1.TXT"));
1245 TInt r = gFileMan->Rename(_L("\\DEF092084\\*.TXT"),_L("\\DEF092084\\*.DDB"), CFileMan::EOverWrite);
1247 CheckFileExists(_L("\\DEF092084\\FILE1.DDB"), KErrNone);
1249 r = gFileMan->Rename(_L("\\DEF092084\\?*.DD?"),_L("\\DEF092084\\?*.TXT"), CFileMan::EOverWrite);
1251 CheckFileExists(_L("\\DEF092084\\FILE1.TXT"), KErrNone);
1253 RmDir(_L("\\DEF092084\\"));
1256 //---------------------------------------------
1257 //! @SYMTestCaseID PBASE-T_FMAN-0542
1259 //! @SYMREQ INC109754
1260 //! @SYMTestCaseDesc 1. Tests that CFileMan::Rename() does not incorrectly remove empty source directory
1261 //! @SYMTestActions Renames the only file from source directory to target directory, then check if
1262 //! the empty source directory still exists.
1263 //! 2. Tests the trailing backslash ("\") is interpreted to ("\*.*").
1264 //! @SYMTestExpectedResults The operation completes with error code KErrNone;
1265 //! The empty source directory still exists.
1266 //! @SYMTestPriority High
1267 //! @SYMTestStatus Implemented
1268 //---------------------------------------------
1269 void TestINC109754()
1271 test.Next(_L("Test empty source directory should exist after contents being renamed (INC109754)"));
1273 // Setting up comparing dir
1274 RmDir( _L("\\F32-TST\\TFMAN\\INC109754_C\\"));
1275 MakeDir( _L("\\F32-TST\\TFMAN\\INC109754_C\\SRC\\"));
1276 MakeFile( _L("\\F32-TST\\TFMAN\\INC109754_C\\TRG\\FILE.TXT"));
1278 // Setting up testing dir
1279 RmDir( _L("\\F32-TST\\TFMAN\\INC109754\\"));
1280 MakeFile( _L("\\F32-TST\\TFMAN\\INC109754\\SRC\\FILE.TXT"));
1281 MakeDir( _L("\\F32-TST\\TFMAN\\INC109754\\TRG\\"));
1283 // Test case 1: CFileMan::Rename(_L("C:\\SRC\\"), _L("C:\\TRG\\"));
1285 r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\INC109754\\SRC\\"),_L("\\F32-TST\\TFMAN\\INC109754\\TRG\\"));
1287 r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\INC109754\\SRC\\"),_L("\\F32-TST\\TFMAN\\INC109754\\TRG\\"),0,gStat);
1289 Compare(_L("\\F32-TST\\TFMAN\\INC109754\\"), _L("\\F32-TST\\TFMAN\\INC109754_C\\"));
1291 // Setting up testing dir
1292 RmDir( _L("\\F32-TST\\TFMAN\\INC109754\\"));
1293 MakeFile( _L("\\F32-TST\\TFMAN\\INC109754\\SRC\\FILE.TXT"));
1294 MakeDir( _L("\\F32-TST\\TFMAN\\INC109754\\TRG\\"));
1296 // Test case 2: CFileMan::Rename(_L("C:\\SRC\\*.*"), _L("C:\\TRG\\"));
1298 r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\INC109754\\SRC\\*.*"),_L("\\F32-TST\\TFMAN\\INC109754\\TRG\\"));
1300 r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\INC109754\\SRC\\*.*"),_L("\\F32-TST\\TFMAN\\INC109754\\TRG\\"),0,gStat);
1302 Compare(_L("\\F32-TST\\TFMAN\\INC109754\\"), _L("\\F32-TST\\TFMAN\\INC109754_C\\"));
1307 Test code for INC111038() and executed with Cache enabled and FS_NOT_RUGGED.
1309 LOCAL_C void TestINC111038()
1312 test.Next(_L("Test example of incorrect attribute flushing"));
1314 _LIT(KTestFile, "\\TESTFILE.TXT");
1316 test.Printf(_L("1: Create Test File\n"));
1318 r = testFile.Create(TheFs, KTestFile, EFileRead | EFileWrite);
1319 test(r == KErrNone);
1321 test.Printf(_L("2: Populate testFile1 Data\n"));
1322 r = testFile.Write(_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
1323 test(r == KErrNone);
1325 test.Printf(_L("3: Get Initial Attributes\n"));
1327 r = testFile.Att(atts);
1328 test(r == KErrNone);
1329 test.Printf(_L(" Attributes: %08x"), atts);
1331 test.Printf(_L("4: Set KEntryAttHidden Attribute\n"));
1332 r = testFile.SetAtt(KEntryAttHidden, 0);
1333 test(r == KErrNone);
1335 test.Printf(_L("5: Verify KEntryAttHidden Attribute is set for testFile1\n"));
1336 r = testFile.Att(atts);
1337 test(r == KErrNone);
1338 test(atts & KEntryAttHidden);
1340 test.Printf(_L("6: Read Data from beginning of file testFile1\n"));
1342 r = testFile.Read(0, data);
1343 test(r == KErrNone);
1345 test.Printf(_L("7: Close all the testFiles\n"));
1348 test.Printf(_L("8: Verify KEntryAttHidden is present\n"));
1349 r = TheFs.Att(KTestFile, atts);
1350 test(r == KErrNone);
1351 test.Printf(_L(" Finally, attributes are : %08x\n"), atts);
1352 test(atts & KEntryAttHidden);
1354 test.Printf(_L("9: Delete Test File\n"));
1355 r = TheFs.Delete(KTestFile);
1356 test(r == KErrNone || r == KErrNotFound);
1359 LOCAL_C void TestDEF113299()
1361 test.Next(_L("Test invalid file rename (DEF113299)"));
1364 TFileName srcFileName = _L("C:\\F32-TST\\TFMAN\\DEF113299\\src\\corner.html");
1365 TFileName trgFileName = _L("C:\\F32-TST\\TFMAN\\DEF113299\\src\\mi?d**dle.html");
1366 TFileName trgInvalidFileName = _L("C:\\F32-TST\\TFMAN\\DEF113299\\src\\mi?d**dle>.html"); // Invalid filename
1367 TFileName renamedFileName = _L("C:\\F32-TST\\TFMAN\\DEF113299\\src\\mirderdle.html");
1369 RmDir(_L("C:\\F32-TST\\TFMAN\\DEF113299\\"));
1370 MakeFile(srcFileName,_L8("Test Data"));
1372 // Renaming a file with invalid special characters should fail with error code KErrBadName(-28)
1374 err = gFileMan->Rename(srcFileName,trgInvalidFileName);
1376 err = gFileMan->Rename(srcFileName,trgInvalidFileName, 0, gStat);
1377 TestResult(err,KErrBadName);
1380 err = gFileMan->Rename(srcFileName,trgFileName);
1382 err = gFileMan->Rename(srcFileName,trgFileName, 0, gStat);
1383 TestResult(err,KErrNone);
1385 CheckFileExists(renamedFileName,KErrNone,ETrue);
1388 LOCAL_C void TestRename()
1390 // Test rename with wildcards
1393 test.Next(_L("Test rename with wildcards"));
1394 RmDir(_L("\\F32-TST\\TFMAN\\rename\\dest\\"));
1396 MakeDir(_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\"));
1397 MakeDir(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\DirTest\\"));
1398 MakeFile(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\abcDEF.TXT"));
1399 MakeFile(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\abxx.TXT"));
1400 MakeFile(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\HELLO.SPG"));
1401 MakeFile(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\SHEET1.SPR"));
1402 MakeFile(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\DirTest.TXT\\Unchanged.txt"));
1406 if (testingInvalidPathLengths)
1407 // Create a path of greater 256 characters by renaming a directory and check it can be
1408 // manipulated (tests fix to F32)
1410 MakeDir(_L("\\LONGNAME\\"));
1411 MakeDir(_L("\\LONGNAME\\DIRECTORY1DIRECTORY2DIRECTORY3DIRECTORY4\\"));
1412 MakeFile(_L("\\LONGNAME\\ELEPHANT01ELEPHANT02ELEPHANT03ELEPHANT04.txt"));
1413 MakeFile(_L("\\LONGNAME\\DINOSAUR01DINOSAUR02DINOSAUR03DINOSAUR04.txt"));
1414 MakeFile(_L("\\LONGNAME\\FILEFILE01FILEFILE02FILEFILE03FILEFILE04.bin"));
1415 r=gFileMan->Rename(_L("\\LONGNAME"),_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff"),CFileMan::EOverWrite);
1418 // Two long directory names - makes paths invalid
1419 MakeDir(_L("\\TEST\\LONG\\NAME\\FGHIJ"));
1420 MakeDir(_L("\\TEST\\LONG\\NAME\\FGHIJ\\DIRECTORY1DIRECTORY2DIRECTORY3DIRECTORY4\\"));
1421 MakeFile(_L("\\TEST\\LONG\\NAME\\FGHIJ\\ELEPHANT01ELEPHANT02ELEPHANT03ELEPHANT.txt"));
1422 MakeFile(_L("\\TEST\\LONG\\NAME\\FGHIJ\\FILEFILE01FILEFILE02FILEFILE03FILEFILE.txt"));
1423 r=gFileMan->Rename(_L("\\TEST\\LONG"),_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds"),CFileMan::EOverWrite);
1427 //testing invalid source path at the beginning:
1430 r=gFileMan->Rename(_L("::C\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite);
1434 r=gFileMan->Rename(_L("::C\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite,gStat);
1436 TestResult(r,KErrBadName,KErrBadName);
1438 //testing invalid target path at the beginning:
1442 r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("::C\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite);
1446 r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("::C\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite,gStat);
1448 TestResult(r,KErrBadName,KErrBadName);
1450 //testing invalid source path at the middle:
1453 r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\:RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite);
1457 r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\:RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite,gStat);
1459 TestResult(r,KErrBadName,KErrNone);
1461 //testing invalid target path at the middle:
1464 r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\:RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite);
1468 r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\:RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite,gStat);
1470 TestResult(r,KErrBadName,KErrNone);
1472 //testing invalid source path at the end:
1475 r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\:*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite);
1479 r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\:*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite,gStat);
1481 TestResult(r,KErrBadName,KErrNone);
1483 //testing invalid target path at the end:
1486 r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\:*.DDB"),CFileMan::EOverWrite);
1490 r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\:*.DDB"),CFileMan::EOverWrite,gStat);
1492 TestResult(r,KErrBadName,KErrNone);
1496 r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite);
1498 if (testingInvalidPathLengths)
1500 r=gFileMan->Rename(_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\elephant01elephant02elephant03elephant04.txt"),_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\elephant01elephant02elephant03elephant04.bin"));
1501 test(r==KErrBadName);
1502 r=gFileMan->Rename(_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff"),_L("\\Shortened"),CFileMan::EOverWrite);
1504 r=gFileMan->Rename(_L("\\Shortened\\*.txt"),_L("\\Shortened\\*.cat"));
1506 r=gFileMan->RmDir(_L("\\Shortened\\"));
1509 r=gFileMan->Rename(_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds"),_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\NotSoShortened"),CFileMan::EOverWrite);
1511 r=gFileMan->Rename(_L("\\TEST"),_L("\\OXO!"));
1513 r=gFileMan->Rename(_L("\\OXO!\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as"),_L("\\OXO!\\Shorter"));
1515 r=gFileMan->Rename(_L("\\OXO!\\Shorter\\NotSoShortened\\NAME\\FGHIJ\\*.txt"),_L("\\TEST\\Shorter\\NotSoShortened\\NAME\\FGHIJ\\*.cat"));
1517 r=gFileMan->RmDir(_L("\\OXO!\\"));
1524 r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*.TXT"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),CFileMan::EOverWrite,gStat);
1526 if (testingInvalidPathLengths)
1528 r=gFileMan->Rename(_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\elephant01elephant02elephant03elephant04.txt"),_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\elephant01elephant02elephant03elephant04.bin"));
1529 test(r==KErrBadName);
1530 r=gFileMan->Rename(_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff"),_L("\\Shortened"),CFileMan::EOverWrite,gStat);
1532 r=gFileMan->Rename(_L("\\Shortened\\*.txt"),_L("\\Shortened\\*.bin"),0,gStat);
1534 r=gFileMan->RmDir(_L("\\Shortened\\"),gStat);
1537 r=gFileMan->Rename(_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\fdsa21asdffds"),_L("\\TEST\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as\\NotSoShortened"),CFileMan::EOverWrite,gStat);
1540 r=gFileMan->Rename(_L("\\TEST"),_L("\\OXO!"),CFileMan::EOverWrite,gStat);
1543 r=gFileMan->Rename(_L("\\OXO!\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20as"),_L("\\OXO!\\Shorter"),CFileMan::EOverWrite,gStat);
1546 r=gFileMan->Rename(_L("\\OXO!\\Shorter\\NotSoShortened\\NAME\\FGHIJ\\*.txt"),_L("\\TEST\\Shorter\\NotSoShortened\\NAME\\FGHIJ\\*.cat"),CFileMan::EOverWrite,gStat);
1549 r=gFileMan->RmDir(_L("\\OXO!\\"));
1551 r=gFileMan->RmDir(_L("\\TEST\\"));
1555 RmDir(_L("\\F32-TST\\TFMAN\\after\\"));
1556 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\abcDEF.DDB"));
1557 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\abxx.DDB"));
1558 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\DirTest.DDB\\Unchanged.txt"));
1559 Compare(_L("\\F32-TST\\TFMAN\\AFTER\\*"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*"));
1561 RmDir(_L("\\F32-TST\\TFMAN\\after\\"));
1562 MakeDir(_L("\\F32-TST\\TFMAN\\AFTER\\DirTest\\"));
1563 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\HELLO.SPG"));
1564 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\SHEET1.SPR"));
1565 Compare(_L("\\F32-TST\\TFMAN\\AFTER\\*"),_L("\\F32-TST\\TFMAN\\RENAME\\SRC\\*"));
1568 r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.TXT"));
1570 r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.DDB"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*.TXT"),0,gStat);
1573 RmDir(_L("\\F32-TST\\TFMAN\\after\\"));
1574 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\abcDEF.TXT"));
1575 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\abxx.TXT"));
1576 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\DirTest.TXT\\Unchanged.txt"));
1577 Compare(_L("\\F32-TST\\TFMAN\\AFTER\\*"),_L("\\F32-TST\\TFMAN\\RENAME\\DEST\\*"));
1579 test.Next(_L("Test rename case of filenames"));
1580 MakeFile(_L("\\F32-TST\\TFMAN\\CASETEST\\FileName1"));
1583 r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\CASETEST\\FileName1"),_L("\\F32-TST\\TFMAN\\CASETEST\\FILENAME1"));
1585 r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\CASETEST\\FileName1"),_L("\\F32-TST\\TFMAN\\CASETEST\\FILENAME1"),0,gStat);
1587 CheckFileExists(_L("\\F32-TST\\TFMAN\\CASETEST\\FileName1"),KErrNone,EFalse);
1588 CheckFileExists(_L("\\F32-TST\\TFMAN\\CASETEST\\FILENAME1"),KErrNone,ETrue);
1591 r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\CASETEST\\FILENAME1"),_L("\\F32-TST\\TFMAN\\CASETEST\\FILENAME1"),CFileMan::EOverWrite);
1593 r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\CASETEST\\FILENAME1"),_L("\\F32-TST\\TFMAN\\CASETEST\\FILENAME1"),CFileMan::EOverWrite,gStat);
1595 CheckFileExists(_L("\\F32-TST\\TFMAN\\CASETEST\\FILENAME1"),KErrNone,ETrue);
1597 // Test behaviour for omitted parameters
1598 // For this, default should be session path
1599 TFileName sessionPath;
1600 TInt err=TheFs.SessionPath(sessionPath);
1601 test(err==KErrNone);
1603 SetupDirectories(ETrue, NULL);
1604 err=TheFs.SetSessionPath(_L("\\F32-TST\\TFMAN\\dest\\"));
1605 test(err == KErrNone);
1607 err = gFileMan->Rename(_L("\\F32-TST\\TFMAN\\source"), _L(""));
1608 test(err == KErrNone);
1609 Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), _L("\\F32-TST\\TFMAN\\dest\\source\\*"));
1611 RmDir(_L("\\F32-TST\\TFMAN\\dest\\"));
1612 RmDir(_L("\\F32-TST\\TFMAN\\source\\"));
1613 SetupDirectories(ETrue, NULL);
1614 err=TheFs.SetSessionPath(_L("\\F32-TST\\TFMAN\\source\\"));
1615 test(err == KErrNone);
1617 err = gFileMan->Rename(_L(""), _L("\\F32-TST\\TFMAN\\dest\\"));
1618 test(err == KErrNone);
1619 Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), _L("\\F32-TST\\TFMAN\\dest\\*"));
1621 err=TheFs.SetSessionPath(sessionPath);
1622 test(err==KErrNone);
1624 TestINC109754(); // Test empty source directory should exist after contents being renamed
1625 TestDEF092084(); // Test wildcards are replaced with letters from the matched file
1626 TestDEF113299(); // Test invalid file rename
1629 LOCAL_C void TestAttribs()
1634 test.Next(_L("Test set file attributes"));
1635 MakeFile(_L("\\F32-TST\\TFMAN\\ATTRIBS\\Attrib1.AT"));
1636 MakeFile(_L("\\F32-TST\\TFMAN\\ATTRIBS\\Attrib2.at"));
1638 TUint legalAttMask=KEntryAttMaskSupported&~(KEntryAttDir|KEntryAttVolume);
1639 TUint setMask=KEntryAttReadOnly;
1640 TUint clearMask=KEntryAttHidden|KEntryAttArchive;
1643 TInt r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\ATTRIBS\\AT*.AT"),setMask,clearMask,TTime(0));
1648 TInt r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\ATTRIBS\\AT*.AT"),setMask,clearMask,TTime(0),0,gStat);
1653 CDirScan* scan=CDirScan::NewL(TheFs);
1654 scan->SetScanDataL(_L("\\F32-TST\\TFMAN\\ATTRIBS\\*"),KEntryAttMaskSupported,ESortByName);
1656 scan->NextL(entryList);
1657 TInt count=entryList->Count();
1659 TEntry entry=(*entryList)[0];
1660 test(entry.iName.MatchF(_L("attrib1.AT"))!=KErrNotFound);
1661 test(entry.iAtt==KEntryAttReadOnly);
1662 entry=(*entryList)[1];
1663 test(entry.iName.MatchF(_L("attrib2.AT"))!=KErrNotFound);
1664 test(entry.iAtt==KEntryAttReadOnly);
1667 TDateTime dateTime(1990,ENovember,20,9,5,0,0);
1668 TTime time(dateTime); // FAT loses microseconds if try to convert HomeTime()
1672 TInt r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\ATTRIBS\\AT*.AT"),0,legalAttMask,time);
1677 TInt r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\ATTRIBS\\AT*.AT"),0,legalAttMask,time,0,gStat);
1682 scan->SetScanDataL(_L("\\F32-TST\\TFMAN\\ATTRIBS\\*"),KEntryAttMaskSupported,ESortByName);
1683 scan->NextL(entryList);
1684 count=entryList->Count();
1686 entry=(*entryList)[0];
1687 test(entry.iName.MatchF(_L("attrib1.AT"))!=KErrNotFound);
1688 test(entry.iAtt==0);
1689 TDateTime dt=(entry.iModified).DateTime();
1690 test(dt.Year()==dateTime.Year());
1691 test(dt.Month()==dateTime.Month());
1692 test(dt.Day()==dateTime.Day());
1693 test(dt.Hour()==dateTime.Hour());
1694 test(dt.Minute()==dateTime.Minute());
1695 test(dt.Second()==dateTime.Second());
1696 test(entry.iModified==time);
1697 entry=(*entryList)[1];
1698 test(entry.iName.MatchF(_L("attrib2.AT"))!=KErrNotFound);
1699 test(entry.iAtt==0);
1700 test(entry.iModified==time);
1704 TestINC111038(); // Test example of incorrect attribute flushing
1707 LOCAL_C void TestINC091841()
1714 test.Next(_L("Test delete long fullnames (INC091841)"));
1715 MakeDir(_L("\\12345678\\Book\\12345678\\"));
1717 longname.Copy(_L("\\12345678\\Book\\12345678\\12345678901234567890123456789012345678901234567890.x"));
1719 TFileName oldname = longname;
1720 TInt ret = KErrNone;
1721 while(ret == KErrNone)
1724 longname.Append(_L("xxxxx"));
1725 ret = TheFs.Replace(oldname, longname);
1727 if(oldname.Length() >= KMaxFileName-5) // if not, it means that we won't be calling ShrinkNames !!
1729 TInt r = gFileMan->Rename(_L("\\12345678\\Book\\12345678"),_L("\\INC091841\\Book\\012-235-abcd"),0);
1732 r = TheFs.GetDir(_L("\\INC091841\\Book\\012-235-abcd\\"), KEntryAttNormal, ESortNone, dir);
1735 TInt dirlen = sizeof("\\INC091841\\Book\\012-235-abcd\\");
1736 for(TInt i=0; r==KErrNotFound && i<dir->Count(); i++)
1738 if((*dir)[i].iName.Length() + dirlen > oldname.Length())
1745 r = gFileMan->RmDir(_L("\\INC091841\\"));
1748 RmDir(_L("\\12345678\\"));
1751 LOCAL_C void TestRmDir()
1753 // Test rmdir function
1756 test.Next(_L("Test rmdir function"));
1758 MakeDir(_L("\\F32-TST\\TFMAN\\RMDIR\\EMPTY\\"));
1759 MakeFile(_L("\\F32-TST\\TFMAN\\RMDIR\\ALFRED.txt"));
1760 MakeFile(_L("\\F32-TST\\TFMAN\\RMDIR\\RICHARD.txt"));
1761 MakeFile(_L("\\F32-TST\\TFMAN\\RMDIR\\RMSUBDIR1\\RMSUBSUBDIR\\CHARLES.txt"));
1762 MakeFile(_L("\\F32-TST\\TFMAN\\RMDIR\\RMSUBDIR2\\EDMUND.txt"));
1763 MakeDir(_L("\\F32-TST\\TFMAN\\TESTDIR\\"));
1764 MakeFile(_L("\\F32-TST\\TFMAN\\TESTDIR\\DEF123044.txt"));
1768 if (testingInvalidPathLengths)
1769 // Create a path of greater 256 characters by renaming a directory and check it can be
1770 // manipulated (tests fix to F32)
1772 MakeDir(_L("\\LONGNAMETEST\\"));
1773 MakeDir(_L("\\LONGNAMETEST\\DIRECTORY1DIRECTORY2DIRECTORY3DIRECTORY4\\"));
1774 MakeFile(_L("\\LONGNAMETEST\\ELEPHANT01ELEPHANT02ELEPHANT03ELEPHANT04"));
1775 MakeFile(_L("\\LONGNAMETEST\\FILEFILE01FILEFILE02FILEFILE03FILEFILE04"));
1776 r=gFileMan->Rename(_L("\\LONGNAMETEST"),_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff"),CFileMan::EOverWrite);
1780 //testing invalid source path at the beginning:
1783 r=gFileMan->RmDir(_L(":C:\\F32-TST\\TFMAN\\RMDIR\\*.AT"));
1787 r=gFileMan->RmDir(_L(":C:\\F32-TST\\TFMAN\\RMDIR\\*.AT"),gStat);
1789 TestResult(r,KErrBadName,KErrBadName);
1791 //testing invalid source path at the middle:
1794 r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\:RMDIR\\*.AT"));
1798 r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\:RMDIR\\*.AT"),gStat);
1800 TestResult(r,KErrBadName,KErrNone);
1802 //testing invalid source path at the end:
1805 r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\TESTDIR\\:DEF.txt"));
1809 r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\TESTDIR\\:DEF.txt"),gStat);
1811 TestResult(r,KErrNone,KErrNone);
1815 r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\RMDIR\\*.AT"));
1817 if (testingInvalidPathLengths)
1819 r=gFileMan->RmDir(_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\"));
1825 r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\RMDIR\\*.AT"),gStat);
1828 if (testingInvalidPathLengths)
1830 r=gFileMan->RmDir(_L("\\asdffdsa01asdffdsa02asdffdsa03asdffdsa04asdffdsa05asdffdsa06asdffdsa07asdffdsa08asdffdsa09asdffdsa10asdffdsa11asdffdsa12asdffdsa13asdffdsa14asdffdsa15asdffdsa16asdffdsa17asdffdsa18asdffdsa19asdffdsa20asdffdsa21asdffdsa22asdff\\"),gStat);
1837 r=TheFs.Entry(_L("\\F32-TST\\TFMAN\\RMDIR"),entry);
1838 test(r==KErrNotFound);
1840 MakeDir(_L("\\F32-TST\\TFMAN\\READONLY\\"));
1841 r=TheFs.SetAtt(_L("\\F32-TST\\TFMAN\\READONLY\\"),KEntryAttReadOnly,0);
1846 r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\READONLY\\"));
1847 test(r==KErrAccessDenied);
1851 r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\READONLY\\"),gStat);
1853 WaitForResult(KErrAccessDenied);
1856 r=TheFs.SetAtt(_L("\\F32-TST\\TFMAN\\READONLY\\"),0,KEntryAttReadOnly);
1859 r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\READONLY\\"));
1862 // Test behaviour for omitted parameters
1863 // For this, default should be session path
1864 TFileName sessionPath;
1865 r=TheFs.SessionPath(sessionPath);
1868 SetupDirectories(ETrue, NULL);
1869 r=TheFs.SetSessionPath(_L("\\F32-TST\\TFMAN\\source\\"));
1871 // Default removal of session path
1872 r=gFileMan->RmDir(_L(""));
1875 r=TheFs.SetSessionPath(sessionPath);
1877 r = gFileMan->Rename(_L("\\F32-TST\\TFMAN\\source\\subdir"), _L("\\F32-TST\\TFMAN\\source\\tofail"), CFileMan::ERecurse);
1878 test(r == KErrPathNotFound);
1880 r = gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\"));
1882 MakeDir(_L("\\F32-TST\\TFMAN\\"));
1884 if(testingInvalidPathLengths)
1886 TestINC091841(); // Test delete long fullnames
1889 //---------------------------------------------
1890 //! @SYMTestCaseID PBASE-T_FMAN-0316
1892 //! @SYMREQ DEF099820
1893 //! @SYMTestCaseDesc Test that CFileMan::RmDir() works when deleting a directory containing open files.
1894 //! @SYMTestActions Open a file within a directory and try to remove the directory.
1895 //! @SYMTestExpectedResults The operation completes with the error code KErrInUse.
1896 //! @SYMTestPriority High
1897 //! @SYMTestStatus Implemented
1898 //---------------------------------------------
1900 test.Next(_L("Test delete directory containing open files"));
1901 gFileMan->SetObserver(NULL);
1903 MakeDir(_L("\\F32-TST\\TFMAN\\OPENFILE\\"));
1904 MakeFile(_L("\\F32-TST\\TFMAN\\OPENFILE\\FILE.TXT"));
1907 r = file.Open(TheFs,_L("\\F32-TST\\TFMAN\\OPENFILE\\FILE.TXT"), EFileRead | EFileShareExclusive);
1912 r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\OPENFILE\\"));
1917 r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\OPENFILE\\"));
1922 r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\OPENFILE\\"), gStat);
1924 WaitForResult(KErrInUse);
1928 r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\OPENFILE\\"), gStat);
1930 WaitForResult(KErrNone);
1933 gFileMan->SetObserver(gObserver);
1936 LOCAL_C void TestRecursiveCopy()
1938 // Test the recursive copy function
1941 test.Next(_L("Test recursive copy"));
1942 RmDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
1944 MakeDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
1945 MakeDir(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EMPTY\\"));
1946 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"));
1947 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE2.TXT"));
1948 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE3.TXT"));
1949 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\FILE4.TXT"));
1950 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EXE1.BIN"));
1951 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\EXE2.BIN"));
1955 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\"),_L("\\F32-TST\\TFMAN\\COPYDIR"),CFileMan::ERecurse);
1957 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\"),_L("\\F32-TST\\TFMAN\\COPYDIR"),CFileMan::ERecurse,gStat);
1960 Compare(_L("\\F32-TST\\TFMAN\\DELDIR\\*"),_L("\\F32-TST\\TFMAN\\COPYDIR\\*"));
1961 RmDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
1962 MakeDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
1965 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\*.BIN"),_L("\\F32-TST\\TFMAN\\COPYDIR\\*.EXT"),CFileMan::ERecurse);
1967 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\*.BIN"),_L("\\F32-TST\\TFMAN\\COPYDIR\\*.EXT"),CFileMan::ERecurse,gStat);
1968 TestResult(KErrNone);
1970 RmDir(_L("\\F32-TST\\TFMAN\\after\\"));
1971 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\DELTEST\\EXE1.EXT"));
1972 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\EXE2.EXT"));
1973 Compare(_L("\\F32-TST\\TFMAN\\AFTER\\*"),_L("\\F32-TST\\TFMAN\\COPYDIR\\*"));
1975 // Test behaviour for omitted parameters
1976 // For this, default should be session path
1977 TFileName sessionPath;
1978 r=TheFs.SessionPath(sessionPath);
1981 RmDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
1982 MakeDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
1983 r=TheFs.SetSessionPath(_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
1985 // Default copy to session path
1987 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\"),_L(""),CFileMan::ERecurse);
1989 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\"),_L(""),CFileMan::ERecurse,gStat);
1990 TestResult(KErrNone);
1991 Compare(_L("\\F32-TST\\TFMAN\\DELDIR\\*"),_L("\\F32-TST\\TFMAN\\COPYDIR\\*"));
1993 RmDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
1994 MakeDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
1995 r=TheFs.SetSessionPath(_L("\\F32-TST\\TFMAN\\DELDIR\\"));
1997 // Default copy from session path
1999 r=gFileMan->Copy(_L(""),_L("\\F32-TST\\TFMAN\\COPYDIR\\"),CFileMan::ERecurse);
2001 r=gFileMan->Copy(_L(""),_L("\\F32-TST\\TFMAN\\COPYDIR\\"),CFileMan::ERecurse,gStat);
2002 TestResult(KErrNone);
2003 Compare(_L("\\F32-TST\\TFMAN\\DELDIR\\*"),_L("\\F32-TST\\TFMAN\\COPYDIR\\*"));
2005 RmDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
2006 RmDir(_L("\\F32-TST\\TFMAN\\DELDIR\\"));
2007 r=TheFs.SetSessionPath(sessionPath);
2011 LOCAL_C void TestRecursiveAttribs()
2013 // Test set attribs recursively
2016 test.Next(_L("Test recursive attribs"));
2017 MakeFile(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\Attrib1.AT"));
2018 MakeFile(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\Attrib2.at"));
2019 MakeFile(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\SUBDIR\\ATFILE.TXT"));
2023 TInt r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\"),KEntryAttReadOnly,0,TTime(0),CFileMan::ERecurse);
2028 TInt r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\"),KEntryAttReadOnly,0,TTime(0),CFileMan::ERecurse,gStat);
2034 CDirScan* scan=CDirScan::NewL(TheFs);
2035 scan->SetScanDataL(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\*"),KEntryAttMaskSupported,ESortByName);
2036 scan->NextL(entryList);
2037 TInt count=entryList->Count();
2039 TEntry entry=(*entryList)[0];
2040 test(entry.iName.MatchF(_L("ATTRIB1.AT"))!=KErrNotFound);
2041 if (!IsTestingLFFS())
2042 test(entry.iAtt==(KEntryAttReadOnly|KEntryAttArchive));
2044 test(entry.iAtt&KEntryAttReadOnly); // ???
2045 entry=(*entryList)[1];
2046 test(entry.iName.MatchF(_L("ATTRIB2.AT"))!=KErrNotFound);
2047 if (!IsTestingLFFS())
2048 test(entry.iAtt==(KEntryAttReadOnly|KEntryAttArchive));
2050 test(entry.iAtt&KEntryAttReadOnly); // ???
2051 entry=(*entryList)[2];
2052 test(entry.iName.MatchF(_L("SUBDIR"))!=KErrNotFound);
2055 scan->NextL(entryList);
2056 count=entryList->Count();
2058 entry=(*entryList)[0];
2059 test(entry.iName.MatchF(_L("ATFILE.TXT"))!=KErrNotFound);
2060 if (!IsTestingLFFS())
2061 test(entry.iAtt==(KEntryAttReadOnly|KEntryAttArchive));
2063 test(entry.iAtt&KEntryAttReadOnly); // ???
2066 scan->NextL(entryList);
2067 test(entryList==NULL);
2071 TInt r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\"),0,KEntryAttReadOnly|KEntryAttArchive,TTime(0),CFileMan::ERecurse);
2076 TInt r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\"),0,KEntryAttReadOnly|KEntryAttArchive,TTime(0),CFileMan::ERecurse,gStat);
2081 scan->SetScanDataL(_L("\\F32-TST\\TFMAN\\RECATTRIBS\\*"),KEntryAttMaskSupported,ESortByName);
2082 scan->NextL(entryList);
2083 count=entryList->Count();
2085 entry=(*entryList)[0];
2086 test(entry.iName.MatchF(_L("ATTRIB1.AT"))!=KErrNotFound);
2087 test(entry.iAtt==KEntryAttNormal);
2088 entry=(*entryList)[1];
2089 test(entry.iName.MatchF(_L("ATTRIB2.AT"))!=KErrNotFound);
2090 test(entry.iAtt==KEntryAttNormal);
2091 entry=(*entryList)[2];
2092 test(entry.iName.MatchF(_L("SUBDIR"))!=KErrNotFound);
2095 scan->NextL(entryList);
2096 count=entryList->Count();
2098 entry=(*entryList)[0];
2099 test(entry.iName.MatchF(_L("ATFILE.TXT"))!=KErrNotFound);
2100 test(entry.iAtt==KEntryAttNormal);
2103 scan->NextL(entryList);
2104 test(entryList==NULL);
2108 LOCAL_C void TestRecursiveDelete()
2110 // Test Recursive delete
2113 test.Next(_L("Test recursive delete"));
2114 MakeFile(_L("\\F32-TST\\TFMAN\\RECDELETE\\FULL\\GRAPE.TXT"));
2115 MakeFile(_L("\\F32-TST\\TFMAN\\RECDELETE\\FULL\\GRAPE.PLP"));
2116 MakeFile(_L("\\F32-TST\\TFMAN\\RECDELETE\\GRAPE.PLP"));
2117 MakeFile(_L("\\F32-TST\\TFMAN\\RECDELETE\\FILE1.TXT"));
2121 TInt r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\RECDELETE\\*.PLP"),CFileMan::ERecurse);
2126 TInt r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\RECDELETE\\*.PLP"),CFileMan::ERecurse,gStat);
2131 RmDir(_L("\\F32-TST\\TFMAN\\after\\"));
2132 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FULL\\GRAPE.TXT"));
2133 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FILE1.TXT"));
2134 Compare(_L("\\F32-TST\\TFMAN\\after\\*"),_L("\\F32-TST\\TFMAN\\RecDelete\\*"));
2137 LOCAL_C void TestINC108401()
2140 test.Next(_L("Test synchronous and asynchronous move operations (INC108401)"));
2143 TFileName trgPath = _L("?:\\F32-TST\\");
2145 if (gSessionPath[0]!='D'&& gSessionPath[0]!='Y')
2147 #if !defined(__WINS__)
2156 TFileName trgDir = trgPath;
2157 trgDir.Append(_L("TFMAN\\INC108401\\dest\\"));
2159 // Moving files and dirs ACROSS DRIVE.
2161 MakeDir(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\"));
2163 MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file1"));
2164 MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file2"));
2165 MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1"));
2166 MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2"));
2169 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), trgDir, 0);
2170 else // Asynchronously
2171 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), trgDir, 0, gStat);
2172 test.Next(_L("Test INC108401 : ACROSS DRIVES with 0"));
2174 // cleanup the current drive
2176 // remove the F32-TST dir on the C: drive
2177 RmDir(_L("\\F32-TST\\TFMAN\\"));
2180 MakeDir(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\"));
2182 MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file1"));
2183 MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file2"));
2184 MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1"));
2185 MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2"));
2188 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), trgDir, CFileMan::EOverWrite);
2189 else // Asynchronously
2190 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), trgDir, CFileMan::EOverWrite, gStat);
2191 test.Next(_L("Test INC108401 : ACROSS DRIVES with CFileMan::EOverWrite"));
2193 // cleanup the current drive
2195 // remove the F32-TST dir on the C: drive
2196 RmDir(_L("\\F32-TST\\"));
2199 MakeDir(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\"));
2201 MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file1"));
2202 MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file2"));
2203 MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1"));
2204 MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2"));
2207 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), trgDir, CFileMan::ERecurse);
2208 else // Asynchronously
2209 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), trgDir, CFileMan::ERecurse, gStat);
2210 test.Next(_L("Test INC108401 : ACROSS DRIVES with CFileMan::ERecurse"));
2212 // cleanup the current drive
2214 // remove the F32-TST dir on the C: drive
2215 RmDir(_L("\\F32-TST\\"));
2218 // Moving files and dirs on the SAME DRIVE.
2219 // case for gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), 0);
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"));
2228 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), 0);
2229 else // Asynchronously
2230 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), 0, gStat);
2231 test.Next(_L("Test INC108401 : SAME DRIVE with 0"));
2233 // test(err==KErrNone);
2234 RmDir(_L("\\F32-TST\\TFMAN\\INC108401\\"));
2236 // case for gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), CFileMan::EOverWrite);
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"));
2245 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), CFileMan::EOverWrite);
2246 else // Asynchronously
2247 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), CFileMan::EOverWrite, gStat);
2248 test.Next(_L("Test INC108401 : SAME DRIVE with CFileMan::EOverWrite"));
2250 // test(err==KErrNone);
2251 RmDir(_L("\\F32-TST\\TFMAN\\INC108401\\"));
2253 // case for gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), CFileMan::EOverWrite|CFileMan::ERecurse);
2254 MakeDir(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\"));
2255 MakeDir(_L("\\F32-TST\\TFMAN\\INC108401\\dest\\"));
2256 MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file1"));
2257 MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\file2"));
2258 MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file1"));
2259 MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\file2"));
2260 MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\file1"));
2261 MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\file1"));
2262 MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\file1"));
2263 MakeFile(_L("\\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\file1"),_L8("FILE PATH : \\F32-TST\\TFMAN\\INC108401\\src\\subDirA\\subDirB\\subDirC\\file1"));
2266 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), CFileMan::ERecurse|CFileMan::EOverWrite);
2267 else // Asynchronously
2268 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC108401\\src"), _L("\\F32-TST\\TFMAN\\INC108401\\dest\\"), CFileMan::ERecurse|CFileMan::EOverWrite, gStat);
2269 test.Next(_L("Test INC108401 : SAME DRIVES with CFileMan::ERecurse|CFileMan::EOverWrite"));
2271 // test(err==KErrNone);
2272 RmDir(_L("\\F32-TST\\TFMAN\\INC108401\\"));
2274 // cleanup for the current drive
2276 RmDir(_L("\\F32-TST\\"));
2278 test.Printf(_L("Test INC108401 : ends\n"));
2281 LOCAL_C void TestINC089638()
2288 test.Next(_L("Test all items removed from source directory after recursive moving (INC089638)"));
2289 RmDir(_L("\\INC089638\\source\\"));
2290 RmDir(_L("\\INC089638\\dest\\"));
2291 MakeFile(_L("\\INC089638\\source\\file1"));
2292 MakeFile(_L("\\INC089638\\source\\file2"));
2293 MakeFile(_L("\\INC089638\\source\\subdir1\\file3"));
2294 MakeFile(_L("\\INC089638\\source\\subdir1\\file4"));
2295 MakeFile(_L("\\INC089638\\source\\subdir2\\file5"));
2296 MakeFile(_L("\\INC089638\\source\\subdir2\\file6"));
2297 MakeDir(_L("\\INC089638\\dest\\"));
2298 test(TheFs.SetAtt(_L("\\INC089638\\source\\subdir1"), KEntryAttHidden, 0) == KErrNone);
2299 test(TheFs.SetAtt(_L("\\INC089638\\source\\subdir2"), KEntryAttReadOnly, 0) == KErrNone);
2301 TInt r = gFileMan->Move(_L("\\INC089638\\source\\"), _L("\\INC089638\\dest\\"), CFileMan::ERecurse);
2303 r = TheFs.RmDir(_L("\\INC089638\\source\\"));
2306 RmDir(_L("\\INC089638\\"));
2309 void TestINC101379()
2311 test.Next(_L("Test moving of directory to its subdirectory recursively and not recursively (INC101379)"));
2313 _LIT(KSourceDir,"\\INC101379\\dir\\");
2314 _LIT(KFile1, "\\INC101379\\dir\\file1.txt");
2315 _LIT(KFile2, "\\INC101379\\dir\\subdir\\file2.txt");
2316 _LIT(KFile3, "\\INC101379\\dir\\other\\file3.txt");
2317 MakeFile(KFile1, _L8("qwerty"));
2318 MakeFile(KFile2, _L8("abc"));
2319 MakeFile(KFile3, _L8("qwerty"));
2321 dest.Copy(KSourceDir);
2322 dest.Append(_L("subdir"));
2323 gFileMan->SetObserver(NULL);
2325 err = gFileMan->Move(KSourceDir, dest, CFileMan::ERecurse|CFileMan::EOverWrite);
2327 err = gFileMan->Move(KSourceDir, dest, CFileMan::ERecurse|CFileMan::EOverWrite, gStat);
2328 test(err==KErrInUse); // Recursive move prohibited
2330 WaitForResult(KErrInUse);
2331 CheckFileContents(KFile1, _L8("qwerty"));
2332 CheckFileContents(KFile2, _L8("abc"));
2333 CheckFileContents(KFile3, _L8("qwerty"));
2336 err = gFileMan->Move(KSourceDir, dest, CFileMan::EOverWrite);
2338 err = gFileMan->Move(KSourceDir, dest, CFileMan::EOverWrite, gStat);
2339 TestResult(err, KErrNone); // Non-recursive move must be OK
2341 _LIT(KFile1Moved, "\\INC101379\\dir\\subdir\\file1.txt");
2342 CheckFileContents(KFile1Moved, _L8("qwerty"));
2343 CheckFileContents(KFile2, _L8("abc"));
2344 CheckFileContents(KFile3, _L8("qwerty"));
2345 gFileMan->SetObserver(gObserver);
2347 RmDir(_L("\\INC101379\\"));
2350 void TestINC099600() // and INC101061
2352 // Test move files from the internal drive to an external one (INC099600)
2353 // Test move files with system (KEntryAttSystem) or hidden (KEntryAttHidden) attributes (INC101061)
2354 test.Next(_L("Test move files from internal drive to external with system and hidden attributes"));
2355 _LIT(KDest,"C:\\DEST099600\\");
2357 source.Format(_L("%c:\\INC099600\\"), (TUint) gDriveToTest);
2367 TheFs.SetAtt(src, KEntryAttArchive, 0);
2370 TheFs.SetAtt(src, KEntryAttArchive | KEntryAttHidden, 0);
2373 TheFs.SetAtt(src, KEntryAttArchive | KEntryAttHidden | KEntryAttSystem, 0);
2375 src.Append(KPathDelimiter);
2378 TheFs.SetAtt(src, KEntryAttArchive, 0);
2381 TheFs.SetAtt(src, KEntryAttArchive | KEntryAttHidden, 0);
2384 dst.Append(_L("ahsx\\"));
2388 r = gFileMan->Move(src, KDest, 0); // ahsx\ah
2389 test(r == KErrNone);
2390 r = TheFs.Entry(src, entry);
2391 test(r == KErrNotFound);
2393 src.SetLength(src.Length()-1); // ahsx\a
2394 r = gFileMan->Move(src, KDest, 0);
2395 test(r == KErrNone);
2396 r = TheFs.Entry(src, entry);
2397 test(r == KErrNotFound);
2399 src.SetLength(src.Length()-3); // ahs
2400 r = gFileMan->Move(src, KDest, 0);
2401 test(r == KErrNone);
2402 r = TheFs.Entry(src, entry);
2403 test(r == KErrNotFound);
2405 src.SetLength(src.Length()-1); // ah
2406 r = gFileMan->Move(src, KDest, 0);
2407 test(r == KErrAlreadyExists);
2408 r = TheFs.Entry(src, entry);
2409 test(r == KErrNone);
2411 r = gFileMan->Move(src, KDest, CFileMan::EOverWrite); // ah
2412 test(r == KErrNone);
2413 r = TheFs.Entry(src, entry);
2414 test(r == KErrNotFound);
2416 src.SetLength(src.Length()-1); // a
2417 r = gFileMan->Move(src, KDest, 0);
2418 test(r == KErrAlreadyExists);
2419 r = TheFs.Entry(src, entry);
2420 test(r == KErrNone);
2422 r = gFileMan->Move(src, KDest, CFileMan::EOverWrite); // a
2423 test(r == KErrNone);
2424 r = TheFs.Entry(src, entry);
2425 test(r == KErrNotFound);
2431 void SetupDirectoriesForCase0520()
2432 // Setup initial directory structure for test case PBASE-T_FMAN-0520
2434 RmDir( _L("\\F32-TST\\TFMAN\\INC106735\\"));
2435 MakeDir( _L("\\F32-TST\\TFMAN\\INC106735\\"));
2436 MakeFile( _L("\\F32-TST\\TFMAN\\INC106735\\F_ROOT.TXT"), _L8("blahblahblah"));
2437 MakeDir( _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\"));
2438 MakeFile( _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\F_SUB.TXT"), _L8("blahblahblah"));
2439 MakeDir( _L("\\F32-TST\\TFMAN\\INC106735\\SUB01\\"));
2440 MakeFile( _L("\\F32-TST\\TFMAN\\INC106735\\SUB01\\F_SUB01.TXT"), _L8("blahblahblah"));
2441 MakeDir( _L("\\F32-TST\\TFMAN\\INC106735\\SUB01\\SUB02\\"));
2442 MakeFile( _L("\\F32-TST\\TFMAN\\INC106735\\SUB01\\SUB02\\F_SUB02.TXT"), _L8("blahblahblah"));
2445 void SetupDirectoriesForCase0520Compare1()
2446 // Comparing directory structure for recursive Move() without wildcard
2448 RmDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\"));
2449 MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\"));
2450 MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\"));
2451 MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\F_ROOT.TXT"), _L8("blahblahblah"));
2452 MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\F_SUB.TXT"), _L8("blahblahblah"));
2453 MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\"));
2454 MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\F_SUB01.TXT"), _L8("blahblahblah"));
2455 MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\SUB02\\"));
2456 MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\SUB02\\F_SUB02.TXT"), _L8("blahblahblah"));
2459 void SetupDirectoriesForCase0520Compare2()
2460 // Comparing directory structure for recursive Move() with wildcard
2462 RmDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\"));
2463 MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\"));
2464 MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\"));
2465 MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\F_ROOT.TXT"), _L8("blahblahblah"));
2466 MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\F_SUB.TXT"), _L8("blahblahblah"));
2467 MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\SUB01\\F_SUB01.TXT"), _L8("blahblahblah"));
2468 MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\SUB01\\SUB02\\F_SUB02.TXT"), _L8("blahblahblah"));
2469 MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\"));
2470 MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\SUB02\\"));
2473 void SetupDirectoriesForCase0520Compare3()
2474 // Comparing directory structure for recursive Copy() without wildcard
2476 RmDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\"));
2477 MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\"));
2478 MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\F_ROOT.TXT"), _L8("blahblahblah"));
2479 MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\"));
2480 MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\F_ROOT.TXT"), _L8("blahblahblah"));
2481 MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\F_SUB.TXT"), _L8("blahblahblah"));
2482 MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\"));
2483 MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\F_SUB01.TXT"), _L8("blahblahblah"));
2484 MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\SUB02\\"));
2485 MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\SUB02\\F_SUB02.TXT"), _L8("blahblahblah"));
2488 void SetupDirectoriesForCase0520Compare4()
2489 // Comparing directory structure for recursive Copy() with wildcard
2491 RmDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\"));
2492 MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\"));
2493 MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\F_ROOT.TXT"), _L8("blahblahblah"));
2494 MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\"));
2495 MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\F_ROOT.TXT"), _L8("blahblahblah"));
2496 MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\F_SUB.TXT"), _L8("blahblahblah"));
2497 MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\SUB01\\F_SUB01.TXT"), _L8("blahblahblah"));
2498 MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB\\SUB01\\SUB02\\F_SUB02.TXT"), _L8("blahblahblah"));
2499 MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\"));
2500 MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\F_SUB01.TXT"), _L8("blahblahblah"));
2501 MakeDir( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\SUB02\\"));
2502 MakeFile( _L("\\F32-TST\\TFMAN\\INC106735_COM\\SUB01\\SUB02\\F_SUB02.TXT"), _L8("blahblahblah"));
2505 LOCAL_C void TestRecursiveMove()
2507 // Test recursive move
2510 test.Next(_L("Test recursive move"));
2511 RmDir(_L("\\F32-TST\\TFMAN\\RecMove2\\"));
2513 MakeFile(_L("\\F32-TST\\TFMAN\\RECMOVE\\FULL\\FILE2.PLP"));
2514 MakeFile(_L("\\F32-TST\\TFMAN\\RECMOVE\\FULL\\FILE3.PLP"));
2515 MakeFile(_L("\\F32-TST\\TFMAN\\RECMOVE\\FULL\\GRAPE.TXT"));
2516 MakeFile(_L("\\F32-TST\\TFMAN\\RECMOVE\\GRAPE.TXT"));
2517 MakeFile(_L("\\F32-TST\\TFMAN\\RECMOVE\\FILE1.PLP"));
2521 err=gFileMan->Move(_L("\\F32-TST\\TFMAN\\RECMOVE\\*.PLP"),_L("\\F32-TST\\TFMAN\\RECMOVE2\\"),CFileMan::ERecurse);
2523 err=gFileMan->Move(_L("\\F32-TST\\TFMAN\\RECMOVE\\*.PLP"),_L("\\F32-TST\\TFMAN\\RECMOVE2\\"),CFileMan::ERecurse,gStat);
2526 RmDir(_L("\\F32-TST\\TFMAN\\after\\"));
2527 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FULL\\FILE2.PLP"));
2528 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FULL\\FILE3.PLP"));
2529 MakeFile(_L("\\F32-TST\\TFMAN\\AFTER\\FILE1.PLP"));
2530 Compare(_L("\\F32-TST\\TFMAN\\after\\*"),_L("\\F32-TST\\TFMAN\\RecMOve2\\*"));
2533 // Test moving empty directories (DEF073924)
2535 test.Next(_L("Test moving empty directories"));
2537 SetupDirectories(EFalse, NULL);
2539 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\"), _L("\\F32-TST\\TFMAN\\dest\\"), CFileMan::ERecurse);
2540 test(err == KErrNotFound); // Expected - directory is empty
2542 // Test that all directories are still present
2544 err = TheFs.Entry(_L("\\F32-TST\\TFMAN\\source\\"), entry);
2545 test(err == KErrNone);
2546 err = TheFs.Entry(_L("\\F32-TST\\TFMAN\\dest\\"), entry);
2547 test(err == KErrNone);
2549 SetupDirectories(EFalse, NULL);
2551 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source"), _L("\\F32-TST\\TFMAN\\dest\\"), CFileMan::ERecurse);
2552 test(err == KErrNone); // Expected - should move (or rename) directory
2554 // Test directory has been moved
2555 err = TheFs.Entry(_L("\\F32-TST\\TFMAN\\dest\\source\\"), entry);
2556 test(err == KErrNone);
2557 err = TheFs.Entry(_L("\\F32-TST\\TFMAN\\source\\"), entry);
2558 test(err == KErrNotFound);
2560 RmDir(_L("\\F32-TST\\TFMAN\\dest\\source\\"));
2563 // Test moving when the source directory contains subdirectories (INC074828, INC078800)
2565 test.Next(_L("Test moving a directory containing subdirectories"));
2567 SetupDirectories(ETrue, NULL);
2568 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\"), _L("\\F32-TST\\TFMAN\\dest\\"), CFileMan::ERecurse | CFileMan::EOverWrite);
2569 test(err == KErrNone);
2571 Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), _L("\\F32-TST\\TFMAN\\dest\\*"));
2573 //---------------------------------------------
2574 //! @SYMTestCaseID PBASE-T_FMAN-0160
2576 //! @SYMREQ DEF087791
2577 //! @SYMTestCaseDesc Test that CFileMan::Move() works when the destination paths does not exist.
2578 //! @SYMTestActions Copy directory structures to a non-existant directory on the same drive.
2579 //! @SYMTestExpectedResults Completes with no error, files are copied and intermediate directories are created.
2580 //! @SYMTestPriority High
2581 //! @SYMTestStatus Implemented
2582 //---------------------------------------------
2583 test.Next(_L("Test moving when the target directory does not exist"));
2585 SetupDirectories(ETrue, NULL);
2587 RmDir(_L("\\F32-TST\\TFMAN\\dest\\"));
2589 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\"), _L("\\F32-TST\\TFMAN\\dest\\"), CFileMan::ERecurse);
2590 test(err == KErrNone);
2592 Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), _L("\\F32-TST\\TFMAN\\dest\\*"));
2594 SetupDirectories(ETrue, NULL);
2596 RmDir(_L("\\F32-TST\\TFMAN\\dest\\"));
2598 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\"), _L("\\F32-TST\\TFMAN\\dest"), CFileMan::ERecurse);
2599 test(err == KErrNone);
2601 Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), _L("\\F32-TST\\TFMAN\\dest\\*"));
2603 SetupDirectories(ETrue, NULL);
2605 RmDir(_L("\\F32-TST\\TFMAN\\dest\\"));
2607 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source"), _L("\\F32-TST\\TFMAN\\dest\\"), CFileMan::ERecurse);
2608 test(err == KErrNone);
2610 MakeDir(_L("\\F32-TST\\TFMAN\\compare\\subdir\\"));
2611 Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), _L("\\F32-TST\\TFMAN\\dest\\source\\*"));
2612 RmDir(_L("\\F32-TST\\TFMAN\\compare\\subdir\\"));
2614 SetupDirectories(ETrue, NULL);
2616 RmDir(_L("\\F32-TST\\TFMAN\\dest\\"));
2618 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\File1.TXT"), _L("\\F32-TST\\TFMAN\\dest\\"), CFileMan::ERecurse);
2619 test(err == KErrNone);
2621 CheckFileExists(_L("\\F32-TST\\TFMAN\\source\\File1.TXT"), KErrNotFound, ETrue);
2622 CheckFileExists(_L("\\F32-TST\\TFMAN\\dest\\File1.TXT"), KErrNone, ETrue);
2624 RmDir(_L("\\F32-TST\\TFMAN\\dest\\"));
2625 RmDir(_L("\\F32-TST\\TFMAN\\source\\"));
2627 // Test behaviour for omitted parameters
2628 // For this, default should be session path
2629 TFileName sessionPath;
2630 err=TheFs.SessionPath(sessionPath);
2631 test(err==KErrNone);
2633 SetupDirectories(ETrue, NULL);
2634 err=TheFs.SetSessionPath(_L("\\F32-TST\\TFMAN\\dest\\"));
2635 test(err == KErrNone);
2637 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source"), _L(""), CFileMan::ERecurse);
2638 test(err == KErrNone);
2639 Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), _L("\\F32-TST\\TFMAN\\dest\\source\\*"));
2641 RmDir(_L("\\F32-TST\\TFMAN\\dest\\"));
2642 RmDir(_L("\\F32-TST\\TFMAN\\source\\"));
2643 SetupDirectories(ETrue, NULL);
2644 err=TheFs.SetSessionPath(_L("\\F32-TST\\TFMAN\\source\\"));
2645 test(err == KErrNone);
2647 err = gFileMan->Move(_L(""), _L("\\F32-TST\\TFMAN\\dest\\"), CFileMan::ERecurse);
2648 test(err == KErrNone);
2649 Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), _L("\\F32-TST\\TFMAN\\dest\\*"));
2651 err=TheFs.SetSessionPath(sessionPath);
2652 test(err==KErrNone);
2654 //---------------------------------------------
2655 //! @SYMTestCaseID PBASE-T_FMAN-0520
2657 //! @SYMREQ INC106735
2658 //! @SYMTestCaseDesc Test that CFileMan::Move() (recursive mode) works properly when the destination
2659 //! directory is sub-directory of the source directory.
2660 //! (e.g. "C:SRC\\*.TXT" -> "C:\\SRC\\SUB\\")
2661 //! @SYMTestActions Move, copy files recursively from source directory to one of its sub-directory,
2662 //! with or without wildcards applied.
2663 //! @SYMTestExpectedResults Completes with no error, file(s) are moved or copied properly, and no redundant
2664 //! movings or copyings are made for files in destination directory.
2665 //! @SYMTestPriority High
2666 //! @SYMTestStatus Implemented
2667 //---------------------------------------------
2668 test.Next(_L("Test recursive moving and copying to sub-directories"));
2669 // Testing recursive Move() without wildcard
2670 SetupDirectoriesForCase0520();
2671 SetupDirectoriesForCase0520Compare1();
2673 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC106735\\F_ROOT.TXT"), _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\*"), CFileMan::ERecurse);
2675 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC106735\\F_ROOT.TXT"), _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\*"), CFileMan::ERecurse, gStat);
2676 TestResult(err, KErrNone);
2677 Compare(_L("\\F32-TST\\TFMAN\\INC106735\\"), _L("\\F32-TST\\TFMAN\\INC106735_COM\\"));
2679 // Testing recursive Move() with wildcard
2680 SetupDirectoriesForCase0520();
2681 SetupDirectoriesForCase0520Compare2();
2683 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC106735\\*.TXT"), _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\"), CFileMan::ERecurse);
2685 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\INC106735\\*.TXT"), _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\"), CFileMan::ERecurse, gStat);
2686 TestResult(err, KErrNone);
2687 Compare(_L("\\F32-TST\\TFMAN\\INC106735\\"), _L("\\F32-TST\\TFMAN\\INC106735_COM\\"));
2689 // Testing recursive Copy() without wildcard
2690 SetupDirectoriesForCase0520();
2691 SetupDirectoriesForCase0520Compare3();
2693 err = gFileMan->Copy(_L("\\F32-TST\\TFMAN\\INC106735\\F_ROOT.TXT"), _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\"), CFileMan::ERecurse);
2695 err = gFileMan->Copy(_L("\\F32-TST\\TFMAN\\INC106735\\F_ROOT.TXT"), _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\"), CFileMan::ERecurse, gStat);
2696 TestResult(err, KErrNone);
2697 Compare(_L("\\F32-TST\\TFMAN\\INC106735\\"), _L("\\F32-TST\\TFMAN\\INC106735_COM\\"));
2699 // Testing recursive Copy() with wildcard
2700 SetupDirectoriesForCase0520();
2701 SetupDirectoriesForCase0520Compare4();
2703 err = gFileMan->Copy(_L("\\F32-TST\\TFMAN\\INC106735\\*.TXT"), _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\"), CFileMan::ERecurse);
2705 err = gFileMan->Copy(_L("\\F32-TST\\TFMAN\\INC106735\\*.TXT"), _L("\\F32-TST\\TFMAN\\INC106735\\SUB\\"), CFileMan::ERecurse, gStat);
2706 TestResult(err, KErrNone);
2707 Compare(_L("\\F32-TST\\TFMAN\\INC106735\\"), _L("\\F32-TST\\TFMAN\\INC106735_COM\\"));
2709 TestINC089638(); // Test all items removed from source directory after recursive moving
2710 TestINC101379(); // Test moving of directory to its subdirectory recursively and not recursively
2711 TestINC099600(); // and INC101061, Test move files from internal drive to external with system
2712 // and hidden attributes
2717 // A complex test directory structure...
2719 LOCAL_D const TInt KNumFiles = 8;
2720 LOCAL_D const TFileName complexFile[] =
2722 _L("\\F32-TST\\TFMAN\\complex\\dir1\\file1.txt"),
2723 _L("\\F32-TST\\TFMAN\\complex\\dir1\\file2.txt"),
2724 _L("\\F32-TST\\TFMAN\\complex\\dir1\\subdir1\\file3.txt"),
2725 _L("\\F32-TST\\TFMAN\\complex\\dir1\\subdir1\\file4.txt"),
2726 _L("\\F32-TST\\TFMAN\\complex\\dir12\\dir1\\file1.txt"),
2727 _L("\\F32-TST\\TFMAN\\complex\\dir12\\dir1\\file2.txt"),
2728 _L("\\F32-TST\\TFMAN\\complex\\dir12\\dir1\\subdir1\\file3.txt"),
2729 _L("\\F32-TST\\TFMAN\\complex\\dir12\\dir1\\subdir1\\file4.txt")
2733 // The expected result of moving the directory complex\\dir1 into complex\\dir2\\ *without* EOverWrite
2735 LOCAL_D const TInt KNumFilesResult1 = 8;
2736 LOCAL_D const TFileName complexResult1[] =
2738 _L("\\F32-TST\\TFMAN\\complex_result1\\dir1\\file1.txt"),
2739 _L("\\F32-TST\\TFMAN\\complex_result1\\dir1\\file2.txt"),
2740 _L("\\F32-TST\\TFMAN\\complex_result1\\dir1\\subdir1\\file3.txt"),
2741 _L("\\F32-TST\\TFMAN\\complex_result1\\dir1\\subdir1\\file4.txt"),
2742 _L("\\F32-TST\\TFMAN\\complex_result1\\dir12\\dir1\\file1.txt"),
2743 _L("\\F32-TST\\TFMAN\\complex_result1\\dir12\\dir1\\file2.txt"),
2744 _L("\\F32-TST\\TFMAN\\complex_result1\\dir12\\dir1\\subdir1\\file3.txt"),
2745 _L("\\F32-TST\\TFMAN\\complex_result1\\dir12\\dir1\\subdir1\\file4.txt")
2749 // The expected result of moving the directory complex\\dir1 into complex\\dir2\\ *with* EOverWrite
2751 LOCAL_D const TInt KNumFilesResult2 = 4;
2752 LOCAL_D const TFileName complexResult2[] =
2754 _L("\\F32-TST\\TFMAN\\complex_result2\\dir12\\dir1\\file1.txt"),
2755 _L("\\F32-TST\\TFMAN\\complex_result2\\dir12\\dir1\\file2.txt"),
2756 _L("\\F32-TST\\TFMAN\\complex_result2\\dir12\\dir1\\subdir1\\file3.txt"),
2757 _L("\\F32-TST\\TFMAN\\complex_result2\\dir12\\dir1\\subdir1\\file4.txt"),
2762 LOCAL_C void TestRecursiveMoveAcrossDrives()
2764 // Test recursive move across drives
2767 test.Next(_L("Test recursive move across drives"));
2769 TFileName trgDir = _L("\\F32-TST\\TFMAN\\RECMOVE2\\");
2770 TFileName trgSpec = _L("\\F32-TST\\TFMAN\\RECMOVE2\\*");
2772 if (gSessionPath[0]=='C')
2774 #if !defined(__WINS__)
2775 trgDir = _L("D:\\F32-TST\\TFMAN\\RECMOVE2\\");
2776 trgSpec = _L("D:\\F32-TST\\TFMAN\\RECMOVE2\\*");
2778 trgDir = _L("Y:\\F32-TST\\TFMAN\\RECMOVE2\\");
2779 trgSpec = _L("Y:\\F32-TST\\TFMAN\\RECMOVE2\\*");
2785 MakeFile(_L("C:\\F32-TST\\TFMAN\\RECMOVE\\FULL\\FILE2.PLP"));
2786 MakeFile(_L("C:\\F32-TST\\TFMAN\\RECMOVE\\FULL\\FILE3.PLP"));
2787 MakeFile(_L("C:\\F32-TST\\TFMAN\\RECMOVE\\FULL\\GRAPE.TXT"));
2788 MakeFile(_L("C:\\F32-TST\\TFMAN\\RECMOVE\\GRAPE.TXT"));
2789 MakeFile(_L("C:\\F32-TST\\TFMAN\\RECMOVE\\FILE1.PLP"));
2793 err=gFileMan->Move(_L("C:\\F32-TST\\TFMAN\\RECMOVE\\*.PLP"),trgDir,CFileMan::ERecurse);
2795 err=gFileMan->Move(_L("C:\\F32-TST\\TFMAN\\RECMOVE\\*.PLP"),trgDir,CFileMan::ERecurse,gStat);
2796 test.Printf(_L("TestRecursiveMoveAcrossDrives(),gFileMan->Move(),err=%d\n"),err);
2799 RmDir(_L("C:\\F32-TST\\TFMAN\\after\\"));
2800 MakeFile(_L("C:\\F32-TST\\TFMAN\\AFTER\\FULL\\FILE2.PLP"));
2801 MakeFile(_L("C:\\F32-TST\\TFMAN\\AFTER\\FULL\\FILE3.PLP"));
2802 MakeFile(_L("C:\\F32-TST\\TFMAN\\AFTER\\FILE1.PLP"));
2803 Compare(_L("C:\\F32-TST\\TFMAN\\after\\*"),trgSpec);
2804 RmDir(_L("C:\\F32-TST\\TFMAN\\AFTER\\"));
2805 RmDir(_L("C:\\F32-TST\\TFMAN\\RECMOVE\\"));
2808 // Test moving empty directories (DEF073924)
2810 test.Next(_L("Test moving empty directories"));
2812 TFileName destOtherDrive;
2813 SetupDirectories(EFalse, &destOtherDrive);
2815 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\"), destOtherDrive, CFileMan::ERecurse);
2816 test(err == KErrNotFound); // Expected - directory is empty
2818 // Test that all directories are still present
2820 err = TheFs.Entry(_L("\\F32-TST\\TFMAN\\source\\"), entry);
2821 test(err == KErrNone);
2822 err = TheFs.Entry(destOtherDrive, entry);
2823 test(err == KErrNone);
2825 //---------------------------------------------
2826 //! @SYMTestCaseID PBASE-T_FMAN-0571
2828 //! @SYMREQ INC108401
2829 //! @SYMTestCaseDesc This testcase tests the synchronous and asynchronous move operations
2830 //! exhaustively with flags set as 0, CFileMan::EOverWrite, CFileMan::ERecurse
2831 //! on the SAME and ACROSS drives without trailing slash at the end of source
2833 //! @SYMTestActions 1. Copy directory structures to another directory across drive.
2834 //! 2. Copy directory structures to another directory across drive overwriting
2835 //! duplicate files.
2836 //! 3. Copy directory structures to another directory across drive.
2837 //! 4. Copy directory structures to another directory on same drive.
2838 //! 5. Copy directory structures to another directory on same drive overwriting
2839 //! duplicate files.
2840 //! 6. Copy directory structures to another directory on same drive.
2841 //! @SYMTestExpectedResults 1. Completes with no error, the last directory and its contents are moved
2842 //! from the src directory to the destination directory.
2843 //! 2. Completes with no error, the last directory and its contents are moved
2844 //! from the src directory to the destination directory, duplicate files are updated.
2845 //! 3. Completes with no error, the last directory and its contents are moved
2846 //! from the src directory to the destination directory.
2847 //! 4. Completes with no error, the last directory and its contents are moved
2848 //! from the src directory to the destination directory.
2849 //! 5. Completes with no error, the last directory and its contents are moved
2850 //! from the src directory to the destination directory, duplicate files are updated.
2851 //! 6. Completes with no error, the last directory and its contents are moved
2852 //! from the src directory to the destination directory.
2853 //! @SYMTestPriority High
2854 //! @SYMTestStatus Implemented
2855 //---------------------------------------------
2860 // Test moving when the source directory contains subdirectories (INC074828, INC078800)
2862 test.Next(_L("Test moving a directory containing subdirectories"));
2864 SetupDirectories(ETrue, &destOtherDrive);
2865 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\"), destOtherDrive, CFileMan::ERecurse | CFileMan::EOverWrite);
2866 test(err == KErrNone);
2868 destOtherDrive.Append(_L("*"));
2869 Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), destOtherDrive);
2871 //---------------------------------------------
2872 //! @SYMTestCaseID PBASE-T_FMAN-0161
2874 //! @SYMREQ DEF087791
2875 //! @SYMTestCaseDesc Test that CFileMan::Move() works when the destination paths does not exist.
2876 //! @SYMTestActions Copy directory structures to a non-existant directory on a different drive.
2877 //! @SYMTestExpectedResults Completes with no error, files are copied and intermediate directories are created.
2878 //! @SYMTestPriority High
2879 //! @SYMTestStatus Implemented
2880 //---------------------------------------------
2881 test.Next(_L("Test moving when the target directory does not exist"));
2883 SetupDirectories(ETrue, &destOtherDrive);
2885 RmDir(destOtherDrive);
2887 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\"), destOtherDrive, CFileMan::ERecurse);
2888 test(err == KErrNone);
2890 Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), destOtherDrive);
2892 SetupDirectories(ETrue, &destOtherDrive);
2894 RmDir(destOtherDrive);
2896 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source"), destOtherDrive, CFileMan::ERecurse);
2897 test(err == KErrNone);
2899 MakeDir(_L("\\F32-TST\\TFMAN\\compare\\subdir\\"));
2900 destOtherDrive.Append(_L("source\\"));
2901 Compare(_L("\\F32-TST\\TFMAN\\compare\\*"), destOtherDrive);
2902 RmDir(_L("\\F32-TST\\TFMAN\\compare\\subdir\\"));
2904 SetupDirectories(ETrue, &destOtherDrive);
2906 RmDir(destOtherDrive);
2908 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\source\\File1.TXT"), destOtherDrive, CFileMan::ERecurse);
2909 test(err == KErrNone);
2911 CheckFileExists(_L("\\F32-TST\\TFMAN\\source\\File1.TXT"), KErrNotFound, ETrue);
2912 destOtherDrive.Append(_L("File1.TXT"));
2913 CheckFileExists(destOtherDrive, KErrNone, ETrue);
2915 RmDir(destOtherDrive);
2916 RmDir(_L("\\F32-TST\\TFMAN\\source\\"));
2919 // Test recursive move of complex directory structure into itself (INC078759)
2922 test.Next(_L("Test recursive move of complex directory structure"));
2924 // Set up the test directory
2926 for(level=0; level < KNumFiles; level++)
2928 err = TheFs.MkDirAll(complexFile[level]);
2929 test(err == KErrNone || err == KErrAlreadyExists);
2932 err = file.Create(TheFs, complexFile[level], EFileRead | EFileWrite);
2933 test(err == KErrNone || err == KErrAlreadyExists || err == KErrBadName);
2938 // Move directory 'dir1' into 'dir12' *without* overwrite flag set
2940 // - This should fail, as 'dir12' already contains a directory called 'dir1'
2941 // - No directories should be modified
2944 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\complex\\dir1"), _L("\\F32-TST\\TFMAN\\complex\\dir12\\"), CFileMan::ERecurse);
2945 test(err == KErrAlreadyExists);
2947 for(level=0; level < KNumFilesResult1; level++)
2949 err = TheFs.MkDirAll(complexResult1[level]);
2950 test(err == KErrNone || err == KErrAlreadyExists);
2953 err = file.Create(TheFs, complexResult1[level], EFileRead | EFileWrite);
2954 test(err == KErrNone || err == KErrAlreadyExists || err == KErrBadName);
2958 Compare(_L("\\F32-TST\\TFMAN\\complex_result1\\*"), _L("\\F32-TST\\TFMAN\\complex\\*"));
2961 // Move directory 'dir1' into 'dir12' *with* overwrite flag set
2963 err = gFileMan->Move(_L("\\F32-TST\\TFMAN\\complex\\dir1"), _L("\\F32-TST\\TFMAN\\complex\\dir12\\"), CFileMan::ERecurse | CFileMan::EOverWrite);
2964 test(err == KErrNone);
2966 for(level=0; level < KNumFilesResult2; level++)
2968 err = TheFs.MkDirAll(complexResult2[level]);
2969 test(err == KErrNone || err == KErrAlreadyExists);
2972 err = file.Create(TheFs, complexResult2[level], EFileRead | EFileWrite);
2973 test(err == KErrNone || err == KErrAlreadyExists || err == KErrBadName);
2977 Compare(_L("\\F32-TST\\TFMAN\\complex_result2\\*"), _L("\\F32-TST\\TFMAN\\complex\\*"));
2980 for(level=0; level < KNumFiles; level++)
2981 TheFs.Delete(complexFile[level]);
2982 for(level=0; level < KNumFilesResult1; level++)
2983 TheFs.Delete(complexResult1[level]);
2984 for(level=0; level < KNumFilesResult2; level++)
2985 TheFs.Delete(complexResult2[level]);
2987 // ...tidy up directories
2988 for(level=0; level < KNumFiles; level++)
2989 TheFs.RmDir(complexFile[level]);
2990 for(level=0; level < KNumFilesResult1; level++)
2991 TheFs.RmDir(complexResult1[level]);
2992 for(level=0; level < KNumFilesResult2; level++)
2993 TheFs.RmDir(complexResult2[level]);
2995 TheFs.RmDir(_L("C:\\F32-TST\\TFMAN\\"));
2996 TheFs.RmDir(_L("C:\\F32-TST\\"));
2999 class CFileManCopyAllCancel : public CBase, public MFileManObserver
3002 CFileManCopyAllCancel(CFileMan* aFileMan);
3003 TControl NotifyFileManStarted();
3004 TControl NotifyFileManEnded();
3011 CFileManCopyAllCancel::CFileManCopyAllCancel(CFileMan* aFileMan)
3016 __DECLARE_NAME(_S("CFileManCopyAllCancel"));
3020 MFileManObserver::TControl CFileManCopyAllCancel::NotifyFileManStarted()
3022 // Observer for TestCopyAllCancel tests
3025 return(MFileManObserver::ECancel);
3028 MFileManObserver::TControl CFileManCopyAllCancel::NotifyFileManEnded()
3030 // Observer for TestCopyAllCancel tests
3033 return(MFileManObserver::EContinue);
3038 LOCAL_C void TestCopyAllCancel()
3040 // Test copy (all cancel)
3043 test.Next(_L("Test copy all cancel"));
3045 RmDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\*"));
3046 CFileManCopyAllCancel* fManObserver=new(ELeave) CFileManCopyAllCancel(gFileMan);
3047 CleanupStack::PushL(fManObserver);
3048 gFileMan->SetObserver(fManObserver);
3050 MakeDir(_L("\\F32-TST\\TFMAN\\COPYDIR\\"));
3051 MakeDir(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EMPTY\\"));
3052 MakeFile(_L("\\F32-TST\\TFMAN\\NewDir\\ABC.DEF"));
3053 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.TXT"));
3054 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE2.TXT"));
3055 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE3.TXT"));
3056 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\FILE4.TXT"));
3057 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\DELTEST\\EXE1.BIN"));
3058 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\EXE2.BIN"));
3059 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA1.TXT"));
3060 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA2.TXT"));
3061 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA3.TXT"));
3062 MakeFile(_L("\\F32-TST\\TFMAN\\DELDIR\\RUMBA4.TXT"));
3064 test.Next(_L("Test cancel copy all the files "));
3068 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0);
3070 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\file?.txt"),_L("\\F32-TST\\TFMAN\\DELDIR\\rumba?.txt"),0,gStat);
3071 TestResult(r,KErrCancel);
3074 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.txt"),_L("\\F32-TST\\TFMAN\\file1.txt"),0);
3076 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\DELDIR\\FILE1.txt"),_L("\\F32-TST\\TFMAN\\file1.txt"),0,gStat);
3077 TestResult(r,KErrCancel);
3078 gFileMan->SetObserver(gObserver);
3079 CleanupStack::PopAndDestroy();
3082 class CFileManObserverOverWrite : public CBase, public MFileManObserver
3085 CFileManObserverOverWrite(CFileMan* aFileMan);
3086 TControl NotifyFileManEnded();
3092 CFileManObserverOverWrite::CFileManObserverOverWrite(CFileMan* aFileMan)
3097 __DECLARE_NAME(_S("CFileManObserverOverWrite"));
3102 MFileManObserver::TControl CFileManObserverOverWrite::NotifyFileManEnded()
3104 // Observer for testoverwrite tests
3107 TInt lastError=iFileMan->GetLastError();
3108 if (lastError!=KErrNone)
3110 test(lastError==KErrAlreadyExists);
3111 if (gAsynch==EFalse)
3113 TFileName fileName=iFileMan->CurrentEntry().iName;
3114 test.Printf(_L(" %S already exists\n"),&fileName);
3117 return(MFileManObserver::EContinue);
3120 LOCAL_C void TestOverWrite()
3122 // Test overwrite for copy and rename
3125 test.Next(_L("Test overwrite option"));
3126 RmDir(_L("\\F32-TST\\TFMAN\\OVERWRITE\\"));
3127 CFileManObserverOverWrite* fManObserver=new(ELeave) CFileManObserverOverWrite(gFileMan);
3128 CleanupStack::PushL(fManObserver);
3129 gFileMan->SetObserver(fManObserver);
3131 TBuf8<128> contentsFile1=_L8("Test file one contents");
3132 TBuf8<128> contentsFile2=_L8("Test file two contents");
3134 MakeFile(_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\FILE1.TXT"));
3135 MakeFile(_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\FILE2.TXT"));
3136 MakeFile(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC\\FILE1.TXT"),contentsFile1);
3137 MakeFile(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC\\FILE2.TXT"),contentsFile2);
3141 TInt r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC"),_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG"),0);
3142 test(r==KErrAlreadyExists);
3146 TInt r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC"),_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG"),0,gStat);
3148 WaitForResult(KErrAlreadyExists);
3152 TInt r=f.Open(TheFs,_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\FILE1.TXT"),EFileRead);
3157 test(data.Length()==0);
3162 TInt r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC"),_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG"),CFileMan::EOverWrite);
3167 TInt r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC"),_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG"),CFileMan::EOverWrite,gStat);
3172 r=f.Open(TheFs,_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\FILE1.TXT"),EFileRead);
3176 test(data==contentsFile1);
3179 RmDir(_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\"));
3180 MakeFile(_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\FILE1.TXT"));
3181 MakeFile(_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\FILE2.TXT"));
3185 TInt r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC\\*"),_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\*"),0);
3186 test(r==KErrAlreadyExists);
3190 TInt r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC\\*"),_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\*"),0,gStat);
3192 WaitForResult(KErrAlreadyExists);
3195 r=f.Open(TheFs,_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\FILE2.TXT"),EFileRead);
3199 test(data.Length()==0);
3204 TInt r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC\\*"),_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\*"),CFileMan::EOverWrite);
3209 TInt r=gFileMan->Rename(_L("\\F32-TST\\TFMAN\\OVERWRITE\\SRC\\*"),_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\*"),CFileMan::EOverWrite,gStat);
3214 r=f.Open(TheFs,_L("\\F32-TST\\TFMAN\\OVERWRITE\\TRG\\FILE2.TXT"),EFileRead);
3218 test(data==contentsFile2);
3220 gFileMan->SetObserver(gObserver);
3221 CleanupStack::PopAndDestroy();
3224 LOCAL_C void TestErrorHandling()
3226 // Test bad paths etc
3229 test.Next(_L("Test error handling"));
3232 TInt r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\BADPATH\\*"));
3233 test(r==KErrPathNotFound);
3237 TInt r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\BADPATH\\*"),0,gStat);
3239 WaitForResult(KErrPathNotFound);
3242 CFileMan* fMan=CFileMan::NewL(TheFs);
3245 for(TInt drvNum=EDriveA; drvNum<=EDriveZ; ++drvNum)
3248 if(KErrNone==TheFs.Drive(drvInfo, drvNum) && drvInfo.iType==EMediaNotPresent)
3250 // found a non-extant drive, test it...
3251 _LIT(KBad,"?:\\BADPATH\\*");
3253 bad[0] = TUint16('A'+drvNum);
3254 TInt r=fMan->Delete(bad);
3255 test(r==KErrNotReady);
3262 MakeFile(_L("\\ONE\\TWO\\FILE1.TXT"));
3263 MakeFile(_L("\\ONE\\TWO\\FOUR"));
3264 test.Next(_L("Test cyclic copy"));
3266 r=gFileMan->Copy(_L("\\ONE\\TWO\\*"),_L("\\ONE\\TWO\\THREE\\"),CFileMan::ERecurse);
3268 r=gFileMan->Copy(_L("\\ONE\\TWO\\*"),_L("\\ONE\\TWO\\THREE\\"),CFileMan::ERecurse,gStat);
3269 test(r==KErrArgument);
3271 test.Next(_L("Test src name == trg name"));
3274 r=gFileMan->Copy(_L("\\ONE\\TWO\\FOUR"),_L("\\ONE\\TWO\\FOUR")); // default aSwitch=EOverWrite
3276 r=gFileMan->Copy(_L("\\ONE\\TWO\\FOUR"),_L("\\ONE\\TWO\\FOUR"), 0);
3277 test(r==KErrAlreadyExists);
3278 r=gFileMan->Copy(_L("\\ONE\\TWO\\FOUR"),_L("\\ONE\\TWO\\FOUR"),CFileMan::ERecurse);
3279 test(r==KErrAlreadyExists);
3280 r=gFileMan->Copy(_L("\\ONE\\TWO\\F*R"),_L("\\ONE\\TWO\\FOUR"),CFileMan::ERecurse);
3281 test(r==KErrAlreadyExists);
3285 r=gFileMan->Copy(_L("\\ONE\\TWO\\*.TXT"),_L("\\ONE\\TWO\\*.TXT"),0,gStat);
3287 WaitForResult(KErrAlreadyExists);
3288 r=gFileMan->Copy(_L("\\ONE\\TWO\\FOUR"),_L("\\ONE\\TWO\\F*R"),CFileMan::ERecurse,gStat);
3290 WaitForResult(KErrNone);
3292 RmDir(_L("\\ONE\\"));
3294 test.Next(_L("Test copy missing source and path"));
3297 r=gFileMan->Copy(_L("\\ONE\\TWO\\XXXYYY"),_L("\\ONE\\TWO\\asdfsadf"));
3298 test(r==KErrPathNotFound);
3299 r=gFileMan->Copy(_L("\\ONE\\TWO\\XXXYYY"),_L("\\ONE\\TWO\\asdfsadf"),CFileMan::ERecurse);
3300 test(r==KErrPathNotFound);
3304 r=gFileMan->Copy(_L("\\ONE\\TWO\\*.TXT"),_L("\\ONE\\TWO\\*.YYY"),0,gStat);
3306 WaitForResult(KErrPathNotFound);
3307 r=gFileMan->Copy(_L("\\ONE\\TWO\\XXXYYY"),_L("\\ONE\\TWO\\asdfsadf"),CFileMan::ERecurse,gStat);
3309 WaitForResult(KErrPathNotFound);
3312 test.Next(_L("Test copy missing source"));
3315 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\*.LPQ"),_L("\\ONE\\TWO\\*.YYY"));
3316 test(r==KErrNotFound);
3317 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\XXXYYY"),_L("\\ONE\\TWO\\asdfsadf"),CFileMan::ERecurse);
3318 test(r==KErrNotFound);
3322 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\XXXYYY"),_L("\\ONE\\TWO\\asdfsadf"),0,gStat);
3324 WaitForResult(KErrNotFound);
3325 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\XXXYYY"),_L("\\ONE\\TWO\\asdfsadf"),CFileMan::ERecurse,gStat);
3327 WaitForResult(KErrNotFound);
3330 RmDir(_L("\\EMPTYSRC\\"));
3331 MakeDir(_L("\\EMPTYSRC\\"));
3332 RmDir(_L("\\EMPTYTRG\\"));
3333 MakeDir(_L("\\EMPTYTRG\\"));
3334 test.Next(_L("Test copy empty source directory"));
3337 r=gFileMan->Copy(_L("\\EMPTYSRC\\"),_L("\\EMPTYTRG\\"));
3338 test(r==KErrNotFound);
3339 r=gFileMan->Copy(_L("\\EMPTYSRC\\"),_L("\\EMPTYTRG\\"), CFileMan::ERecurse);
3340 test(r==KErrNotFound);
3341 r=gFileMan->Copy(_L("\\EMPTYSRC"),_L("\\EMPTYTRG\\"));
3342 test(r==KErrNotFound);
3343 r=gFileMan->Copy(_L("\\EMPTYSRC"),_L("\\EMPTYTRG\\"), CFileMan::ERecurse);
3344 test(r==KErrNotFound);
3348 r=gFileMan->Copy(_L("\\EMPTYSRC\\"),_L("\\EMPTYTRG\\"), 0, gStat);
3350 WaitForResult(KErrNotFound);
3351 r=gFileMan->Copy(_L("\\EMPTYSRC\\"),_L("\\EMPTYTRG\\"), CFileMan::ERecurse, gStat);
3353 WaitForResult(KErrNotFound);
3354 r=gFileMan->Copy(_L("\\EMPTYSRC"),_L("\\EMPTYTRG\\"), 0, gStat);
3356 WaitForResult(KErrNotFound);
3357 r=gFileMan->Copy(_L("\\EMPTYSRC"),_L("\\EMPTYTRG\\"), CFileMan::ERecurse, gStat);
3359 WaitForResult(KErrNotFound);
3361 RmDir(_L("\\EMPTYSRC\\"));
3362 RmDir(_L("\\EMPTYTRG\\"));
3365 MakeFile(_L("Dummyfile"));
3366 test.Next(_L("Test illegal names"));
3367 r=gFileMan->Attribs(_L(":C:"),0,0,TTime(0),0);
3368 test(r==KErrBadName);
3369 r=gFileMan->Copy(_L(":C:"),_L("newname"),0);
3370 test(r==KErrBadName);
3371 r=gFileMan->Copy(_L("Dummyfile"),_L(":C:"),0);
3372 test(r==KErrBadName);
3373 r=gFileMan->Delete(_L(":C:"),0);
3374 test(r==KErrBadName);
3375 r=gFileMan->Move(_L(":C:"),_L("newname"),0);
3376 test(r==KErrBadName);
3377 r=gFileMan->Move(_L("dummyFile"),_L(":C:"),0);
3378 test(r==KErrBadName);
3379 r=gFileMan->Rename(_L(":C:"),_L("newname"),0);
3380 test(r==KErrBadName);
3381 r=gFileMan->Rename(_L("DummyFile"),_L(":C:"),0);
3382 test(r==KErrBadName);
3383 r=gFileMan->RmDir(_L("\\:C:\\"));
3384 test(r==KErrBadName);
3386 r=gFileMan->Attribs(_L("::C:"),0,0,TTime(0),0);
3387 test(r==KErrBadName);
3388 r=gFileMan->Copy(_L("::C:"),_L("newname"),0);
3389 test(r==KErrBadName);
3390 r=gFileMan->Copy(_L("Dummyfile"),_L("::C:"),0);
3391 test(r==KErrBadName);
3392 r=gFileMan->Delete(_L("::C:"),0);
3393 test(r==KErrBadName);
3394 r=gFileMan->Move(_L("::C:"),_L("newname"),0);
3395 test(r==KErrBadName);
3396 r=gFileMan->Move(_L("dummyFile"),_L("::C:"),0);
3397 test(r==KErrBadName);
3398 r=gFileMan->Rename(_L("::C:"),_L("newname"),0);
3399 test(r==KErrBadName);
3400 r=gFileMan->Rename(_L("DummyFile"),_L("::C:"),0);
3401 test(r==KErrBadName);
3402 r=gFileMan->RmDir(_L("::C:"));
3403 test(r==KErrBadName);
3404 r=TheFs.Delete(_L("DummyFile"));
3406 // test copying two files with identical names that do not exist
3407 _LIT(KNonExistent,"\\azzzz.txt");
3408 r=gFileMan->Copy(KNonExistent,KNonExistent,0);
3409 test(r==KErrNotFound);
3412 LOCAL_C void TestNameMangling()
3414 // Synchronous test of name mangling
3417 test.Next(_L("Test name mangling"));
3418 gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\TRG\\"));
3419 MakeDir(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\TRG\\"));
3420 MakeFile(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\abc.def"));
3421 MakeFile(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\abcdefghijk.def"));
3422 MakeFile(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\abc.defgh"));
3423 MakeFile(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\abcdefghijk.defgh"));
3424 MakeFile(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\zyx.abc.def"));
3425 MakeFile(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\zyx.abcdefghijk.def"));
3426 MakeFile(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\zyx.abc.defgh"));
3427 MakeFile(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\zyx.abcdefghijk.defgh"));
3429 TInt r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\*.*"),_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\TRG\\*.*"));
3431 Compare(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\SRC\\*"),_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\TRG\\*"));
3432 r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\NAMEMANGLER\\TRG\\*.*"));
3436 LOCAL_C void TestLongNames()
3438 // Synchronous test of name mangling
3441 #if defined(__WINS__)
3442 if (gSessionPath[0]=='C')
3446 gFileMan->SetObserver(NULL);
3448 // Format the current drive
3449 Format(CurrentDrive());
3450 // Create Session Path
3451 CreateTestDirectory(_L("\\F32-TST\\TFMAN\\"));
3453 // Create 2 root directories with very long names
3454 TInt longFileLength = KMaxFileName-4;
3455 test.Next(_L("Test methods on long names"));
3456 TFileName longFileNameA;
3457 longFileNameA.SetLength(longFileLength);
3458 longFileNameA.Fill('A',longFileLength);
3459 TFileName longRootDirNameA=_L("\\");
3460 longRootDirNameA+=longFileNameA;
3461 longRootDirNameA+=_L("\\");
3462 TInt r=TheFs.MkDir(longRootDirNameA);
3463 test(r==KErrNone || r==KErrAlreadyExists);
3465 TFileName longFileNameB;
3466 longFileNameB.SetLength(longFileLength);
3467 longFileNameB.Fill('B',longFileLength);
3468 TFileName longRootDirNameB=_L("\\");
3469 longRootDirNameB+=longFileNameB;
3470 longRootDirNameB+=_L("\\");
3471 r=TheFs.MkDir(longRootDirNameB);
3472 test(r==KErrNone || r==KErrAlreadyExists);
3474 TInt longFilePtrLength = KMaxFileName-3; // We do not want the trailing backslash
3475 TPtrC ptrLongFileA(longRootDirNameA.Ptr(),longFilePtrLength);
3476 TPtrC ptrLongFileB(longRootDirNameB.Ptr(),longFilePtrLength);
3478 // TInt CFileMan::Move(const TDesC& anOld,const TDesC& aNew,TUint aSwitch=EOverWrite);
3479 // Tries to move a folder with a long name into another
3480 // This test will return KErrGeneral because the new path will exceed the maximum length
3482 r=gFileMan->Move(ptrLongFileA,ptrLongFileB);
3483 test(r==KErrGeneral);
3485 r=gFileMan->RmDir(longRootDirNameA);
3487 r=gFileMan->Rename(ptrLongFileB,ptrLongFileA);
3489 r=gFileMan->RmDir(longRootDirNameB);
3490 test(r==KErrPathNotFound);
3491 r=gFileMan->RmDir(longRootDirNameA);
3494 TFileName longSubDirName=_L("\\Files\\");
3495 TPtrC longSubDirFileName(longFileNameA.Ptr(),longFilePtrLength-longSubDirName.Length());
3496 longSubDirName+=longSubDirFileName;
3497 longSubDirName+=_L("\\");
3498 r=TheFs.MkDirAll(longSubDirName);
3502 r=TheFs.GetDir(longSubDirName,KEntryAttMaskSupported,0,dirList);
3504 test(dirList->Count()==0);
3507 TPtrC ptrLongSubDirSrc(longSubDirName.Ptr(),longSubDirName.Length()-1);
3508 TPtrC ptrLongSubDirTrg(longRootDirNameA.Ptr(),longRootDirNameA.Length()-1);
3509 r=gFileMan->Copy(ptrLongSubDirSrc,ptrLongSubDirTrg);
3511 r=TheFs.MkDir(longRootDirNameB);
3513 r=gFileMan->Move(ptrLongSubDirSrc,longRootDirNameB);
3514 test(r==KErrBadName);
3515 r=TheFs.RmDir(longRootDirNameB);
3517 test(TheFs.RmDir(longSubDirName) == KErrNone);
3518 test(TheFs.RmDir(_L("\\Files\\")) == KErrNone);
3519 gFileMan->SetObserver(gObserver);
3522 LOCAL_C void TestFileAttributes()
3524 // Test file attributes are copied and new settings
3527 test.Next(_L("Test file attributes are copied"));
3528 gFileMan->Delete(_L("\\F32-TST\\TFMAN\\FILEATT\\TRG\\*.*"));
3529 MakeDir(_L("\\F32-TST\\TFMAN\\FILEATT\\TRG\\"));
3530 MakeFile(_L("\\F32-TST\\TFMAN\\FILEATT\\SRC\\readonly.def"),KEntryAttReadOnly);
3531 MakeFile(_L("\\F32-TST\\TFMAN\\FILEATT\\SRC\\readonlyhidden.def"),KEntryAttReadOnly|KEntryAttHidden);
3532 MakeFile(_L("\\F32-TST\\TFMAN\\FILEATT\\SRC\\hiddensystem.def"),KEntryAttHidden|KEntryAttSystem);
3533 MakeFile(_L("\\F32-TST\\TFMAN\\FILEATT\\SRC\\systemarchive.def"),KEntryAttArchive|KEntryAttSystem);
3535 TInt r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\FILEATT\\SRC\\*.*"),_L("\\F32-TST\\TFMAN\\FILEATT\\TRG\\*.*"));
3537 Compare(_L("\\F32-TST\\TFMAN\\FILEATT\\SRC\\*.*"),_L("\\F32-TST\\TFMAN\\FILEATT\\TRG\\*"));
3538 r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\FILEATT\\SRC\\*"),0,KEntryAttReadOnly,TTime(0));
3540 r=gFileMan->Attribs(_L("\\F32-TST\\TFMAN\\FILEATT\\TRG\\*"),0,KEntryAttReadOnly,TTime(0));
3542 r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\FILEATT\\"));
3546 class CFileManObserverContinue : public CBase, public MFileManObserver
3549 CFileManObserverContinue(CFileMan* aFileMan);
3550 TControl NotifyFileManEnded();
3556 CFileManObserverContinue::CFileManObserverContinue(CFileMan* aFileMan)
3561 __DECLARE_NAME(_S("CFileManObserverOverWrite"));
3566 MFileManObserver::TControl CFileManObserverContinue::NotifyFileManEnded()
3568 // Observer for testoverwrite tests
3571 return(MFileManObserver::EContinue);
3574 LOCAL_C void TestCopyOpenFile()
3576 // Copy a file while it is open
3579 test.Next(_L("Test copying open files"));
3581 CFileManObserverContinue* fManObserver=new(ELeave) CFileManObserverContinue(gFileMan);
3582 gFileMan->SetObserver(fManObserver);
3586 CreateLongName(contents,gSeed,256);
3587 bufPtr.Set((TUint8*)contents.Ptr(),contents.Size());
3589 MakeFile(_L("\\F32-TST\\TFMAN\\FILECOPY\\asdf.asdf"),bufPtr);
3591 TInt r=f.Open(TheFs,_L("\\F32-TST\\TFMAN\\FILECOPY\\asdf.asdf"),EFileRead|EFileShareReadersOnly);
3593 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\FILECOPY\\asdf.asdf"),_L("\\F32-TST\\TFMAN\\FILECOPY\\xxxx.xxxx"));
3596 r=f.Open(TheFs,_L("\\F32-TST\\TFMAN\\FILECOPY\\xxxx.xxxx"),EFileRead);
3598 TBuf8<256*sizeof(TText)> temp;
3604 test(temp.Length()==0);
3607 r=f.Open(TheFs,_L("\\F32-TST\\TFMAN\\FILECOPY\\asdf.asdf"),EFileRead);
3609 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\FILECOPY\\asdf.asdf"),_L("\\F32-TST\\TFMAN\\FILECOPY\\xxxx.xxxx"));
3613 gFileMan->SetObserver(gObserver);
3614 r=gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\FILECOPY\\"));
3616 delete fManObserver;
3619 void TestINC101844()
3621 test.Next(_L("Test move files and subdirs with different attributes (INC101844)"));
3622 _LIT(KDest,"C:\\DEST101844\\");
3624 source.Format(_L("%c:\\INC101844\\"), (TUint) gDriveToTest);
3631 // Create files and subdirs with different attributes
3633 src.Append(_L("file1"));
3634 MakeFile(src, _L8("blah"));
3635 TheFs.SetAtt(src, KEntryAttReadOnly, 0);
3637 src.Append(_L("file2"));
3638 MakeFile(src, _L8("blah"));
3639 TheFs.SetAtt(src, KEntryAttHidden, 0);
3641 src.Append(_L("file3"));
3642 MakeFile(src, _L8("blah"));
3643 TheFs.SetAtt(src, KEntryAttSystem, 0);
3645 src.Append(_L("subdir1\\file4"));
3646 MakeFile(src, _L8("blah"));
3647 TheFs.SetAtt(src, KEntryAttArchive, 0);
3649 src.Append(_L("subdir1"));
3650 TheFs.SetAtt(src, KEntryAttSystem | KEntryAttHidden, KEntryAttArchive);
3652 // Move directory containing files and subdirs with different attributes
3653 r = gFileMan->Move(source, KDest, 0);
3656 // Check that the files and subdirs have moved and have the correct attributes
3659 src.Append(_L("file1"));
3660 r = TheFs.Entry(src, entry);
3661 test(r == KErrNone);
3662 test(entry.iAtt&KEntryAttReadOnly);
3665 src.Append(_L("file2"));
3666 r = TheFs.Entry(src, entry);
3667 test(r == KErrNone);
3668 test(entry.iAtt&KEntryAttHidden);
3671 src.Append(_L("file3"));
3672 r = TheFs.Entry(src, entry);
3673 test(r == KErrNone);
3674 test(entry.iAtt&KEntryAttSystem);
3677 src.Append(_L("subdir1\\"));
3678 r = gFileMan->Move(src, source, 0);
3679 test(r == KErrNone);
3681 r = TheFs.RmDir(src);
3684 src.Append(_L("file4"));
3685 r = TheFs.Delete(src);
3687 r = TheFs.RmDir(source);
3692 LOCAL_C void TestMoveAcrossDrives()
3694 // Move a file from C: to the target drive
3697 test.Next(_L("Test move across drives"));
3699 TFileName trgDrive = _L("\\");
3700 TFileName trgFile = _L("\\Sketch");
3701 TFileName trgDir = _L("\\DRIVEMOVE\\");
3702 TFileName trgDirFile = _L("\\DRIVEMOVE\\Sketch");
3704 if (gSessionPath[0]=='C')
3706 #if !defined(__WINS__)
3707 trgDrive = _L("D:\\");
3708 trgFile = _L("D:\\Sketch");
3709 trgDir = _L("D:\\DRIVEMOVE\\");
3710 trgDirFile = _L("D:\\DRIVEMOVE\\Sketch");
3712 trgDrive = _L("Y:\\");
3713 trgFile = _L("Y:\\Sketch");
3714 trgDir = _L("Y:\\DRIVEMOVE\\");
3715 trgDirFile = _L("Y:\\DRIVEMOVE\\Sketch");
3720 RmDir(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\"));
3722 MakeFile(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\Sketch"));
3724 // Move Sketch from the source to target
3725 TInt r = gFileMan->Move(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\Sketch"),trgDrive);
3726 test.Printf(_L("TestMoveAcrossDrives(),gFileMan->Move(),r=%d\n"),r);
3727 // Check Sketch no longer exists on source drive
3728 CheckFileExists(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\Sketch"),KErrNotFound);
3729 // Check Sketch exists on target drive
3730 CheckFileExists(trgFile,KErrNone);
3732 MakeFile(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\Sketch"));
3733 // Move Directory DRIVEMOVE from the source to target
3734 r = gFileMan->Move(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE"),trgDrive);
3735 test.Printf(_L("TestMoveAcrossDrives(),gFileMan->Move(),r=%d\n"),r);
3736 // Check DRIVEMOVE no longer exists on source drive
3737 CheckFileExists(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\Sketch"),KErrPathNotFound);
3738 // Check Sketch exists on target drive
3739 CheckFileExists(trgDirFile,KErrNone);
3742 test(TheFs.Delete(trgFile) == KErrNone);
3744 TestINC101844(); // Test move files and subdirs with different attributes
3747 class CFileManObserverCopyAbort : public CBase, public MFileManObserver
3750 CFileManObserverCopyAbort(CFileMan* aFileMan);
3751 TControl NotifyFileManEnded();
3752 void SetAbortStep(TInt aAbortStep);
3759 CFileManObserverCopyAbort::CFileManObserverCopyAbort(CFileMan* aFileMan)
3763 : iFileMan(aFileMan),
3766 __DECLARE_NAME(_S("CFileManObserverCopyAbort"));
3770 void CFileManObserverCopyAbort::SetAbortStep(TInt aAbortStep)
3772 // Set the step at which to cancel the operation
3775 iCurrentStep = aAbortStep;
3779 MFileManObserver::TControl CFileManObserverCopyAbort::NotifyFileManEnded()
3781 // Observer for testoverwrite tests
3784 TInt lastError = iFileMan->GetLastError();
3785 test(lastError == KErrNone);
3788 iFileMan->GetCurrentSource(srcfile);
3790 TInt action = iFileMan->CurrentAction();
3791 test(action == CFileMan::EMove ||
3792 action == CFileMan::EDelete ||
3793 action == CFileMan::ERmDir);
3796 return(iCurrentStep ? MFileManObserver::EContinue : MFileManObserver::EAbort);
3799 LOCAL_C void TestAbortedMoveAcrossDrives()
3801 // Move a file from C: to D: or Y:, and test various cancel conditions
3804 test.Next(_L("Test cancel move across drives"));
3806 const TInt KNumFiles = 5;
3808 TFileName trgDirRoot = _L("\\F32-TST\\TFMAN\\");
3809 TFileName trgDirFull = _L("\\F32-TST\\TFMAN\\CANCELMOVE\\");
3810 TFileName trgDirFile = _L("\\F32-TST\\TFMAN\\CANCELMOVE\\FILE");
3812 if (gSessionPath[0]=='C')
3814 #if !defined(__WINS__)
3815 trgDirRoot = _L("D:\\F32-TST\\TFMAN\\");
3816 trgDirFull = _L("D:\\F32-TST\\TFMAN\\CANCELMOVE\\");
3817 trgDirFile = _L("D:\\F32-TST\\TFMAN\\CANCELMOVE\\FILE");
3819 trgDirRoot = _L("Y:\\F32-TST\\TFMAN\\");
3820 trgDirFull = _L("Y:\\F32-TST\\TFMAN\\CANCELMOVE\\");
3821 trgDirFile = _L("Y:\\F32-TST\\TFMAN\\CANCELMOVE\\FILE");
3825 gFileMan->RmDir(_L("C:\\F32-TST\\TFMAN\\CANCELMOVE\\"));
3827 CFileManObserverCopyAbort* fManObserver=new(ELeave) CFileManObserverCopyAbort(gFileMan);
3828 CleanupStack::PushL(fManObserver);
3830 // Check that source files exist when interrupting the copy step
3833 for(step = 1; step <= KNumFiles+1; ++step)
3835 for (i = 0; i < KNumFiles; i++)
3837 TFileName sourceFile =_L("C:\\F32-TST\\TFMAN\\CANCELMOVE\\FILE");
3838 sourceFile.AppendNum(i);
3839 sourceFile.Append(_L(".TXT"));
3840 MakeFile(sourceFile);
3843 gFileMan->RmDir(trgDirFull);
3845 fManObserver->SetAbortStep(step);
3846 gFileMan->SetObserver(fManObserver);
3850 r=gFileMan->Move(_L("C:\\F32-TST\\TFMAN\\CANCELMOVE"),trgDirRoot, CFileMan::EOverWrite);
3852 r=gFileMan->Move(_L("C:\\F32-TST\\TFMAN\\CANCELMOVE"),trgDirRoot, CFileMan::EOverWrite, gStat);
3854 test.Printf(_L("TestAbortedMoveAcrossDrives(),gFileMan->Move(),r=%d\n"),r);
3855 TestResult(r, (step <= KNumFiles) ? KErrCancel : KErrNone);
3857 gFileMan->SetObserver(NULL);
3859 // Check that the expected target files exist...
3860 CheckFileExists(trgDirFull, KErrNone, EFalse);
3861 for (i = 0; i < Min(step, KNumFiles); i++)
3863 TFileName trgAfterFile = trgDirFile;
3864 trgAfterFile.AppendNum(i);
3865 trgAfterFile.Append(_L(".TXT"));
3866 CheckFileExists(trgAfterFile, KErrNone);
3869 // Check that the expected source files still exist after the abort...
3870 CheckFileExists(_L("C:\\F32-TST\\TFMAN\\CANCELMOVE\\"), (step <= KNumFiles) ? KErrNone : KErrNotFound, EFalse);
3871 for (; i < KNumFiles; i++)
3873 TFileName srcAfterFile =_L("C:\\F32-TST\\TFMAN\\CANCELMOVE\\FILE");
3874 srcAfterFile.AppendNum(i);
3875 srcAfterFile.Append(_L(".TXT"));
3876 CheckFileExists(srcAfterFile, KErrNone);
3880 gFileMan->SetObserver(NULL);
3881 CleanupStack::PopAndDestroy();
3883 RmDir(trgDirRoot); // "?:\\F32-TST\\TFMAN\\"
3884 TheFs.RmDir(trgDirRoot.Left(16));
3885 TheFs.RmDir(trgDirRoot.Left(10));
3886 TheFs.RmDir(_L("C:\\F32-TST\\TFMAN\\"));
3887 TheFs.RmDir(_L("C:\\F32-TST\\"));
3891 LOCAL_C void TestMoveEmptyDirectory()
3893 // "Try to move an empty directory C:\F32-TST\TFMAN\DRIVEMOVE\ to C:\"
3896 test.Next(_L("Test move empty directory"));
3898 #if !defined(__WINS__)
3899 TFileName trgDrive=_L("D:\\");
3901 if (gSessionPath[0]!='C')
3903 TFileName trgDrive=_L("C:\\");
3906 MakeDir(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\"));
3907 TInt r=gFileMan->Move(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\*"),trgDrive,CFileMan::ERecurse);
3908 test.Printf(_L("TestMoveEmptyDirectory(),gFileMan->Move(),r=%d\n"),r);
3909 test (r==KErrNotFound);
3912 LOCAL_C void TestCopyAndRename()
3914 // Rename while copying files and directories
3917 test.Next(_L("Test rename while copying files and directories"));
3918 gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\CPMV"));
3919 MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\ONE\\ONE_1.TXT"));
3920 MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\ONE\\ONE_2.TXT"));
3921 MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\ONE\\ONE_3.TXT"));
3922 MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\ONE\\TWOTWO.TWO"));
3923 MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\ONE_4.TXT"));
3924 MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\ONE_5.TXT"));
3925 MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\TWO.TXT"));
3926 MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\TWO.GOD"));
3927 MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\TWO.BAD"));
3929 TInt r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\TWO.*"), _L("\\F32-TST\\TFMAN\\THREE.*"), CFileMan::ERecurse);
3932 CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE.TXT"), KErrNone);
3933 CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE.GOD"), KErrNone);
3934 CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE.BAD"), KErrNone);
3935 r=gFileMan->Delete(_L("\\F32-TST\\TFMAN\\CPMV\\THREE.*"));
3938 MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\TWO2\\TWO__1.TXT"));
3939 MakeFile(_L("\\F32-TST\\TFMAN\\CPMV\\TWO2\\TWO__2.TXT"));
3941 // copy and rename dir
3942 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\CPMV\\TWO2"), _L("\\F32-TST\\TFMAN\\CPMV\\THREE"), CFileMan::ERecurse);
3944 Compare(_L("\\F32-TST\\TFMAN\\CPMV\\TWO2\\*"), _L("\\F32-TST\\TFMAN\\CPMV\\THREE\\*"));
3946 // copy and move into another dir
3947 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\CPMV\\TWO2"), _L("\\F32-TST\\TFMAN\\CPMV\\THREE\\TWO"), CFileMan::ERecurse);
3949 Compare(_L("\\F32-TST\\TFMAN\\CPMV\\TWO2\\*"), _L("\\F32-TST\\TFMAN\\CPMV\\THREE\\TWO\\*"));
3951 // copy and rename files and dirs in current dir
3952 r=gFileMan->Copy(_L("\\F32-TST\\TFMAN\\CPMV\\TWO*"), _L("\\F32-TST\\TFMAN\\CPMV\\THREE*"), CFileMan::ERecurse);
3954 // Compare(_L("\\F32-TST\\TFMAN\\CPMV\\TWO2\\*"), _L("\\F32-TST\\TFMAN\\CPMV\\THREE2\\*"));
3956 CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\ONE\\THREEO.TWO"), KErrNone);
3957 CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE\\TWO__1.TXT"), KErrNone);
3958 CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE\\TWO__2.TXT"), KErrNone);
3959 CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE.TXT"), KErrNone);
3960 CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE.BAD"), KErrNone);
3961 CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE.GOD"), KErrNone);
3962 CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE\\THREE1.TXT"), KErrNone);
3963 CheckFileExists(_L("\\F32-TST\\TFMAN\\CPMV\\THREE\\THREE2.TXT"), KErrNone);
3965 gFileMan->RmDir(_L("\\F32-TST\\TFMAN\\CPMV\\"));
3968 void TestStackUsage(TInt aLevel, TThreadStackInfo& aStack)
3971 _LIT(KDir, "\\DEF104115\\");
3972 _LIT(KFile1, "\\DEF104115\\file1veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryverylong.txt");
3973 _LIT(KFile2, "\\DEF104115\\SUBDIR\\longfile2.txt");
3977 test.Next(_L("Test stack usage"));
3979 MakeFile(KFile1, _L8("123456789012345678901234567890"));
3986 TInt stacksize = aStack.iBase - aStack.iLimit;
3987 start = (char*)aStack.iLimit;
3988 end = (char*)&stacksize;
3989 available = (TInt)end - (TInt)start;
3991 if(available > 6 * 1024) // X86 uses about twice as much stack as ARM in debug mode, so double the number.
3993 if(available > 3 * 1024) // don't touch this constant ... fix CFileMan instead!!
3996 TestStackUsage(aLevel+1, aStack);
4000 test.Printf(_L("Level:%d Available:%d\n"), aLevel, available);
4002 gFileMan->SetObserver(NULL);
4004 r = gFileMan->Attribs(KDir, 0, 0, 0, CFileMan::ERecurse);
4008 r = gFileMan->Move(KFile1, KFile2, CFileMan::ERecurse);
4009 test(r==KErrAlreadyExists);
4011 r = gFileMan->Move(KFile1, KFile2, CFileMan::ERecurse | CFileMan::EOverWrite);
4015 r = gFileMan->Copy(KFile2, KFile1, CFileMan::ERecurse);
4019 r = gFileMan->Rename(KFile1, KFile2, 0);
4020 test(r==KErrAlreadyExists);
4022 r = gFileMan->Rename(KFile1, KFile2, CFileMan::EOverWrite);
4026 r = gFileMan->Delete(KFile2, CFileMan::ERecurse);
4030 r = gFileMan->RmDir(KDir);
4033 gFileMan->SetObserver(gObserver);
4036 LOCAL_C void InitialiseL()
4038 // Set up test variables
4041 gFileMan=CFileMan::NewL(TheFs);
4042 gObserver=new(ELeave) CFileManObserver(gFileMan);
4043 gFileMan->SetObserver(gObserver);
4046 LOCAL_C void Cleanup()
4048 // Cleanup test variables
4055 LOCAL_C void SetupDirStructure(TFileName& aSrcPath,TFileName& aTrgPath)
4057 TFileName tmpName = aSrcPath;
4059 // Create the TrgPath dirs
4062 // Create the aSrcPath dirs
4064 tmpName.Append(_L("EmptyDir01\\"));
4068 tmpName.Append(_L("EmptyDir02\\"));
4072 tmpName.Append(_L("EmptyDir03\\"));
4076 tmpName.Append(_L("FILE01.TXT"));
4080 tmpName.Append(_L("FILE02.TXT"));
4084 tmpName.Append(_L("FILE03.TXT"));
4088 tmpName.Append(_L("SubDir01\\EmptyDir01\\"));
4092 tmpName.Append(_L("SubDir02\\EmptyDir02\\"));
4096 tmpName.Append(_L("SubDir03\\EmptyDir03\\"));
4100 tmpName.Append(_L("SubDir01\\FILE01.TXT"));
4104 tmpName.Append(_L("SubDir01\\FILE02.TXT"));
4108 tmpName.Append(_L("SubDir01\\FILE03.TXT"));
4112 tmpName.Append(_L("SubDir02\\FILE01.TXT"));
4116 tmpName.Append(_L("SubDir02\\FILE02.TXT"));
4120 tmpName.Append(_L("SubDir02\\FILE03.TXT"));
4124 tmpName.Append(_L("SubDir03\\FILE01.TXT"));
4128 tmpName.Append(_L("SubDir03\\FILE02.TXT"));
4132 tmpName.Append(_L("SubDir03\\FILE03.TXT"));
4136 LOCAL_C void TestPDEF112148()
4138 test.Next(_L("Test recursive and non-recursive move across drives (PDEF112148)"));
4143 trgPath.Format(_L("%c:\\F32-TST\\TFMAN\\PDEF112148\\dest\\"), (TUint8)gDriveToTest);
4144 TFileName srcPath = _L("C:\\F32-TST\\TFMAN\\PDEF112148\\src\\");
4146 // Non-Recursive move
4147 // clean up before testing
4150 // Setup the directory structure
4151 SetupDirStructure(srcPath, trgPath);
4153 err = gFileMan->Move(srcPath, trgPath, 0);
4155 err = gFileMan->Move(srcPath, trgPath, 0, gStat);
4158 // Verify src contents after move operation
4160 err = TheFs.GetDir(srcPath, KEntryAttMaskSupported, ESortNone, dir);
4161 test(6 == dir->Count());
4163 // Verify dest contents after move operation
4164 err = TheFs.GetDir(trgPath, KEntryAttMaskSupported, ESortNone, dir);
4165 test(3 == dir->Count());
4168 // Recursive move with "\\" at the end of srcPath
4169 // clean up before execution
4172 // Setup the directory structure
4173 SetupDirStructure(srcPath, trgPath);
4175 err = gFileMan->Move(srcPath, trgPath, CFileMan::ERecurse);
4177 err = gFileMan->Move(srcPath, trgPath, CFileMan::ERecurse, gStat);
4180 // Verify src has no content
4181 err = TheFs.GetDir(srcPath, KEntryAttMaskSupported, ESortNone, dir);
4182 test(0 == dir->Count());
4184 // Verify dest contents after move operation
4185 err = TheFs.GetDir(trgPath, KEntryAttMaskSupported, ESortNone, dir);
4186 test(9 == dir->Count());
4189 // Recursive move without "\\" at the end of srcPath
4190 // clean up before execution
4193 // Setup the directory structure
4194 SetupDirStructure(srcPath, trgPath);
4195 // Remove the "\\" at the end of srcPath for Recursive Move
4196 srcPath.Delete(srcPath.Length()-1,1);
4198 err = gFileMan->Move(srcPath, trgPath, CFileMan::ERecurse);
4200 err = gFileMan->Move(srcPath, trgPath, CFileMan::ERecurse, gStat);
4203 // Add the "\\" at the end of srcPath for verification
4204 srcPath.Append(KPathDelimiter);
4205 // Verify src doesnt not exist
4206 err = gFileMan->RmDir(srcPath);
4207 test(err==KErrPathNotFound); // KErrPathNotFound expected as src has been moved to dest
4208 // Verify dest after move operation
4209 err = TheFs.GetDir(trgPath, KEntryAttMaskSupported, ESortNone, dir);
4210 test(1 == dir->Count());
4213 // clean up before leaving
4217 //---------------------------------------------
4218 //! @SYMTestCaseID PBASE-T_FMAN-2398
4220 //! @SYMREQ DEF130678
4221 //! @SYMTestCaseDesc Tests that CFileMan::Move itself does not leak any memory
4222 //! @SYMTestActions Move files and keep checking the memory usage for each operation.
4223 //! @SYMTestExpectedResults Test completes without any crash and hence without any memory leak.
4224 //! @SYMTestPriority High
4225 //! @SYMTestStatus Implemented
4226 //---------------------------------------------
4227 void TestDEF130678()
4229 test.Next(_L("Test CFileMan::Move does not leak any memory"));
4230 _LIT(KFromFile,"C:\\TestDEF130678\\FROM\\from_");
4231 _LIT(KToFile,"C:\\TestDEF130678\\TO\\");
4234 // choose a number that certainly tests all memory allocations.
4235 // it is used for memory allocation failure simulation.
4238 for(run=1; run<=maxRun; ++run)
4240 TInt err = KErrNone;
4241 TFileName fromFile, toFile;
4243 fromFile.Append(KFromFile);
4244 fromFile.AppendNum(run);
4245 fromFile.Append(_L(".txt"));
4248 MakeDir(_L("C:\\TestDEF130678\\FROM\\"));
4249 MakeDir(_L("C:\\TestDEF130678\\TO\\"));
4250 toFile.Append(KToFile);
4252 // Check the memory usage
4254 // set to fail every run-th memory allocation
4255 __UHEAP_SETFAIL(RAllocator::EDeterministic, run);
4257 CFileMan* fileMan = NULL;
4258 TInt errTrap1 = KErrNone;
4259 TRAP(errTrap1,(fileMan=CFileMan::NewL(TheFs)));
4260 if (errTrap1 != KErrNone)
4262 // reset the memory allocation failure and check for any leak
4268 CleanupStack::PushL(fileMan);
4269 TInt errTrap2 = KErrNone;
4270 TRAP(errTrap2,(err = fileMan->Move(fromFile,toFile)));
4271 if (errTrap2 != KErrNone || err != KErrNone)
4273 CleanupStack::PopAndDestroy(fileMan);
4274 // reset the memory allocation failure and check for any leak
4279 CleanupStack::PopAndDestroy(fileMan);
4280 // reset the memory allocation failure and check for any leak
4283 } // End of OOM loop
4286 RmDir(_L("C:\\TestDEF130678\\"));
4289 GLDEF_C void CallTestsL()
4294 // T_FMAN is independent of all tests so format first
4296 Format(CurrentDrive());
4300 CreateTestDirectory(_L("\\F32-TST\\TFMAN\\"));
4301 // May not be able to test handling of invalid path lengths because F32 fix
4302 // to prevent paths >256 ever being created
4303 testingInvalidPathLengths = CheckIfShortPathsAreSupported();
4305 //-----------------------------------------------------------------------------------
4306 // Asynchronous tests
4309 test.Next(_L("Asynchronous tests ..."));
4310 TheFs.SetAllocFailure(gAllocFailOff);
4313 test(HAL::Get(HAL::EMachineUid,uid)==KErrNone);
4314 TBool doTargetTests = (!IsTestingLFFS() &&
4315 uid!=HAL::EMachineUid_Cogent &&
4316 uid!=HAL::EMachineUid_IQ80310 &&
4317 uid!=HAL::EMachineUid_X86PC);
4321 TestMoveAcrossDrives();
4322 TestRecursiveMoveAcrossDrives();
4323 TestMoveEmptyDirectory();
4324 TestAbortedMoveAcrossDrives();
4325 TestPDEF112148(); // Test recursive and non-recursive move across drives
4330 TestErrorHandling();
4332 TestRecursiveMove();
4333 TestRecursiveDelete();
4334 TestRecursiveAttribs();
4335 TestRecursiveCopy();
4341 if (!IsTestingLFFS())
4344 TestCopyAllCancel();
4346 //-----------------------------------------------------------------------------------
4347 // Synchronous tests
4350 test.Next(_L("Synchronous tests ..."));
4351 TheFs.SetAllocFailure(gAllocFailOn);
4355 TestMoveAcrossDrives();
4356 TestRecursiveMoveAcrossDrives();
4357 TestMoveEmptyDirectory();
4358 TestAbortedMoveAcrossDrives();
4359 TestPDEF112148(); // Test recursive and non-recursive move across drives
4363 if(testingInvalidPathLengths)
4366 TestFileAttributes();
4369 TestErrorHandling();
4370 TestRecursiveMove();
4371 TestRecursiveDelete();
4372 TestRecursiveAttribs();
4373 TestRecursiveCopy();
4380 TestCopyAndRename();
4381 TestCopyAllCancel();
4383 TestDEF130678(); // Test CFileMan::Move does not leak any memory
4386 TThreadStackInfo stack;
4387 test(t.StackInfo(stack)==KErrNone);
4388 TestStackUsage(0, stack);
4392 DeleteTestDirectory();
4393 test(TheFs.RmDir(_L("\\F32-TST\\")) == KErrNone);