os/kernelhwsrv/kerneltest/f32test/server/t_dctcballfiles.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) 1995-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
//
sl@0
    15
sl@0
    16
#include <f32file.h>
sl@0
    17
#include <e32test.h>
sl@0
    18
#include <e32std.h>
sl@0
    19
#include <e32std_private.h>
sl@0
    20
#include <e32svr.h>
sl@0
    21
#include <e32def.h>
sl@0
    22
#include <e32def_private.h>
sl@0
    23
#include "t_server.h"
sl@0
    24
sl@0
    25
GLDEF_D RTest test(_L("t_dctcballfiles"));
sl@0
    26
GLDEF_D TTime gTimeNow;
sl@0
    27
LOCAL_D TInt gTheDriveNum;
sl@0
    28
sl@0
    29
const TInt KPathPosition = 2;
sl@0
    30
_LIT(KExpectedPrivatePath, "\\Private\\00000001\\");
sl@0
    31
sl@0
    32
_LIT(KResourcePath, "?:\\Resource\\");
sl@0
    33
_LIT(KSystemPath,	"?:\\Sys\\");
sl@0
    34
_LIT(KPrivatePath,	"?:\\Private\\");
sl@0
    35
_LIT(KPrivateFalseID,	"?:\\Private\\FFFFFFFF\\");
sl@0
    36
_LIT(KDriveName,	"Billy");
sl@0
    37
_LIT(KVolLable,		"Benny");
sl@0
    38
_LIT(KFileSys,	"systemfile.txt");
sl@0
    39
_LIT(KFileSys3, "sysfile.rna");
sl@0
    40
_LIT(KFilePri,	"privatefile.txt");
sl@0
    41
_LIT(KFilePri2,	"privatefile.tmp");
sl@0
    42
_LIT(KFilePri3,	"prifile.rna");
sl@0
    43
_LIT(KFileRes,	"resourcefile.txt");
sl@0
    44
_LIT(KFileRes3,	"resfile.rna");
sl@0
    45
_LIT(KMkDirSub,"Subdir\\");
sl@0
    46
_LIT(KOldFile,"?:\\Anyold.txt");
sl@0
    47
_LIT(KWildPath, "Z:\\SYS\\");
sl@0
    48
_LIT(KWildFile, "*");
sl@0
    49
sl@0
    50
TCapability TheCaps;
sl@0
    51
TBuf<4> driveBuf=_L("?:\\");
sl@0
    52
RFormat format;
sl@0
    53
TInt count;
sl@0
    54
RRawDisk rawdisk;
sl@0
    55
RFile file1;
sl@0
    56
RFile file2;
sl@0
    57
RDir	dir;
sl@0
    58
sl@0
    59
TInt r;
sl@0
    60
TBuf<40> fsname;
sl@0
    61
TBuf<40> systestname;
sl@0
    62
TBuf<40> pritestname;
sl@0
    63
TBuf<40> restestname;
sl@0
    64
TBuf<40> theprivatepath;
sl@0
    65
TBuf<40> pritestfalseidname;
sl@0
    66
TBuf<40> mkdirname;
sl@0
    67
TFileName fromTemp;
sl@0
    68
sl@0
    69
TBuf<25> sysfilename;
sl@0
    70
TBuf<30> realName;
sl@0
    71
TBuf<40> shortfilename;
sl@0
    72
TBuf<40> longfilename;
sl@0
    73
sl@0
    74
TRequestStatus aStat1;
sl@0
    75
TRequestStatus aStat2;
sl@0
    76
TRequestStatus aStat3;
sl@0
    77
TRequestStatus aStat4;
sl@0
    78
sl@0
    79
TVolumeInfo aVolInfo;
sl@0
    80
//	TDriveInfo adriveInfo;
sl@0
    81
sl@0
    82
TBuf<40> systestfile;
sl@0
    83
TBuf<40> pritestfile;
sl@0
    84
TBuf<40> restestfile;
sl@0
    85
TBuf<40> systestfile1;
sl@0
    86
TBuf<40> pritestfile1;
sl@0
    87
TBuf<40> restestfile1;
sl@0
    88
sl@0
    89
TTime testtime;
sl@0
    90
TBuf<20> oldName;
sl@0
    91
sl@0
    92
TBuf<25> temp;
sl@0
    93
sl@0
    94
TEntry entry;
sl@0
    95
sl@0
    96
sl@0
    97
LOCAL_C void systemRFsTest()
sl@0
    98
//
sl@0
    99
//	RFs test on system Directory
sl@0
   100
