os/kernelhwsrv/kerneltest/f32test/rofs/src/t_rofsdir.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Test traversal of directories and locating files in directories
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <e32std.h>
sl@0
    19
#include <e32std_private.h>
sl@0
    20
#define __E32TEST_EXTENSION__
sl@0
    21
#include <e32test.h>
sl@0
    22
#include <f32file.h>
sl@0
    23
#include "utl.h"
sl@0
    24
sl@0
    25
GLREF_D RFs TheFs;
sl@0
    26
sl@0
    27
RTest	test( _L("T_ROFSDIR") );
sl@0
    28
sl@0
    29
_LIT( KTestFile1, "root.txt" );
sl@0
    30
_LIT( KTestFile2, "Dir1\\level1.txt" );
sl@0
    31
_LIT( KTestFile3, "Dir1\\Dir2\\level2.txt" );
sl@0
    32
_LIT( KTestFile4, "Dir1\\Dir2\\Dir3\\level3.txt" );
sl@0
    33
_LIT( KTestFile5, "Dir1\\Dir2\\Dir3\\Dir4\\level4.txt" );
sl@0
    34
_LIT( KTestFile6, "Dir1\\Dir2\\Dir3\\Dir4\\Dir5\\level5.txt" );
sl@0
    35
_LIT( KTestFile7, "Dir1\\Dir2\\Dir3\\Dir4\\Dir5\\Dir6\\level6.txt" );
sl@0
    36
_LIT( KTestFile8, "Dir1\\Dir2\\Dir3\\Dir4\\Dir5\\Dir6\\Dir7\\level7.txt" );
sl@0
    37
_LIT( KTestFile9, "DeepDir1\\DeepDir2\\DeepDir3\\DeepDir4\\DeepDir5\\DeepDir6\\DeepDir7\\DeepDir8\\DeepDir9\\DeepDir10\\DeepDir11\\DeepDir12\\DeepDir13\\DeepDir14\\file.txt" );
sl@0
    38
_LIT( KTestFile10, "Parent\\parfile.txt" );
sl@0
    39
_LIT( KTestFile11, "Parent\\SubDir1A\\subfileA.txt" );
sl@0
    40
_LIT( KTestFile12, "Parent\\SubDir1B\\subfileB.txt" );
sl@0
    41
_LIT( KTestFile13, "Parent\\SubDir1C\\subfileC.txt" );
sl@0
    42
_LIT( KTestFile14, "Parent\\SubDir1D\\subfileD.txt" );
sl@0
    43
_LIT( KTestFile15, "Parent\\SubDir1E\\subfileE.txt" );
sl@0
    44
_LIT( KTestFile16, "Parent\\SubDir1F\\SubSubA\\subsub_a.txt" );
sl@0
    45
_LIT( KTestFile17, "Parent\\SubDir1F\\SubSubB\\subsub_b.txt" );
sl@0
    46
_LIT( KTestFile18, "Parent\\SubDir1F\\SubSubC\\subsub_c.txt" );
sl@0
    47
_LIT( KTestFile19, "Parent\\SubDir1F\\SubSubD\\subsub_d.txt" );
sl@0
    48
_LIT( KTestFile20, "Mixed\\par1.txt" );
sl@0
    49
_LIT( KTestFile21, "Mixed\\SubDir1\\sub1.txt" );
sl@0
    50
_LIT( KTestFile22, "Mixed\\SubDir2\\sub2.txt" );
sl@0
    51
_LIT( KTestFile23, "Mixed\\SubDir3\\sub3.txt" );
sl@0
    52
_LIT( KTestFile24, "Mixed\\SubDir4\\sub4.txt" );
sl@0
    53
_LIT( KTestFile25, "Mixed\\SubDir5\\sub5.txt" );
sl@0
    54
_LIT( KTestFile26, "Mixed\\SubDir6\\sub6.txt" );
sl@0
    55
_LIT( KTestFile27, "Mixed\\SubDir7\\sub7.txt" );
sl@0
    56
_LIT( KTestFile28, "Mixed\\SubDir8\\sub8.txt" );
sl@0
    57
