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