//
sl@0
   101
	{
sl@0
   102
	systestname=KSystemPath;
sl@0
   103
	systestname[0]=(TText)('A' + gTheDriveNum);
sl@0
   104
	
sl@0
   105
	mkdirname.Zero();
sl@0
   106
	mkdirname.Append(systestname);
sl@0
   107
	mkdirname.Append(KMkDirSub);
sl@0
   108
	r=TheFs.MkDirAll(mkdirname);	
sl@0
   109
	test(r==KErrNone);
sl@0
   110
sl@0
   111
	TheFs.RmDir(mkdirname);
sl@0
   112
	test(r==KErrNone);
sl@0
   113
sl@0
   114
	r=TheFs.SetSubst(systestname,EDriveO);
sl@0
   115
	test(r==KErrPermissionDenied);
sl@0
   116
	
sl@0
   117
	r=TheFs.RealName(_L("O:\\File.XXX"),realName);
sl@0
   118
	test(r==KErrNone);
sl@0
   119
sl@0
   120
	r=TheFs.SetSessionPath(systestname);
sl@0
   121
	test(r==KErrNone);
sl@0
   122
	
sl@0
   123
	TheFs.NotifyChange(ENotifyAll,aStat1,systestname);
sl@0
   124
	test(aStat1==KRequestPending);
sl@0
   125
sl@0
   126
	systestfile=KSystemPath;
sl@0
   127
	systestfile[0]=(TText)('A' + gTheDriveNum);
sl@0
   128
	systestfile1=systestfile;
sl@0
   129
	systestfile.Append(KFileSys);
sl@0
   130
	systestfile1.Append(KFileSys3);
sl@0
   131
	
sl@0
   132
	oldName=KOldFile;
sl@0
   133
	oldName[0]=(TText)gDriveToTest;
sl@0
   134
sl@0
   135
	r=TheFs.GetShortName(systestfile, shortfilename);
sl@0
   136
	test(r==KErrNotFound || r==KErrNotSupported);
sl@0
   137
sl@0
   138
	r=TheFs.GetLongName(systestfile1, longfilename);
sl@0
   139
	test(r==KErrNotFound || r==KErrNotSupported);
sl@0
   140
sl@0
   141
	r=file1.Create(TheFs,oldName,EFileWrite);
sl@0
   142
	test(r==KErrNone || r==KErrAlreadyExists);
sl@0
   143
	file1.Close();
sl@0
   144
sl@0
   145
	r=TheFs.Replace(oldName,systestfile);
sl@0
   146
	test(r==KErrNone);
sl@0
   147
	
sl@0
   148
	r=TheFs.Rename(systestfile,systestfile1);
sl@0
   149
	test(r==KErrNone);
sl@0
   150
	
sl@0
   151
	r=TheFs.Entry(systestfile1,entry);
sl@0
   152
	test(r==KErrNone);
sl@0
   153
sl@0
   154
	r=TheFs.SetEntry(systestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
sl@0
   155
	test(r==KErrNone);
sl@0
   156
sl@0
   157
	r=TheFs.Delete(systestfile1);
sl@0
   158
	test(r==KErrNone);
sl@0
   159
	}
sl@0
   160
sl@0
   161
LOCAL_C void ResourceRFsTest()
sl@0
   162
//
sl@0
   163
//
sl@0
   164
//
sl@0
   165
	{
sl@0
   166
	restestname=KResourcePath;
sl@0
   167
	restestname[0]=(TText)('A' + gTheDriveNum);
sl@0
   168
	
sl@0
   169
	mkdirname.Zero();
sl@0
   170
	mkdirname.Append(restestname);
sl@0
   171
	mkdirname.Append(KMkDirSub);
sl@0
   172
	r=TheFs.MkDirAll(mkdirname);	
sl@0
   173
	test(r==KErrNone);
sl@0
   174
sl@0
   175
	TheFs.RmDir(mkdirname);
sl@0
   176
	test(r==KErrNone);
sl@0
   177
sl@0
   178
	r=TheFs.SetSubst(restestname,EDriveO);
sl@0
   179
	test(r==KErrPermissionDenied);
sl@0
   180
	
sl@0
   181
	r=TheFs.RealName(_L("O:\\File.XXX"),realName);
sl@0
   182
	test(r==KErrNone);
sl@0
   183
sl@0
   184
	r=TheFs.SetSessionPath(restestname);
sl@0
   185
	test(r==KErrNone);
sl@0
   186
	
sl@0
   187
	TheFs.NotifyChange(ENotifyAll,aStat4,restestname);
sl@0
   188
	test(aStat4==KRequestPending);
sl@0
   189
sl@0
   190
	restestfile=KResourcePath;
sl@0
   191
	restestfile[0]=(TText)('A' + gTheDriveNum);
sl@0
   192
	restestfile1=restestfile;
sl@0
   193
	restestfile.Append(KFileRes);
sl@0
   194
	restestfile1.Append(KFileRes3);
sl@0
   195
	
sl@0
   196
	oldName=KOldFile;
sl@0
   197
	oldName[0]=(TText)gDriveToTest;
sl@0
   198
sl@0
   199
	r=TheFs.GetShortName(restestfile, shortfilename);
sl@0
   200
	test(r==KErrNone || KErrNotFound || r==KErrNotSupported);
sl@0
   201
sl@0
   202
	r=TheFs.GetLongName(restestfile1, longfilename);
sl@0
   203
	test(r==KErrNone || KErrNotFound || r==KErrNotSupported);
sl@0
   204
sl@0
   205
	r=file1.Create(TheFs,oldName,EFileWrite);
sl@0
   206
	test(r==KErrNone || r==KErrAlreadyExists);
sl@0
   207
	file1.Close();
sl@0
   208
sl@0
   209
	r=TheFs.Replace(oldName,restestfile);
sl@0
   210
	test(r==KErrNone);
sl@0
   211
	
sl@0
   212
	r=TheFs.Rename(restestfile,restestfile1);
sl@0
   213
	test(r==KErrNone);
sl@0
   214
	
sl@0
   215
	r=TheFs.Entry(restestfile1,entry);
sl@0
   216
	test(r==KErrNone);
sl@0
   217
sl@0
   218
	r=TheFs.SetEntry(restestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
sl@0
   219
	test(r==KErrNone);
sl@0
   220
sl@0
   221
	r=TheFs.Delete(restestfile1);
sl@0
   222
	test(r==KErrNone);
sl@0
   223
sl@0
   224
	}
sl@0
   225
sl@0
   226
sl@0
   227
LOCAL_C void privatefalseIDRFsTest()
sl@0
   228
//
sl@0
   229
//
sl@0
   230
//
sl@0
   231
	{
sl@0
   232
	pritestfalseidname=KPrivateFalseID;
sl@0
   233
	pritestfalseidname[0]=(TText)('A' + gTheDriveNum);
sl@0
   234
	
sl@0
   235
	mkdirname.Zero();
sl@0
   236
	mkdirname.Append(pritestfalseidname);
sl@0
   237
	mkdirname.Append(KMkDirSub);
sl@0
   238
sl@0
   239
	r=TheFs.MkDirAll(mkdirname);	
sl@0
   240
	test(r==KErrNone);
sl@0
   241
sl@0
   242
	r=TheFs.RmDir(mkdirname);	
sl@0
   243
	test(r==KErrNone);
sl@0
   244
sl@0
   245
	r=TheFs.SetSubst(pritestfalseidname,EDriveO);
sl@0
   246
	test(r==KErrPermissionDenied);
sl@0
   247
sl@0
   248
	r=TheFs.RealName(_L("O:\\File.XXX"),realName);
sl@0
   249
	test(r==KErrNone);
sl@0
   250
sl@0
   251
	r=TheFs.SetSessionPath(pritestfalseidname);
sl@0
   252
	test(r==KErrNone);
sl@0
   253
sl@0
   254
	TheFs.NotifyChange(ENotifyAll,aStat2,pritestfalseidname);
sl@0
   255
	test(aStat2==KRequestPending);
sl@0
   256
sl@0
   257
sl@0
   258
	pritestfile=KPrivateFalseID;
sl@0
   259
	pritestfile[0]=(TText)('A' + gTheDriveNum);
sl@0
   260
	pritestfile1=pritestfile;
sl@0
   261
	pritestfile.Append(KFilePri2);
sl@0
   262
	pritestfile1.Append(KFilePri3);
sl@0
   263
	
sl@0
   264
	oldName=KOldFile;
sl@0
   265
	oldName[0]=(TText)gDriveToTest;
sl@0
   266
sl@0
   267
	r=TheFs.GetShortName(pritestfile, shortfilename);
sl@0
   268
	test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
sl@0
   269
sl@0
   270
	r=TheFs.GetLongName(pritestfile1, longfilename);
sl@0
   271
	test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
sl@0
   272
sl@0
   273
	r=file1.Create(TheFs,oldName,EFileWrite);
sl@0
   274
	test(r==KErrNone || r==KErrAlreadyExists);
sl@0
   275
	file1.Close();
sl@0
   276
sl@0
   277
	r=TheFs.Replace(oldName,pritestfile);
sl@0
   278
	test(r==KErrNone);
sl@0
   279
	
sl@0
   280
	r=TheFs.Rename(pritestfile,pritestfile1);
sl@0
   281
	test(r==KErrNone);
sl@0
   282
	
sl@0
   283
	r=TheFs.Entry(pritestfile1,entry);
sl@0
   284
	test(r==KErrNone);
sl@0
   285
sl@0
   286
	r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
sl@0
   287
	test(r==KErrNone);
sl@0
   288
sl@0
   289
	r=TheFs.Delete(pritestfile1);
sl@0
   290
	test(r==KErrNone);
sl@0
   291
sl@0
   292
	}
sl@0
   293
sl@0
   294
sl@0
   295
LOCAL_C void privateRFsTest()
sl@0
   296
//
sl@0
   297
//
sl@0
   298
//
sl@0
   299
	{
sl@0
   300
	//private
sl@0
   301
	pritestname=KPrivatePath;
sl@0
   302
	pritestname[0]=(TText)('A' + gTheDriveNum);
sl@0
   303
	
sl@0
   304
	mkdirname.Zero();
sl@0
   305
	mkdirname.Append(pritestname);
sl@0
   306
	mkdirname.Append(KMkDirSub);
sl@0
   307
sl@0
   308
	r=TheFs.MkDirAll(mkdirname);	
sl@0
   309
	test(r==KErrNone);
sl@0
   310
sl@0
   311
	r=TheFs.RmDir(mkdirname);	
sl@0
   312
	test(r==KErrNone);
sl@0
   313
sl@0
   314
	r=TheFs.SetSubst(pritestname,EDriveO);
sl@0
   315
	test(r==KErrPermissionDenied);
sl@0
   316
sl@0
   317
	r=TheFs.RealName(_L("O:\\File.XXX"),realName);
sl@0
   318
	test(r==KErrNone);
sl@0
   319
sl@0
   320
	r=TheFs.SetSessionPath(pritestname);
sl@0
   321
	test(r==KErrNone);
sl@0
   322
sl@0
   323
	TheFs.NotifyChange(ENotifyAll,aStat2,pritestname);
sl@0
   324
	test(aStat2==KRequestPending);
sl@0
   325
sl@0
   326
sl@0
   327
	pritestfile=KPrivatePath;
sl@0
   328
	pritestfile[0]=(TText)('A' + gTheDriveNum);
sl@0
   329
	pritestfile1=pritestfile;
sl@0
   330
	pritestfile.Append(KFilePri2);
sl@0
   331
	pritestfile1.Append(KFilePri3);
sl@0
   332
	
sl@0
   333
	oldName=KOldFile;
sl@0
   334
	oldName[0]=(TText)gDriveToTest;
sl@0
   335
sl@0
   336
	r=TheFs.GetShortName(pritestfile, shortfilename);
sl@0
   337
	test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
sl@0
   338
sl@0
   339
	r=TheFs.GetLongName(pritestfile1, longfilename);
sl@0
   340
	test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
sl@0
   341
sl@0
   342
	r=file1.Create(TheFs,oldName,EFileWrite);
sl@0
   343
	test(r==KErrNone || r==KErrAlreadyExists);
sl@0
   344
	file1.Close();
sl@0
   345
sl@0
   346
	r=TheFs.Replace(oldName,pritestfile);
sl@0
   347
	test(r==KErrNone);
sl@0
   348
	
sl@0
   349
	r=TheFs.Rename(pritestfile,pritestfile1);
sl@0
   350
	test(r==KErrNone);
sl@0
   351
	
sl@0
   352
	r=TheFs.Entry(pritestfile1,entry);
sl@0
   353
	test(r==KErrNone);
sl@0
   354
sl@0
   355
	r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
sl@0
   356
	test(r==KErrNone);
sl@0
   357
sl@0
   358
	r=TheFs.Delete(pritestfile1);
sl@0
   359
	test(r==KErrNone);
sl@0
   360
sl@0
   361
	}
sl@0
   362
sl@0
   363
sl@0
   364
LOCAL_C void privateSIDRFstest()
sl@0
   365
	{
sl@0
   366
	theprivatepath[0]=(TText)gDriveToTest;	
sl@0
   367
	test.Printf(_L("the Private Path = %S"),&theprivatepath);
sl@0
   368
sl@0
   369
	mkdirname.Zero();
sl@0
   370
	mkdirname.Append(theprivatepath);
sl@0
   371
	mkdirname.Append(KMkDirSub);
sl@0
   372
	r=TheFs.MkDirAll(mkdirname);	
sl@0
   373
	test(r==KErrNone);
sl@0
   374
sl@0
   375
	r=TheFs.RmDir(mkdirname);	
sl@0
   376
	test(r==KErrNone);
sl@0
   377
sl@0
   378
	r=TheFs.SetSubst(theprivatepath,EDriveO);	
sl@0
   379
	test(r==KErrPermissionDenied);
sl@0
   380
sl@0
   381
	r=TheFs.RealName(_L("O:\\File.XXX"),realName);
sl@0
   382
	test(r==KErrNone);
sl@0
   383
sl@0
   384
	r=TheFs.SetSessionPath(theprivatepath);
sl@0
   385
	test(r==KErrNone);
sl@0
   386
sl@0
   387
	TheFs.NotifyChange(ENotifyAll,aStat3,theprivatepath);
sl@0
   388
	test(aStat3==KRequestPending);
sl@0
   389
sl@0
   390
	pritestfile=theprivatepath;
sl@0
   391
	pritestfile[0]=(TText)('A' + gTheDriveNum);
sl@0
   392
	pritestfile1=pritestfile;
sl@0
   393
	pritestfile.Append(KFilePri2);
sl@0
   394
	pritestfile1.Append(KFilePri3);
sl@0
   395
	
sl@0
   396
	oldName=KOldFile;
sl@0
   397
	oldName[0]=(TText)gDriveToTest;
sl@0
   398
sl@0
   399
	r=TheFs.GetShortName(pritestfile, shortfilename);
sl@0
   400
	test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
sl@0
   401
sl@0
   402
	r=TheFs.GetLongName(pritestfile1, longfilename);
sl@0
   403
	test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
sl@0
   404
sl@0
   405
	r=file1.Create(TheFs,oldName,EFileWrite);
sl@0
   406
	test(r==KErrNone || r==KErrAlreadyExists);
sl@0
   407
	file1.Close();
sl@0
   408
sl@0
   409
	r=TheFs.Replace(oldName,pritestfile);
sl@0
   410
	test(r==KErrNone);
sl@0
   411
	
sl@0
   412
	r=TheFs.Rename(pritestfile,pritestfile1);
sl@0
   413
	test(r==KErrNone || r==KErrAlreadyExists);
sl@0
   414
	
sl@0
   415
	r=TheFs.Entry(pritestfile1,entry);
sl@0
   416
	test(r==KErrNone);
sl@0
   417
sl@0
   418
	r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
sl@0
   419
	test(r==KErrNone);
sl@0
   420
sl@0
   421
	r=TheFs.Delete(pritestfile1);
sl@0
   422
	test(r==KErrNone);
sl@0
   423
	}
sl@0
   424
sl@0
   425
sl@0
   426
LOCAL_C void systemRFiletest()
sl@0
   427
//
sl@0
   428
//RFile testing with session path set to //system//
sl@0
   429
//
sl@0
   430
	{
sl@0
   431
sl@0
   432
	r=TheFs.SetSessionPath(systestname);
sl@0
   433
	test(r==KErrNone);
sl@0
   434
sl@0
   435
	r=file1.Temp(TheFs,systestname,fromTemp,EFileWrite);
sl@0
   436
	test(r==KErrNone);
sl@0
   437
	file1.Close();
sl@0
   438
sl@0
   439
	r=file1.Create(TheFs,KFileSys,EFileWrite);
sl@0
   440
	test(r==KErrNone);
sl@0
   441
	file1.Close();
sl@0
   442
sl@0
   443
	r=file1.Open(TheFs,KFileSys,EFileWrite);
sl@0
   444
	test(r==KErrNone);
sl@0
   445
	file1.Close();
sl@0
   446
	
sl@0
   447
	r=file1.Open(TheFs,KFileSys,EFileRead);
sl@0
   448
	test(r==KErrNone);
sl@0
   449
	file1.Close();
sl@0
   450
sl@0
   451
	r=file1.Replace(TheFs,KFileSys,EFileWrite);
sl@0
   452
	test(r==KErrNone);
sl@0
   453
	
sl@0
   454
	r=file1.Rename(KFileSys3);
sl@0
   455
	test(r==KErrNone);
sl@0
   456
	file1.Close();
sl@0
   457
sl@0
   458
    TFindFile finder(TheFs);
sl@0
   459
    CDir* dir = NULL;
sl@0
   460
    r=finder.FindWildByDir(KWildFile, KWildPath, dir);
sl@0
   461
	if (!(r==KErrNone))
sl@0
   462
        test.Printf(_L("T_DCTCBALLFILES: test find wildcards r = %d (expected KErrNone)\n"), r);
sl@0
   463
	test(r==KErrNone);
sl@0
   464
	delete dir;
sl@0
   465
	}
sl@0
   466
sl@0
   467
LOCAL_C void resourceRFiletest()
sl@0
   468
//
sl@0
   469
//RFile testing with session path set to //resource//
sl@0
   470
//
sl@0
   471
	{
sl@0
   472
	r=TheFs.SetSessionPath(restestname);
sl@0
   473
	test(r==KErrNone);
sl@0
   474
sl@0
   475
	r=file1.Temp(TheFs,restestname,fromTemp,EFileWrite);
sl@0
   476
	test(r==KErrNone);
sl@0
   477
	file1.Close();
sl@0
   478
sl@0
   479
	r=file1.Create(TheFs,KFileRes,EFileWrite);
sl@0
   480
	test(r==KErrNone);
sl@0
   481
	file1.Close();
sl@0
   482
sl@0
   483
	r=file1.Open(TheFs,KFileRes,EFileWrite|EFileShareExclusive );
sl@0
   484
	test(r==KErrNone);
sl@0
   485
	
sl@0
   486
	r=file1.Rename(KFileRes3);
sl@0
   487
	test(r==KErrNone);
sl@0
   488
	file1.Close();
sl@0
   489
sl@0
   490
	r=file1.Open(TheFs,KFileRes3,EFileShareReadersOrWriters|EFileRead);
sl@0
   491
	test(r==KErrNone);
sl@0
   492
	file1.Close();
sl@0
   493
sl@0
   494
	r=file1.Open(TheFs,KFileRes3,EFileShareReadersOrWriters|EFileWrite);
sl@0
   495
	test(r==KErrNone);
sl@0
   496
	file1.Close();
sl@0
   497
sl@0
   498
	r=file1.Open(TheFs,KFileRes3,EFileShareReadersOnly);
sl@0
   499
	test(r==KErrNone);
sl@0
   500
sl@0
   501
	r=file1.ChangeMode(EFileShareExclusive);
sl@0
   502
	test(r==KErrNone);
sl@0
   503
	file1.Close();
sl@0
   504
sl@0
   505
	r=file1.Replace(TheFs,KFileRes,EFileWrite);
sl@0
   506
	test(r==KErrNone);
sl@0
   507
	file1.Close();	
sl@0
   508
	}
sl@0
   509
sl@0
   510
sl@0
   511
LOCAL_C void privateRFiletest()
sl@0
   512
//
sl@0
   513
//RFile testing with session path set to //Private//
sl@0
   514
//
sl@0
   515
	{
sl@0
   516
	r=TheFs.SetSessionPath(pritestfalseidname);
sl@0
   517
	test(r==KErrNone);
sl@0
   518
sl@0
   519
	r=file1.Temp(TheFs,pritestfalseidname,fromTemp,EFileWrite);
sl@0
   520
	test(r==KErrNone);
sl@0
   521
	file1.Close();
sl@0
   522
sl@0
   523
	r=file1.Create(TheFs,KFilePri,EFileWrite);
sl@0
   524
	test(r==KErrNone);
sl@0
   525
	file1.Close();
sl@0
   526
sl@0
   527
	r=file1.Open(TheFs,KFilePri,EFileWrite);
sl@0
   528
	test(r==KErrNone);
sl@0
   529
	file1.Close();
sl@0
   530
	
sl@0
   531
	r=file1.Open(TheFs,KFilePri,EFileRead);
sl@0
   532
	test(r==KErrNone);
sl@0
   533
	file1.Close();
sl@0
   534
	
sl@0
   535
	r=file1.Replace(TheFs,KFilePri,EFileWrite);
sl@0
   536
	test(r==KErrNone);
sl@0
   537
	
sl@0
   538
	r=file1.Rename(KFilePri3);
sl@0
   539
	test(r==KErrNone);
sl@0
   540
	file1.Close();
sl@0
   541
	}
sl@0
   542
sl@0
   543
sl@0
   544
LOCAL_C void privatefalseIDRFiletest()
sl@0
   545
//
sl@0
   546
//RFile testing with session path set to //Private//
sl@0
   547
//
sl@0
   548
	{
sl@0
   549
	r=TheFs.SetSessionPath(pritestname);
sl@0
   550
	test(r==KErrNone);
sl@0
   551
sl@0
   552
	r=file1.Temp(TheFs,pritestname,fromTemp,EFileWrite);
sl@0
   553
	test(r==KErrNone);
sl@0
   554
	file1.Close();
sl@0
   555
sl@0
   556
	r=file1.Create(TheFs,KFilePri,EFileWrite);
sl@0
   557
	test(r==KErrNone);
sl@0
   558
	file1.Close();
sl@0
   559
sl@0
   560
	r=file1.Open(TheFs,KFilePri,EFileWrite);
sl@0
   561
	test(r==KErrNone);
sl@0
   562
	file1.Close();
sl@0
   563
	
sl@0
   564
	r=file1.Open(TheFs,KFilePri,EFileRead);
sl@0
   565
	test(r==KErrNone);
sl@0
   566
	file1.Close();
sl@0
   567
	
sl@0
   568
	r=file1.Replace(TheFs,KFilePri,EFileWrite);
sl@0
   569
	test(r==KErrNone);
sl@0
   570
	
sl@0
   571
	r=file1.Rename(KFilePri3);
sl@0
   572
	test(r==KErrNone);
sl@0
   573
	file1.Close();
sl@0
   574
	}
sl@0
   575
sl@0
   576
sl@0
   577
LOCAL_C void privateSIDRFiletest()
sl@0
   578
//
sl@0
   579
//Rfile Testing with session path set to //Private//UID//
sl@0
   580
//
sl@0
   581
	{
sl@0
   582
	r=TheFs.SetSessionToPrivate(gTheDriveNum);
sl@0
   583
	test(r==KErrNone);
sl@0
   584
	
sl@0
   585
	r=file1.Temp(TheFs,theprivatepath,fromTemp,EFileWrite);
sl@0
   586
	test(r==KErrNone);
sl@0
   587
	file1.Close();
sl@0
   588
sl@0
   589
	r=file1.Create(TheFs,KFilePri,EFileWrite);
sl@0
   590
	test(r==KErrNone);
sl@0
   591
	file1.Close();
sl@0
   592
sl@0
   593
	r=file1.Open(TheFs,KFilePri,EFileWrite);
sl@0
   594
	test(r==KErrNone);
sl@0
   595
	file1.Close();
sl@0
   596
	
sl@0
   597
	r=file1.Open(TheFs,KFilePri,EFileRead);
sl@0
   598
	test(r==KErrNone);
sl@0
   599
	file1.Close();
sl@0
   600
	
sl@0
   601
	r=file1.Replace(TheFs,KFilePri,EFileWrite);
sl@0
   602
	test(r==KErrNone);
sl@0
   603
	
sl@0
   604
	r=file1.Rename(KFilePri3);
sl@0
   605
	test(r==KErrNone);
sl@0
   606
	file1.Close();
sl@0
   607
	}
sl@0
   608
sl@0
   609
LOCAL_C void RDirtest()
sl@0
   610
//
sl@0
   611
//
sl@0
   612
//
sl@0
   613
	{
sl@0
   614
sl@0
   615
	//system
sl@0
   616
	CDir*	dirEntries;
sl@0
   617
	TBuf<30> dirNameBuf(KSystemPath);
sl@0
   618
	dirNameBuf[0]=(TText)gDriveToTest;
sl@0
   619
	r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
sl@0
   620
	test(r==KErrNone);
sl@0
   621
	dir.Close();
sl@0
   622
	r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
sl@0
   623
	test(r==KErrNone);
sl@0
   624
	dirNameBuf.Zero();
sl@0
   625
	delete dirEntries;
sl@0
   626
sl@0
   627
	//Private
sl@0
   628
	dirNameBuf=KPrivatePath;
sl@0
   629
	dirNameBuf[0]=(TText)gDriveToTest;
sl@0
   630
	r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
sl@0
   631
	test(r==KErrNone);
sl@0
   632
	dir.Close();
sl@0
   633
	r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
sl@0
   634
	test(r==KErrNone);
sl@0
   635
	dirNameBuf.Zero();
sl@0
   636
	delete dirEntries;
sl@0
   637
sl@0
   638
	//Private//false ID
sl@0
   639
	dirNameBuf=KPrivateFalseID;
sl@0
   640
	dirNameBuf[0]=(TText)gDriveToTest;
sl@0
   641
	r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
sl@0
   642
	test(r==KErrNone);
sl@0
   643
	dir.Close();
sl@0
   644
	r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
sl@0
   645
	test(r==KErrNone);
sl@0
   646
	dirNameBuf.Zero();
sl@0
   647
	delete dirEntries;
sl@0
   648
sl@0
   649
	//Private/uid
sl@0
   650
	TheFs.PrivatePath(dirNameBuf);
sl@0
   651
	dirNameBuf.Insert(0,_L("?:"));
sl@0
   652
	dirNameBuf[0]=(TText)gDriveToTest;
sl@0
   653
	r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
sl@0
   654
	test(r==KErrNone);
sl@0
   655
	dir.Close();
sl@0
   656
	r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
sl@0
   657
	test(r==KErrNone);
sl@0
   658
	dirNameBuf.Zero();
sl@0
   659
	delete dirEntries;
sl@0
   660
	//Resource
sl@0
   661
	dirNameBuf=KResourcePath;
sl@0
   662
	dirNameBuf[0]=(TText)gDriveToTest;
sl@0
   663
	r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
sl@0
   664
	test(r==KErrNone);
sl@0
   665
	r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
sl@0
   666
	test(r==KErrNone);
sl@0
   667
	dir.Close();
sl@0
   668
	delete dirEntries;
sl@0
   669
	}
sl@0
   670
sl@0
   671
sl@0
   672
LOCAL_C void TestTcbAllfiles()
sl@0
   673
//
sl@0
   674
//	Test with tcb capabilities
sl@0
   675
//
sl@0
   676
	{
sl@0
   677
	r=TheFs.FileSystemName(fsname,gTheDriveNum);
sl@0
   678
	test(r==KErrNone);
sl@0
   679
	r = DismountFileSystem(TheFs, fsname, gTheDriveNum);
sl@0
   680
	test(r==KErrPermissionDenied);
sl@0
   681
//	r=TheFs.RemoveFileSystem(fsname);	//can not test due to bug else where fix exists
sl@0
   682
//	test(r==KErrNone);
sl@0
   683
//	r=TheFs.AddFileSystem(fsname);
sl@0
   684
//	test(r==KErrNone);
sl@0
   685
	r = MountFileSystem(TheFs, fsname, gTheDriveNum);
sl@0
   686
	test(r==KErrPermissionDenied);
sl@0
   687
	test.Printf(_L("r=%d"),r);
sl@0
   688
	r=TheFs.SetDriveName(gTheDriveNum,KDriveName);
sl@0
   689
	test(r==KErrPermissionDenied);
sl@0
   690
#ifndef __WINS__
sl@0
   691
 	r=TheFs.SetVolumeLabel(KVolLable, gTheDriveNum);
sl@0
   692
	test(r==KErrPermissionDenied);
sl@0
   693
#endif
sl@0
   694
sl@0
   695
	systemRFsTest();
sl@0
   696
	ResourceRFsTest();
sl@0
   697
	privateRFsTest();	
sl@0
   698
	privateSIDRFstest();
sl@0
   699
	privatefalseIDRFsTest();
sl@0
   700
sl@0
   701
	systemRFiletest();
sl@0
   702
	resourceRFiletest();
sl@0
   703
	privateRFiletest();
sl@0
   704
	privateSIDRFiletest();
sl@0
   705
	privatefalseIDRFiletest();
sl@0
   706
sl@0
   707
	//check notifier return values set in rfs testing
sl@0
   708
	User::WaitForRequest(aStat1);
sl@0
   709
	User::WaitForRequest(aStat2);
sl@0
   710
	User::WaitForRequest(aStat3);
sl@0
   711
	User::WaitForRequest(aStat4);
sl@0
   712
	test(aStat1==KErrNone);
sl@0
   713
	test(aStat2==KErrNone);
sl@0
   714
	test(aStat3==KErrNone);
sl@0
   715
	test(aStat4==KErrNone);
sl@0
   716
sl@0
   717
	r=TheFs.SetSessionPath(systestname);
sl@0
   718
	test(r==KErrNone);
sl@0
   719
	
sl@0
   720
//Test RRawDisk class
sl@0
   721
	r=rawdisk.Open(TheFs,gTheDriveNum);
sl@0
   722
	test(r==KErrNone);
sl@0
   723
	rawdisk.Close();
sl@0
   724
sl@0
   725
	RDirtest();
sl@0
   726
sl@0
   727
#ifdef __WINS__
sl@0
   728
	if (User::UpperCase(driveBuf[0]) != 'C')
sl@0
   729
#endif
sl@0
   730
		{
sl@0
   731
		//Test RFormat class
sl@0
   732
		r=format.Open(TheFs,driveBuf,EHighDensity,count);
sl@0
   733
		test(r==KErrPermissionDenied);
sl@0
   734
sl@0
   735
		while(count)	
sl@0
   736
			{
sl@0
   737
			TInt r=format.Next(count);
sl@0
   738
			test(r==KErrNone);
sl@0
   739
			}
sl@0
   740
		format.Close();
sl@0
   741
		}
sl@0
   742
sl@0
   743
	driveBuf[0]=(TText)gDriveToTest;
sl@0
   744
	r=TheFs.ScanDrive(driveBuf);
sl@0
   745
	RDebug::Print(_L("r=%d"),r);
sl@0
   746
	test(r==KErrPermissionDenied);
sl@0
   747
	r=TheFs.CheckDisk(driveBuf);
sl@0
   748
	test(r==KErrPermissionDenied);
sl@0
   749
	}
sl@0
   750
sl@0
   751
LOCAL_C void TestCaps()
sl@0
   752
//
sl@0
   753
//	test format etc that require certain capabilities
sl@0
   754
//
sl@0
   755
	{
sl@0
   756
#ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
sl@0
   757
	const char myDiagMsg[] = "Capability Check Failure";
sl@0
   758
#endif //!__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
sl@0
   759
	r=RProcess().HasCapability(ECapabilityTCB, __PLATSEC_DIAGNOSTIC_STRING(myDiagMsg));
sl@0
   760
	test(r);
sl@0
   761
	r=RProcess().HasCapability(ECapabilityAllFiles, __PLATSEC_DIAGNOSTIC_STRING(myDiagMsg));
sl@0
   762
	test(r);
sl@0
   763
	
sl@0
   764
	driveBuf[0]=(TText)gDriveToTest;
sl@0
   765
	r=TheFs.SessionPath(temp);
sl@0
   766
	test(r==KErrNone);
sl@0
   767
sl@0
   768
	test.Printf(_L("Session path: %S"),&temp);
sl@0
   769
sl@0
   770
	r=TheFs.CreatePrivatePath(gTheDriveNum);
sl@0
   771
	test(r==KErrNone || r== KErrAlreadyExists);
sl@0
   772
sl@0
   773
	TBuf<18> tempPri;
sl@0
   774
	r=TheFs.PrivatePath(tempPri);
sl@0
   775
	test(r==KErrNone);
sl@0
   776
	theprivatepath = _L("?:");
sl@0
   777
	theprivatepath.Append(tempPri);
sl@0
   778
sl@0
   779
	TestTcbAllfiles();
sl@0
   780
	
sl@0
   781
	TFileName thesessionpath;
sl@0
   782
	r=TheFs.SetSessionToPrivate(gTheDriveNum);
sl@0
   783
	test(r==KErrNone);
sl@0
   784
	r=TheFs.SessionPath(thesessionpath);
sl@0
   785
	test(r==KErrNone);
sl@0
   786
sl@0
   787
	test(thesessionpath == theprivatepath);
sl@0
   788
	}
sl@0
   789
sl@0
   790
sl@0
   791
TFileName dirName;
sl@0
   792
sl@0
   793
LOCAL_C void ScanDir(const TDesC& aName, CDirScan::TScanDirection aDirection, TInt aError)
sl@0
   794
	{
sl@0
   795
	CDirScan* scanner = NULL;
sl@0
   796
	TRAP(r, scanner = CDirScan::NewL(TheFs));
sl@0
   797
	test(r == KErrNone && scanner);
sl@0
   798
sl@0
   799
	TRAP(r, scanner->SetScanDataL(aName,KEntryAttDir,ESortByName|EAscending,aDirection));
sl@0
   800
	test(r == KErrNone);
sl@0
   801
sl@0
   802
	CDir *entryList=NULL;
sl@0
   803
	for (;;)
sl@0
   804
		{
sl@0
   805
		TRAP(r, scanner->NextL(entryList));
sl@0
   806
		test(r == aError);
sl@0
   807
		if (entryList==NULL)
sl@0
   808
			break;
sl@0
   809
sl@0
   810
        TInt count=entryList->Count();
sl@0
   811
sl@0
   812
        while (count--)
sl@0
   813
			{
sl@0
   814
			TEntry data=(*entryList)[count];
sl@0
   815
			TBuf<KMaxFileName> path=scanner->AbbreviatedPath();
sl@0
   816
			
sl@0
   817
			dirName = path;
sl@0
   818
			dirName.Append(data.iName);
sl@0
   819
			test.Printf(_L("    %S\n"),&dirName);
sl@0
   820
			
sl@0
   821
			}
sl@0
   822
		delete entryList;
sl@0
   823
		entryList=NULL;
sl@0
   824
		}
sl@0
   825
	delete scanner;
sl@0
   826
sl@0
   827
	}
sl@0
   828
sl@0
   829
/**
sl@0
   830
The following test, tests CFileMan and CDirScan API on folders private and sys
sl@0
   831
to confirm that any operation on these folders for any app with incorrect capability
sl@0
   832
returns KErrPermissionDenied. This test step was added as a result of DEF051428
sl@0
   833
("PlatSec: Incorrect errors returned by f32")
sl@0
   834
*/
sl@0
   835
LOCAL_C void TestCaging()
sl@0
   836
	{
sl@0
   837
	CFileMan* fMan=CFileMan::NewL(TheFs);
sl@0
   838
	TInt r;
sl@0
   839
	if(fMan!=NULL)
sl@0
   840
		{		
sl@0
   841
		
sl@0
   842
		// Checking the private path
sl@0
   843
		TBuf<30> privatepath;
sl@0
   844
		r=TheFs.PrivatePath(privatepath);
sl@0
   845
		test.Printf(_L("Private Path is=%S"),&privatepath);
sl@0
   846
		
sl@0
   847
		r = TheFs.MkDir(_L("\\Caged\\"));
sl@0
   848
		test(r==KErrNone || r==KErrAlreadyExists);
sl@0
   849
		
sl@0
   850
		CDir* entryCount=NULL;
sl@0
   851
		r=TheFs.GetDir(_L("\\*.*"),KEntryAttNormal|KEntryAttDir,ESortNone,entryCount);
sl@0
   852
		test(r==KErrNone);
sl@0
   853
		
sl@0
   854
		delete entryCount;
sl@0
   855
		entryCount=NULL;
sl@0
   856
sl@0
   857
sl@0
   858
		//Testing Copy
sl@0
   859
		CDir* entryCount2=NULL;
sl@0
   860
		r=fMan->Copy(_L("\\sys\\"),_L("\\Caged\\"));
sl@0
   861
		test(r == KErrNone);
sl@0
   862
		r=fMan->Copy(_L("\\*"),_L("\\Caged\\"));
sl@0
   863
		test(r == KErrNone);
sl@0
   864
		
sl@0
   865
		r=TheFs.GetDir(_L("\\Caged\\*.*"),KEntryAttNormal|KEntryAttDir,ESortNone,entryCount2);
sl@0
   866
		test(r==KErrNone);
sl@0
   867
		
sl@0
   868
		delete entryCount2;
sl@0
   869
		entryCount2=NULL;
sl@0
   870
	
sl@0
   871
		r=fMan->Copy(_L("\\private\\two\\moo"),_L("\\private\\two\\mew")); 
sl@0
   872
		test(r == KErrPathNotFound);
sl@0
   873
	
sl@0
   874
		// Create a test file
sl@0
   875
		RFile testFile;
sl@0
   876
		r = testFile.Replace(TheFs, _L("\\capTest"),EFileWrite);
sl@0
   877
		test(r==KErrNone || r==KErrAlreadyExists);
sl@0
   878
		testFile.Close();
sl@0
   879
		
sl@0
   880
		TFileName name;
sl@0
   881
		name = privatepath;
sl@0
   882
		name.Append(_L("privateFile.tst"));
sl@0
   883
		RFile privateFile;
sl@0
   884
		r = privateFile.Replace(TheFs, name,EFileWrite);
sl@0
   885
		test(r==KErrNone || r==KErrAlreadyExists);
sl@0
   886
		privateFile.Close();
sl@0
   887
sl@0
   888
	
sl@0
   889
		r=fMan->Copy(_L("\\capTest"),_L("\\private\\two\\moo")); 
sl@0
   890
		test(r == KErrPathNotFound);
sl@0
   891
		r=fMan->Copy(_L("\\capTest"),_L("\\sys\\bin\\moo")); 
sl@0
   892
		test(r == KErrPathNotFound); 
sl@0
   893
		r=fMan->Copy(_L("\\sys\\bin\\capTest"),_L("\\sys\\bin\\moo")); 
sl@0
   894
		test(r == KErrPathNotFound);
sl@0
   895
		r=fMan->Copy(_L("\\capTest"),_L("\\sys\\capTest")); 
sl@0
   896
		test(r == KErrNone || r==KErrAlreadyExists); 
sl@0
   897
		r=fMan->Copy(_L("\\sys\\*"),_L("\\"));
sl@0
   898
		test (r==KErrNone);
sl@0
   899
		r=fMan->Copy(name,_L("\\sys\\"));
sl@0
   900
		test(r==KErrNone);
sl@0
   901
sl@0
   902
		// Testing Attribs
sl@0
   903
		r=fMan->Attribs(_L("\\private\\two\\moo"),KEntryAttReadOnly,0,TTime(0)); 
sl@0
   904
		test(r == KErrPathNotFound);
sl@0
   905
		r=fMan->Attribs(_L("\\private\\moo"),KEntryAttReadOnly,0,TTime(0)); 
sl@0
   906
		test(r == KErrNotFound);
sl@0
   907
		r=fMan->Attribs(name,KEntryAttReadOnly,0,TTime(0));
sl@0
   908
		test(r == KErrNone);
sl@0
   909
		r=fMan->Attribs(name,0,KEntryAttReadOnly,TTime(0));
sl@0
   910
		test(r == KErrNone);
sl@0
   911
sl@0
   912
		// Testing Move
sl@0
   913
		r=fMan->Move(_L("\\private\\two\\moo"),_L("\\private\\one\\moo"));
sl@0
   914
		test(r == KErrPathNotFound);
sl@0
   915
		r=fMan->Move(_L("\\private\\two\\moo.."),_L("\\private\\one\\moo"));
sl@0
   916
		test(r == KErrPathNotFound);
sl@0
   917
		r=fMan->Move(_L("\\private\\two\\moo"),_L("\\private\\one\\moo.."));
sl@0
   918
		test(r == KErrPathNotFound);
sl@0
   919
		r=fMan->Move(name,_L("\\privateFile.tst"));
sl@0
   920
		test(r == KErrNone);
sl@0
   921
		r=fMan->Move(_L("\\privateFile.tst"),name);
sl@0
   922
		test(r == KErrNone);
sl@0
   923
sl@0
   924
sl@0
   925
		// Testing RmDir
sl@0
   926
		r=fMan->RmDir(_L("\\private\\"));
sl@0
   927
		test(r == KErrNone);
sl@0
   928
		// put it back where it was
sl@0
   929
		r = TheFs.MkDirAll(_L("\\private\\00000001\\"));
sl@0
   930
		test(r == KErrNone);
sl@0
   931
		r=fMan->RmDir(_L("\\private\\two\\"));
sl@0
   932
		test(r == KErrPathNotFound);
sl@0
   933
		r=fMan->RmDir(_L("\\private\\tw?\\"));
sl@0
   934
		test(r == KErrBadName);
sl@0
   935
sl@0
   936
		r=fMan->RmDir(_L("\\private\\two\\"));
sl@0
   937
		test(r == KErrPathNotFound);
sl@0
   938
		r=fMan->RmDir(_L("\\private\\tw?\\"));
sl@0
   939
		test(r == KErrBadName);
sl@0
   940
		
sl@0
   941
		
sl@0
   942
		// Testing Rename
sl@0
   943
		r=fMan->Rename(_L("\\private\\two\\moo"),_L("\\private\\two\\mew")); 
sl@0
   944
		test(r == KErrPathNotFound);
sl@0
   945
		
sl@0
   946
		// Testing Delete
sl@0
   947
		r=fMan->Delete(_L("\\private\\two\\test")); 
sl@0
   948
		test(r == KErrPathNotFound);
sl@0
   949
		r=fMan->Delete(_L("\\private\\moo")); 
sl@0
   950
		test(r == KErrNotFound);
sl@0
   951
		
sl@0
   952
		//Something that actually exists in Private
sl@0
   953
		r=fMan->Rename(name,_L("\\private\\00000001\\moo")); 
sl@0
   954
		test(r == KErrNotFound);
sl@0
   955
		r=fMan->Rename(_L("\\private\\00000001\\moo"),name); 
sl@0
   956
		test(r == KErrNotFound);
sl@0
   957
		r=fMan->Copy(name,_L("\\private\\00000001\\moo")); 
sl@0
   958
		test(r == KErrNotFound);
sl@0
   959
		r=fMan->Delete(_L("\\private\\00000001\\moo")); 
sl@0
   960
		test(r == KErrNotFound);
sl@0
   961
sl@0
   962
		// Clean up the test data
sl@0
   963
		r=fMan->RmDir(_L("\\Caged\\")); 
sl@0
   964
		test(r == KErrNone);
sl@0
   965
		r=fMan->Delete(_L("\\capTest")); 
sl@0
   966
		test(r == KErrNone);
sl@0
   967
		delete(fMan);
sl@0
   968
		}
sl@0
   969
	
sl@0
   970
	// CDirScan tests
sl@0
   971
	ScanDir(_L("\\"), CDirScan::EScanUpTree, KErrNone);
sl@0
   972
	ScanDir(_L("\\"), CDirScan::EScanDownTree, KErrNone);
sl@0
   973
	ScanDir(_L("\\private\\"), CDirScan::EScanDownTree, KErrNone);
sl@0
   974
	ScanDir(_L("\\private\\"), CDirScan::EScanUpTree, KErrNone);
sl@0
   975
	ScanDir(_L("\\sys\\"), CDirScan::EScanDownTree, KErrNone);
sl@0
   976
	ScanDir(_L("\\sys\\"), CDirScan::EScanUpTree, KErrNone);
sl@0
   977
	}
sl@0
   978
sl@0
   979
LOCAL_C void CleanupL()
sl@0
   980
//
sl@0
   981
// Clean up tests
sl@0
   982
//
sl@0
   983
	{
sl@0
   984
	test.Next(_L("Delete test directory"));
sl@0
   985
	CFileMan* fMan=CFileMan::NewL(TheFs);
sl@0
   986
	TInt r=fMan->RmDir(gSessionPath);
sl@0
   987
	test(r==KErrNone || KErrPathNotFound);
sl@0
   988
	delete fMan;
sl@0
   989
	}
sl@0
   990
sl@0
   991
GLDEF_C void CallTestsL(/*TChar aDriveLetter*/)
sl@0
   992
//
sl@0
   993
// Do all tests
sl@0
   994
//
sl@0
   995
	{
sl@0
   996
	if( !PlatSec::IsCapabilityEnforced(ECapabilityTCB) || 
sl@0
   997
		!PlatSec::IsCapabilityEnforced(ECapabilityAllFiles))
sl@0
   998
		{
sl@0
   999
		test.Printf(_L("Insufficient capabilities enabled - leaving t_dctcballfiles"));
sl@0
  1000
		test.Printf(_L("\n")); // Prevent overwrite by next print
sl@0
  1001
		return;
sl@0
  1002
		}
sl@0
  1003
	TurnAllocFailureOff();
sl@0
  1004
	TheFs.CharToDrive(gDriveToTest,gTheDriveNum);
sl@0
  1005
	
sl@0
  1006
	TBuf<30> sesspath;
sl@0
  1007
	sesspath=_L("?:\\");
sl@0
  1008
	sesspath[0] = (TText)gDriveToTest;
sl@0
  1009
sl@0
  1010
	TInt r= TheFs.SetSessionPath(sesspath);
sl@0
  1011
	test(r==KErrNone);
sl@0
  1012
sl@0
  1013
	//cleanup from previous run of this test
sl@0
  1014
	TBuf<20> delDir;
sl@0
  1015
	CFileMan* fMan=CFileMan::NewL(TheFs);
sl@0
  1016
	delDir=KResourcePath;
sl@0
  1017
	delDir[0]=(TText)gDriveToTest;
sl@0
  1018
	r=fMan->RmDir(delDir);
sl@0
  1019
	test(r==KErrNone || KErrNotFound);
sl@0
  1020
	delDir=KSystemPath;
sl@0
  1021
	delDir[0]=(TText)gDriveToTest;
sl@0
  1022
	r=fMan->RmDir(delDir);
sl@0
  1023
	test(r==KErrNone || KErrNotFound);
sl@0
  1024
	delDir=KPrivatePath;
sl@0
  1025
	delDir[0]=(TText)gDriveToTest;
sl@0
  1026
	r=fMan->RmDir(delDir);
sl@0
  1027
	test(r==KErrNone || KErrNotFound);
sl@0
  1028
	delete fMan;
sl@0
  1029
sl@0
  1030
	//check double mode ie that Defpath still works	
sl@0
  1031
	RFs fs1;
sl@0
  1032
	RFs fs2;
sl@0
  1033
	
sl@0
  1034
	r=fs1.Connect();
sl@0
  1035
	test(r==KErrNone);
sl@0
  1036
	r=fs1.SessionPath(sesspath);
sl@0
  1037
	test(r==KErrNone);
sl@0
  1038
	test.Printf(_L("session1 Path=%S"),&sesspath);
sl@0
  1039
sl@0
  1040
	TBuf<30> privatepath;
sl@0
  1041
	r=fs1.SetSessionToPrivate(gTheDriveNum);
sl@0
  1042
	test(r==KErrNone);
sl@0
  1043
	r=fs1.PrivatePath(privatepath);
sl@0
  1044
	test(r==KErrNone);
sl@0
  1045
	r=privatepath.Compare(KExpectedPrivatePath());
sl@0
  1046
	test(r==0);
sl@0
  1047
	r=fs1.SessionPath(sesspath);
sl@0
  1048
	test(r==KErrNone);
sl@0
  1049
	r=privatepath.Compare(sesspath.Mid(KPathPosition));
sl@0
  1050
	test(r==0);
sl@0
  1051
	r=fs1.CreatePrivatePath(gTheDriveNum);
sl@0
  1052
	test(r==KErrNone);
sl@0
  1053
	fs1.Close();
sl@0
  1054
sl@0
  1055
	r=fs2.Connect();
sl@0
  1056
	test(r==KErrNone);
sl@0
  1057
	r=fs2.SessionPath(sesspath);
sl@0
  1058
	test(r==KErrNone);
sl@0
  1059
	test.Printf(_L("session2 Path=%S"),&sesspath);
sl@0
  1060
	fs2.Close();
sl@0
  1061
sl@0
  1062
	TestCaps();
sl@0
  1063
	TestCaging();
sl@0
  1064
sl@0
  1065
	test.Printf(_L("No of files open=%d"), TheFs.ResourceCount());
sl@0
  1066
sl@0
  1067
	CleanupL();
sl@0
  1068
	}