_LIT( KTestFile29, "Mixed\\par2.txt" );
sl@0
    58
_LIT( KTestFile30, "Mixed\\par3.txt" );
sl@0
    59
_LIT( KTestFile31, "Mixed\\par4.txt" );
sl@0
    60
_LIT( KTestFile32, "Mixed\\par5.txt" );
sl@0
    61
_LIT( KTestFile33, "Mixed\\par6.txt" );
sl@0
    62
_LIT( KTestFile34, "Mixed\\par7.txt" );
sl@0
    63
_LIT( KTestFile35, "Mixed\\par8.txt" );
sl@0
    64
// required to test extension
sl@0
    65
_LIT( KTestFile36, "ext.txt" );
sl@0
    66
_LIT( KTestFile37, "Dir1\\ext.txt" );
sl@0
    67
_LIT( KTestFile38, "Dir1\\level1_ext.txt" );
sl@0
    68
//required to test the unique files 
sl@0
    69
//(Note: These file names depend on the mount ids. Hence change in mount order will affect the test)
sl@0
    70
_LIT( KTestFile39, "Exattrib\\test1.txt[02-00]" );
sl@0
    71
_LIT( KTestFile40, "Exattrib\\test1.txt[03-00]");
sl@0
    72
_LIT( KTestFile41, "Exattrib\\test2.txt[03-00]" );
sl@0
    73
_LIT( KTestFile42, "Exattrib\\test3-1.txt[02-00]");
sl@0
    74
_LIT( KTestFile43, "Exattrib\\test5-1.txt[x-y][03-00]");
sl@0
    75
sl@0
    76
const TInt KRootDirEntryCount = 17;
sl@0
    77
sl@0
    78
_LIT( KRootFile, "root.txt" );
sl@0
    79
_LIT( KRootFileExt, "ext.txt" );
sl@0
    80
_LIT( KRootDir1, "Dir1" );
sl@0
    81
_LIT( KRootDeepDir1, "DeepDir1" );
sl@0
    82
_LIT( KRootDirParent, "Parent" );
sl@0
    83
_LIT( KRootDirMixed, "Mixed" );
sl@0
    84
_LIT( KRootDirReadTest, "ReadTest" );
sl@0
    85
_LIT( KRootDirAttrib, "Attrib" );
sl@0
    86
_LIT( KRootDirExattrib, "Exattrib" );
sl@0
    87
_LIT( KRootDirResource, "Resource" );
sl@0
    88
_LIT( KRootImg, "Img" );
sl@0
    89
_LIT( KRootSys, "sys" );
sl@0
    90
_LIT( KRootSystem, "system" );
sl@0
    91
_LIT( KRootTest, "Test" );
sl@0
    92
_LIT( KRootDirMultiple, "Multiple" );
sl@0
    93
_LIT( KRootAutoexec, "autoexec.bat" );
sl@0
    94
sl@0
    95
_LIT( KRootDirScripts, "scripts" );
sl@0
    96
sl@0
    97
sl@0
    98
_LIT( KSubDirOnlyBase, "Parent\\SubDir1F\\" );
sl@0
    99
_LIT( KSubSubPattern, "SubSub%c" );
sl@0
   100
const TInt KSubDirOnlyCount = 4;
sl@0
   101
sl@0
   102
_LIT( KFilesOnlyBase, "Parent\\SubDir1F\\SubSubA\\" );
sl@0
   103
_LIT( KSubSubFilePattern, "subsub_%c.txt" );
sl@0
   104
const TInt KFilesOnlyCount = 1;
sl@0
   105
sl@0
   106
_LIT( KMixedDirBase, "Mixed\\" );
sl@0
   107
_LIT( KMixedDirPattern, "SubDir%d" );
sl@0
   108
_LIT( KMixedFilePattern, "par%d.txt" );
sl@0
   109
const TInt KMixedSubDirCount = 8;
sl@0
   110
const TInt KMixedSubFileCount = 8;
sl@0
   111
sl@0
   112
sl@0
   113
const TInt KMultipleDirEntryCount=14;
sl@0
   114
_LIT( KMultipleFile1, "new1.txt" );
sl@0
   115
