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