_LIT( KMultipleFile2, "new2.txt" );
sl@0
   116
_LIT( KMultipleFile3, "new3.txt" );
sl@0
   117
_LIT( KMultipleFile4, "replaceme1.txt" );
sl@0
   118
_LIT( KMultipleFile5, "replaceme2.txt" );
sl@0
   119
_LIT( KMultipleFile6, "replaceme3.txt" );
sl@0
   120
_LIT( KMultipleFile7, "replaceme4.txt" );
sl@0
   121
_LIT( KMultipleFile8, "rom.txt" );
sl@0
   122
_LIT( KMultipleFile9, "romreplace.txt" );
sl@0
   123
// required to test multiple rofs
sl@0
   124
_LIT( KMultipleFile10, "multirofs.txt" );
sl@0
   125
// files on user data fat partition
sl@0
   126
_LIT( KMultipleFile11, "new4.txt" );
sl@0
   127
_LIT( KMultipleFile12, "replaceme5.txt" );
sl@0
   128
_LIT( KMultipleFile13, "romreplacefat.txt" );
sl@0
   129
_LIT( KMultipleFile14, "t_file.cpp" );
sl@0
   130
sl@0
   131
const TInt KExattribDirEntryCount = 11;
sl@0
   132
sl@0
   133
_LIT( KExattribFile1, "test1.txt[02-00]" );
sl@0
   134
_LIT( KExattribFile2, "test1.txt[03-00]" );
sl@0
   135
_LIT( KExattribFile3, "test2.txt[03-00]" );
sl@0
   136
_LIT( KExattribFile4, "test3-1.txt[02-00]" );
sl@0
   137
_LIT( KExattribFile5, "test4-2.txt[03-00]" );
sl@0
   138
_LIT( KExattribFile6, "test5-1.txt[x-y][03-00]" );
sl@0
   139
_LIT( KExattribFile7, "test5-2.txt[x-y]" );
sl@0
   140
_LIT( KExattribFile8, "test8-1.txt[04-00]" );
sl@0
   141
_LIT( KExattribFile9, "test6-1.txt[04-00]" );
sl@0
   142
_LIT( KExattribFile10, "test7-1.txt[03-00]" );
sl@0
   143
_LIT( KExattribFile11, "test7-1.txt[04-00]" );
sl@0
   144
sl@0
   145
_LIT( KDriveBase, " :\\" );
sl@0
   146
_LIT( KDriveMultiple, "Multiple\\" );
sl@0
   147
_LIT( KDriveExattrib, "Exattrib\\" );
sl@0
   148
_LIT( KWildCard, "*" );
sl@0
   149
sl@0
   150
sl@0
   151
enum TEntrySet
sl@0
   152
	{
sl@0
   153
	ERoot,
sl@0
   154
	ERootExtension,
sl@0
   155
	EMultiple,
sl@0
   156
	EExattrib,
sl@0
   157
	};
sl@0
   158
sl@0
   159
LOCAL_C void TestOpenFilesL(TInt aDriveToTest, TBool aExtension, TBool aMultipleRofs)
sl@0
   160
//
sl@0
   161
// Tests that we can open files in various directories on the drive
sl@0
   162
//
sl@0
   163
	{
sl@0
   164
	TInt index = 35;
sl@0
   165
	if(aExtension)
sl@0
   166
		index=37;
sl@0
   167
	if(aMultipleRofs)
sl@0
   168
		index=42;
sl@0
   169
sl@0
   170
	const TDesC* const fileArray[43] =
sl@0
   171
		{
sl@0
   172
		&KTestFile1, &KTestFile2, &KTestFile3, &KTestFile4, &KTestFile5,
sl@0
   173
		&KTestFile6, &KTestFile7, &KTestFile8, &KTestFile9, &KTestFile10,
sl@0
   174
		&KTestFile11, &KTestFile12, &KTestFile13, &KTestFile14, &KTestFile15,
sl@0
   175
		&KTestFile16, &KTestFile17, &KTestFile18, &KTestFile19, &KTestFile20,
sl@0
   176
		&KTestFile21, &KTestFile22, &KTestFile23, &KTestFile24, &KTestFile25,
sl@0
   177
		&KTestFile26, &KTestFile27, &KTestFile28, &KTestFile29, &KTestFile30,
sl@0
   178
		&KTestFile31, &KTestFile32, &KTestFile33, &KTestFile34, &KTestFile35,
sl@0
   179
		&KTestFile36, &KTestFile37, &KTestFile38, &KTestFile39, &KTestFile40,
sl@0
   180
		&KTestFile41, &KTestFile42, &KTestFile43
sl@0
   181
		};
sl@0
   182
sl@0
   183
	test.Next( _L("Test opening files in directories") );
sl@0
   184
	TFileName name(KDriveBase);
sl@0
   185
	name[0] = TText('A' + aDriveToTest);
sl@0
   186
sl@0
   187
	for( TInt i = 0; i < index; i++ )
sl@0
   188
		{
sl@0
   189
		name.SetLength( 3 );	// trim back to drive specifier
sl@0
   190
		if(aExtension && (i==1))
sl@0
   191
			name.Append( *fileArray[i+36] );
sl@0
   192
		else
sl@0
   193
			name.Append( *fileArray[i] );
sl@0
   194
		test.Printf( _L("Opening file %S\n"), &name );
sl@0
   195
		RFile file;
sl@0
   196
		TInt r = file.Open( TheFs, name, EFileRead );
sl@0
   197
		TEST_FOR_ERROR( r );
sl@0
   198
		file.Close();
sl@0
   199
		}
sl@0
   200
	}
sl@0
   201
sl@0
   202
sl@0
   203
LOCAL_C void TestScanDirL(TInt aDriveToTest, TEntrySet aEntrySet)
sl@0
   204
	//
sl@0
   205
	// Scan the root directory file
sl@0
   206
	//
sl@0
   207
	{
sl@0
   208
	const TDesC* const rootEntriesExt[ KRootDirEntryCount ] = 
sl@0
   209
		{
sl@0
   210
		&KRootFileExt, &KRootFile, &KRootDir1, &KRootDeepDir1, 
sl@0
   211
		&KRootDirParent, &KRootDirMixed, &KRootDirReadTest, &KRootDirAttrib, &KRootDirExattrib, 
sl@0
   212
		&KRootDirResource, &KRootImg, &KRootSys, &KRootSystem, &KRootTest, &KRootDirMultiple,
sl@0
   213
		&KRootDirScripts,
sl@0
   214
		&KRootAutoexec
sl@0
   215
		};
sl@0
   216
sl@0
   217
	const TDesC* const rootEntries[ KRootDirEntryCount-1 ] = 
sl@0
   218
		{
sl@0
   219
		&KRootFile, &KRootDir1, &KRootDeepDir1, 
sl@0
   220
		&KRootDirParent, &KRootDirMixed, &KRootDirReadTest, &KRootDirAttrib, &KRootDirExattrib, 
sl@0
   221
		&KRootDirResource, &KRootImg, &KRootSys, &KRootSystem, &KRootTest, &KRootDirMultiple, 
sl@0
   222
		&KRootDirScripts,
sl@0
   223
		&KRootAutoexec
sl@0
   224
		};
sl@0
   225
sl@0
   226
	const TDesC* const multipleEntries[ KMultipleDirEntryCount ] =
sl@0
   227
		{
sl@0
   228
		&KMultipleFile1, &KMultipleFile2, &KMultipleFile3, &KMultipleFile4, &KMultipleFile5,
sl@0
   229
		&KMultipleFile6, &KMultipleFile7, &KMultipleFile8, &KMultipleFile9, &KMultipleFile10,
sl@0
   230
		&KMultipleFile11, &KMultipleFile12, &KMultipleFile13, &KMultipleFile14
sl@0
   231
		};
sl@0
   232
sl@0
   233
	const TDesC* const exattribEntries[ KExattribDirEntryCount ] =
sl@0
   234
		{
sl@0
   235
		&KExattribFile1, &KExattribFile2, &KExattribFile3, &KExattribFile4,
sl@0
   236
		&KExattribFile5, &KExattribFile6, &KExattribFile7, &KExattribFile8,
sl@0
   237
		&KExattribFile9, &KExattribFile10, &KExattribFile11
sl@0
   238
		};
sl@0
   239
sl@0
   240
	const TDesC* const *entries = NULL;
sl@0
   241
	TInt DirCount=0;
sl@0
   242
	TBool seen[KRootDirEntryCount];
sl@0
   243
	memclr(seen, KRootDirEntryCount*sizeof(TBool));
sl@0
   244
	TFileName name(KDriveBase);
sl@0
   245
	name[0] = TText('A' + aDriveToTest);
sl@0
   246
	
sl@0
   247
	switch (aEntrySet)
sl@0
   248
		{
sl@0
   249
		case ERoot:
sl@0
   250
			DirCount=KRootDirEntryCount-1;
sl@0
   251
			entries=rootEntries;
sl@0
   252
			test.Next( _L("Scanning root directory") );
sl@0
   253
		break;
sl@0
   254
		case ERootExtension:
sl@0
   255
			DirCount=KRootDirEntryCount;
sl@0
   256
			entries=rootEntriesExt;
sl@0
   257
			test.Next( _L("Scanning root extension directory") );
sl@0
   258
		break;
sl@0
   259
		case EMultiple:
sl@0
   260
			DirCount=KMultipleDirEntryCount;
sl@0
   261
			entries=multipleEntries;
sl@0
   262
			name.Append(KDriveMultiple);
sl@0
   263
			test.Next( _L("Scanning multiple directory") );
sl@0
   264
		break;
sl@0
   265
		case EExattrib:
sl@0
   266
			DirCount=KExattribDirEntryCount;
sl@0
   267
			entries=exattribEntries;
sl@0
   268
			name.Append(KDriveExattrib);
sl@0
   269
			test.Next( _L("Scanning Exattrib directory") );
sl@0
   270
		break;
sl@0
   271
		default:
sl@0
   272
			test(EFalse);
sl@0
   273
		}
sl@0
   274
sl@0
   275
	CDir* dir;
sl@0
   276
	TInt r = TheFs.GetDir( name, KEntryAttMaskSupported, ESortNone, dir );
sl@0
   277
	TEST_FOR_ERROR( r );
sl@0
   278
	
sl@0
   279
	TInt actualCount = dir->Count();
sl@0
   280
	for(TInt i = 0; i < actualCount; i++)
sl@0
   281
		{
sl@0
   282
		const TEntry& e = dir->operator[](i);
sl@0
   283
		TFileName lowerName(e.iName);
sl@0
   284
		lowerName.LowerCase();
sl@0
   285
		TBool found = EFalse;
sl@0
   286
		// try to find the name in our list
sl@0
   287
		for(TInt j = 0; j < DirCount && !found; j++)
sl@0
   288
			{
sl@0
   289
			TFileName expectedLower(*entries[j]);
sl@0
   290
			expectedLower.LowerCase();
sl@0
   291
			// Check the directory name is that expected.
sl@0
   292
			found = lowerName == expectedLower;
sl@0
   293
			if(found)
sl@0
   294
				{
sl@0
   295
				if(seen[j])
sl@0
   296
					{
sl@0
   297
					test.Printf( _L("ERROR: saw entry %S twice\n"), &e.iName );
sl@0
   298
					test( EFalse );
sl@0
   299
					}
sl@0
   300
				else
sl@0
   301
					{
sl@0
   302
					seen[j] = ETrue;
sl@0
   303
					}
sl@0
   304
				}
sl@0
   305
			}
sl@0
   306
		if (!found)
sl@0
   307
			{
sl@0
   308
			test.Printf( _L("ERROR: entry %S unknown\n"), &e.iName );
sl@0
   309
			test( EFalse );
sl@0
   310
			}
sl@0
   311
		}
sl@0
   312
	// All the entries are those expected but are there enough matching entries.
sl@0
   313
	// Allow the autoexe.bat to not be present so the test can pass when run 
sl@0
   314
	// when not part of an auto test rom.
sl@0
   315
	TInt tolerance = 1;
sl@0
   316
	if (aEntrySet == ERoot || aEntrySet == ERootExtension)
sl@0
   317
		{// The "scripts" directory is not present on all roms.
sl@0
   318
		tolerance++;
sl@0
   319
		}
sl@0
   320
	test_Value(actualCount, actualCount >= DirCount-tolerance);
sl@0
   321
	delete dir;
sl@0
   322
	}
sl@0
   323
sl@0
   324
sl@0
   325
sl@0
   326
LOCAL_C void TestSubDirsOnlyL(TInt aDriveToTest)
sl@0
   327
	//
sl@0
   328
	// Tests that scanning a directory containing only subdirectories
sl@0
   329
	// only returns entries marked as directories
sl@0
   330
	//
sl@0
   331
	{
sl@0
   332
	test.Next( _L("Testing scan of dir containing only subdirs") );
sl@0
   333
	CDir* dir;
sl@0
   334
sl@0
   335
	TFileName name(KDriveBase);
sl@0
   336
	name[0] = TText('A' + aDriveToTest);
sl@0
   337
	name.Append( KSubDirOnlyBase );
sl@0
   338
	name.Append( KWildCard );
sl@0
   339
sl@0
   340
	TInt r = TheFs.GetDir( name, KEntryAttMaskSupported, ESortNone, dir );
sl@0
   341
	TEST_FOR_ERROR( r );
sl@0
   342
	
sl@0
   343
	TEST_FOR_MATCH( dir->Count(), KSubDirOnlyCount );
sl@0
   344
sl@0
   345
	TBuf<32> subEntryName;
sl@0
   346
	for( TInt i = 0; i < KSubDirOnlyCount; i++ )
sl@0
   347
		{
sl@0
   348
		const TEntry& e = dir->operator[](i);
sl@0
   349
		subEntryName.Format( KSubSubPattern, 'A' + i );
sl@0
   350
		test.Printf( _L("Found entry %S\n"), &e.iName );
sl@0
   351
		test( e.iName == subEntryName );
sl@0
   352
		test( e.IsDir() );
sl@0
   353
		}
sl@0
   354
	delete dir;
sl@0
   355
	}
sl@0
   356
sl@0
   357
sl@0
   358
LOCAL_C void TestFilesOnlyL(TInt aDriveToTest)
sl@0
   359
	//
sl@0
   360
	// Tests that scanning a directory containing only files
sl@0
   361
	// does not return any entries marked as files
sl@0
   362
	//
sl@0
   363
	{
sl@0
   364
	test.Next( _L("Testing scan of dir containing only files") );
sl@0
   365
	CDir* dir;
sl@0
   366
sl@0
   367
	TFileName name(KDriveBase);
sl@0
   368
	name[0] = TText('A' + aDriveToTest);
sl@0
   369
	name.Append( KFilesOnlyBase );
sl@0
   370
	name.Append( KWildCard );
sl@0
   371
sl@0
   372
	TInt r = TheFs.GetDir( name, KEntryAttMaskSupported, ESortNone, dir );
sl@0
   373
	TEST_FOR_ERROR( r );
sl@0
   374
	
sl@0
   375
	TEST_FOR_MATCH( dir->Count(), KFilesOnlyCount );
sl@0
   376
sl@0
   377
	TBuf<32> subEntryName;
sl@0
   378
	for( TInt i = 0; i < KFilesOnlyCount; i++ )
sl@0
   379
		{
sl@0
   380
		const TEntry& e = dir->operator[](i);
sl@0
   381
		subEntryName.Format( KSubSubFilePattern, 'a' + i );
sl@0
   382
		test.Printf( _L("Found entry %S\n"), &e.iName );
sl@0
   383
		test( e.iName == subEntryName );
sl@0
   384
		test( !e.IsDir() );
sl@0
   385
		}
sl@0
   386
	delete dir;
sl@0
   387
	}
sl@0
   388
sl@0
   389
sl@0
   390
LOCAL_C void TestMaskDirsL(TInt aDriveToTest)
sl@0
   391
	//
sl@0
   392
	// Test scanning a directory with masking to return only directories
sl@0
   393
	//
sl@0
   394
	{
sl@0
   395
	test.Next( _L("Testing scan of dir masking out files") );
sl@0
   396
	CDir* dir;
sl@0
   397
sl@0
   398
	TFileName name(KDriveBase);
sl@0
   399
	name[0] = TText('A' + aDriveToTest);
sl@0
   400
	name.Append( KMixedDirBase );
sl@0
   401
	name.Append( KWildCard );
sl@0
   402
sl@0
   403
	TInt r = TheFs.GetDir( name, KEntryAttMatchExclusive | KEntryAttDir, ESortNone, dir );
sl@0
   404
	TEST_FOR_ERROR( r );
sl@0
   405
	
sl@0
   406
	TEST_FOR_MATCH( dir->Count(), KMixedSubDirCount );
sl@0
   407
sl@0
   408
	TBuf<32> subEntryName;
sl@0
   409
	for( TInt i = 0; i < KMixedSubDirCount; i++ )
sl@0
   410
		{
sl@0
   411
		const TEntry& e = dir->operator[](i);
sl@0
   412
		subEntryName.Format( KMixedDirPattern, i+1 );
sl@0
   413
		test.Printf( _L("Found entry %S\n"), &e.iName );
sl@0
   414
		test( e.iName == subEntryName );
sl@0
   415
		test( e.IsDir() );
sl@0
   416
		}
sl@0
   417
	delete dir;
sl@0
   418
	}
sl@0
   419
sl@0
   420
LOCAL_C void TestMaskFilesL(TInt aDriveToTest)
sl@0
   421
	//
sl@0
   422
	// Test scanning a directory with masking to return only files
sl@0
   423
	//
sl@0
   424
	{
sl@0
   425
	test.Next( _L("Testing scan of dir masking out directories") );
sl@0
   426
	CDir* dir;
sl@0
   427
sl@0
   428
	TFileName name(KDriveBase);
sl@0
   429
	name[0] = TText('A' + aDriveToTest);
sl@0
   430
	name.Append( KMixedDirBase );
sl@0
   431
	name.Append( KWildCard );
sl@0
   432
sl@0
   433
	TInt r = TheFs.GetDir( name, KEntryAttMatchExclude | KEntryAttDir, ESortNone, dir );
sl@0
   434
	TEST_FOR_ERROR( r );
sl@0
   435
	
sl@0
   436
	TEST_FOR_MATCH( dir->Count(), KMixedSubFileCount );
sl@0
   437
sl@0
   438
	TBuf<32> subEntryName;
sl@0
   439
	for( TInt i = 0; i < KMixedSubFileCount; i++ )
sl@0
   440
		{
sl@0
   441
		const TEntry& e = dir->operator[](i);
sl@0
   442
		subEntryName.Format( KMixedFilePattern, i+1 );
sl@0
   443
		test.Printf( _L("Found entry %S\n"), &e.iName );
sl@0
   444
		test( e.iName == subEntryName );
sl@0
   445
		test( !e.IsDir() );
sl@0
   446
		}
sl@0
   447
	delete dir;
sl@0
   448
	}
sl@0
   449
sl@0
   450
LOCAL_C void TestGetDirL(TInt aDriveToTest)
sl@0
   451
//
sl@0
   452
// Test UID scanning of a directory
sl@0
   453
//
sl@0
   454
	{
sl@0
   455
	test.Next( _L("Testing scan of dir with UID bitmask") );
sl@0
   456
sl@0
   457
	TFileName name(KDriveBase);
sl@0
   458
	name[0] = TText('A' + aDriveToTest);
sl@0
   459
	name.Append( KRootDirResource );
sl@0
   460
	name.Append(_L("\\"));
sl@0
   461
sl@0
   462
	const TUid KUidInterfaceImplementationCollectionInfo = {0x101F747D};
sl@0
   463
	
sl@0
   464
	TUidType rscUidType(KNullUid,KUidInterfaceImplementationCollectionInfo,KNullUid);
sl@0
   465
sl@0
   466
	CDir* dir;
sl@0
   467
	TInt r = TheFs.GetDir(name, rscUidType, ESortByUid, dir);
sl@0
   468
	test(r==KErrNone);
sl@0
   469
	TInt count = dir->Count();
sl@0
   470
	test(count==10);
sl@0
   471
	delete dir;
sl@0
   472
sl@0
   473
	TUidType uidType2(TUid::Uid('X'),TUid::Uid('Y'),TUid::Uid('Z'));
sl@0
   474
	r = TheFs.GetDir(name, uidType2, ESortByUid, dir);
sl@0
   475
	test(r==KErrNone);
sl@0
   476
	count = dir->Count();
sl@0
   477
	test(count==1);
sl@0
   478
	delete dir;
sl@0
   479
	}
sl@0
   480
sl@0
   481
sl@0
   482
sl@0
   483
//************************
sl@0
   484
// Entry point
sl@0
   485
sl@0
   486
void DoTestL(TInt aDriveToTest)
sl@0
   487
	{
sl@0
   488
	test.Title();
sl@0
   489
	test.Start( _L("Testing ROFS directory structure") );
sl@0
   490
sl@0
   491
	test.Printf( _L("Looking for ROFS extension..\n"));
sl@0
   492
	TBool extension = EFalse;
sl@0
   493
	TFileName name(KDriveBase);
sl@0
   494
	name[0] = TText('A' + aDriveToTest);
sl@0
   495
sl@0
   496
	name.SetLength( 3 );	// trim back to drive specifier
sl@0
   497
	name.Append( KTestFile36 );
sl@0
   498
sl@0
   499
	RFile file;
sl@0
   500
	test.Printf( _L("Attempt to open file %S.."), &name );
sl@0
   501
	TInt r = file.Open( TheFs, name, EFileRead );
sl@0
   502
	if(r==KErrNone)
sl@0
   503
		{
sl@0
   504
		extension=ETrue;
sl@0
   505
		file.Close();
sl@0
   506
		test.Printf( _L("ROFS extension found.\n"));
sl@0
   507
		}
sl@0
   508
	else if(r==KErrNotFound)
sl@0
   509
		{
sl@0
   510
		test.Printf( _L("Not found, ROFS extension not present.\n"));
sl@0
   511
		}
sl@0
   512
sl@0
   513
	test.Printf( _L("Looking for multiple ROFS..\n"));
sl@0
   514
	TBool multipleRofs = EFalse;
sl@0
   515
	name.SetLength( 3 );	// trim back to drive specifier
sl@0
   516
	name.Append( KMultipleFile10 );
sl@0
   517
sl@0
   518
	test.Printf( _L("Attempt to open file %S.."), &name );
sl@0
   519
	r = file.Open( TheFs, name, EFileRead );
sl@0
   520
	if(r==KErrNone)
sl@0
   521
		{
sl@0
   522
		multipleRofs=ETrue;
sl@0
   523
		file.Close();
sl@0
   524
		test.Printf( _L("Multiple ROFS found. %S is present.\n"), &name);
sl@0
   525
		}
sl@0
   526
	else if(r==KErrNotFound)
sl@0
   527
		{
sl@0
   528
		test.Printf( _L("No multiple ROFS found. %S is not present.\n"), &name);
sl@0
   529
		}
sl@0
   530
	
sl@0
   531
	TestOpenFilesL(aDriveToTest,extension,multipleRofs);
sl@0
   532
	TestScanDirL(aDriveToTest, extension?ERootExtension:ERoot);
sl@0
   533
	TestSubDirsOnlyL(aDriveToTest);
sl@0
   534
	TestFilesOnlyL(aDriveToTest);
sl@0
   535
	TestMaskDirsL(aDriveToTest);
sl@0
   536
	TestMaskFilesL(aDriveToTest);
sl@0
   537
	TestGetDirL(aDriveToTest);
sl@0
   538
sl@0
   539
	// Test dir works for muliple rofs
sl@0
   540
	if (multipleRofs)
sl@0
   541
	{
sl@0
   542
		TestScanDirL(aDriveToTest, EMultiple);
sl@0
   543
		TestScanDirL(aDriveToTest, EExattrib);
sl@0
   544
	}
sl@0
   545
sl@0
   546
	test.End();
sl@0
   547
	}