kerneltest/f32test/server/t_dcallcaps.cpp
changeset 0 a41df078684a
child 43 c1f20ce4abcf
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <f32file.h>
       
    17 #include <e32test.h>
       
    18 #include <e32std.h>
       
    19 #include <e32std_private.h>
       
    20 #include <e32def.h>
       
    21 #include <e32def_private.h>
       
    22 #include <e32svr.h>
       
    23 #include "t_server.h"
       
    24 
       
    25 GLDEF_D RTest test(_L("t_dcallcaps"));
       
    26 GLDEF_D TTime gTimeNow;
       
    27 LOCAL_D TInt gTheDriveNum;
       
    28 
       
    29 
       
    30 const TInt KPathPosition = 2;
       
    31 _LIT(KExpectedPrivatePath, "\\Private\\00000001\\");
       
    32 _LIT(KResourcePath, "?:\\Resource\\");
       
    33 _LIT(KSystemPath,	"?:\\Sys\\");
       
    34 _LIT(KPrivatePath,	"?:\\Private\\");
       
    35 _LIT(KPrivateFalseID,	"?:\\Private\\FFFFFFFF\\");
       
    36 _LIT(KDriveName,	"Billy");
       
    37 _LIT(KVolLable,		"Benny");
       
    38 _LIT(KFileSys,	"systemfile.txt");
       
    39 _LIT(KFileSys3, "sysfile.rna");
       
    40 _LIT(KFilePri,	"privatefile.txt");
       
    41 _LIT(KFilePri2,	"privatefile.tmp");
       
    42 _LIT(KFilePri3,	"prifile.rna");
       
    43 _LIT(KFileRes,	"resourcefile.txt");
       
    44 _LIT(KFileRes3,	"resfile.rna");
       
    45 _LIT(KMkDirSub,"Subdir\\");
       
    46 _LIT(KOldFile,"?:\\Anyold.txt");
       
    47 _LIT(KWildPath, "Z:\\SYS\\");
       
    48 _LIT(KWildFile, "*");
       
    49 
       
    50 TCapability TheCaps;
       
    51 TBuf<4> driveBuf=_L("?:\\");
       
    52 RFormat format;
       
    53 TInt count;
       
    54 RRawDisk rawdisk;
       
    55 RFile file1;
       
    56 RFile file2;
       
    57 RDir	dir;
       
    58 
       
    59 TInt r;
       
    60 TBuf<40> fsname;
       
    61 TBuf<40> systestname;
       
    62 TBuf<40> pritestname;
       
    63 TBuf<40> restestname;
       
    64 TBuf<40> theprivatepath;
       
    65 TBuf<40> pritestfalseidname;
       
    66 TBuf<40> mkdirname;
       
    67 TFileName fromTemp;
       
    68 
       
    69 TBuf<25> sysfilename;
       
    70 TBuf<30> realName;
       
    71 TBuf<40> shortfilename;
       
    72 TBuf<40> longfilename;
       
    73 
       
    74 TRequestStatus aStat1;
       
    75 TRequestStatus aStat2;
       
    76 TRequestStatus aStat3;
       
    77 TRequestStatus aStat4;
       
    78 
       
    79 TVolumeInfo aVolInfo;
       
    80 //	TDriveInfo adriveInfo;
       
    81 
       
    82 TBuf<40> systestfile;
       
    83 TBuf<40> pritestfile;
       
    84 TBuf<40> restestfile;
       
    85 TBuf<40> systestfile1;
       
    86 TBuf<40> pritestfile1;
       
    87 TBuf<40> restestfile1;
       
    88 
       
    89 TTime testtime;
       
    90 TBuf<20> oldName;
       
    91 
       
    92 TBuf<25> temp;
       
    93 
       
    94 TEntry entry;
       
    95 
       
    96 LOCAL_C void systemRFsTest()
       
    97 //
       
    98 //	RFs test on system Directory
       
    99 //
       
   100 	{
       
   101 	systestname=KSystemPath;
       
   102 	systestname[0]=(TText)('A' + gTheDriveNum);
       
   103 	
       
   104 	mkdirname.Zero();
       
   105 	mkdirname.Append(systestname);
       
   106 	mkdirname.Append(KMkDirSub);
       
   107 	r=TheFs.MkDirAll(mkdirname);	
       
   108 	test(r==KErrNone);
       
   109 
       
   110 	TheFs.RmDir(mkdirname);
       
   111 	test(r==KErrNone);
       
   112 
       
   113 	r=TheFs.SetSubst(systestname,EDriveO);
       
   114 	test(r==KErrNone);
       
   115 	
       
   116 	r=TheFs.RealName(_L("O:\\File.XXX"),realName);
       
   117 	test(r==KErrNone);
       
   118 
       
   119 	r=TheFs.SetSubst(_L(""),EDriveO); //to unsubst
       
   120 	test(r==KErrNone);
       
   121 
       
   122 	r=TheFs.SetSessionPath(systestname);
       
   123 	test(r==KErrNone);
       
   124 	
       
   125 	TheFs.NotifyChange(ENotifyAll,aStat1,systestname);
       
   126 	test(aStat1==KRequestPending);
       
   127 
       
   128 	systestfile=KSystemPath;
       
   129 	systestfile[0]=(TText)('A' + gTheDriveNum);
       
   130 	systestfile1=systestfile;
       
   131 	systestfile.Append(KFileSys);
       
   132 	systestfile1.Append(KFileSys3);
       
   133 	
       
   134 	oldName=KOldFile;
       
   135 	oldName[0]=(TText)gDriveToTest;
       
   136 
       
   137 	r=TheFs.GetShortName(systestfile, shortfilename);
       
   138 	test(r==KErrNotFound || r==KErrNotSupported);
       
   139 
       
   140 	r=TheFs.GetLongName(systestfile1, longfilename);
       
   141 	test(r==KErrNotFound || r==KErrNotSupported);
       
   142 
       
   143 	r=file1.Create(TheFs,oldName,EFileWrite);
       
   144 	test(r==KErrNone || r==KErrAlreadyExists);
       
   145 	file1.Close();
       
   146 
       
   147 	r=TheFs.Replace(oldName,systestfile);
       
   148 	test(r==KErrNone);
       
   149 	
       
   150 	r=TheFs.Rename(systestfile,systestfile1);
       
   151 	test(r==KErrNone);
       
   152 	
       
   153 	r=TheFs.Entry(systestfile1,entry);
       
   154 	test(r==KErrNone);
       
   155 
       
   156 	r=TheFs.SetEntry(systestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
       
   157 	test(r==KErrNone);
       
   158 
       
   159 	r=TheFs.Delete(systestfile1);
       
   160 	test(r==KErrNone);
       
   161 	}
       
   162 
       
   163 LOCAL_C void ResourceRFsTest()
       
   164 //
       
   165 //
       
   166 //
       
   167 	{
       
   168 	restestname=KResourcePath;
       
   169 	restestname[0]=(TText)('A' + gTheDriveNum);
       
   170 	
       
   171 	mkdirname.Zero();
       
   172 	mkdirname.Append(restestname);
       
   173 	mkdirname.Append(KMkDirSub);
       
   174 	r=TheFs.MkDirAll(mkdirname);	
       
   175 	test(r==KErrNone);
       
   176 
       
   177 	TheFs.RmDir(mkdirname);
       
   178 	test(r==KErrNone);
       
   179 
       
   180 	r=TheFs.SetSubst(restestname,EDriveO);
       
   181 	test(r==KErrNone);
       
   182 	
       
   183 	r=TheFs.RealName(_L("O:\\File.XXX"),realName);
       
   184 	test(r==KErrNone);
       
   185 
       
   186 	r=TheFs.SetSubst(_L(""),EDriveO); 
       
   187 	test(r==KErrNone);
       
   188 
       
   189 	r=TheFs.SetSessionPath(restestname);
       
   190 	test(r==KErrNone);
       
   191 	
       
   192 	TheFs.NotifyChange(ENotifyAll,aStat4,restestname);
       
   193 	test(aStat4==KRequestPending);
       
   194 
       
   195 	restestfile=KResourcePath;
       
   196 	restestfile[0]=(TText)('A' + gTheDriveNum);
       
   197 	restestfile1=restestfile;
       
   198 	restestfile.Append(KFileRes);
       
   199 	restestfile1.Append(KFileRes3);
       
   200 	
       
   201 	oldName=KOldFile;
       
   202 	oldName[0]=(TText)gDriveToTest;
       
   203 
       
   204 	r=TheFs.GetShortName(restestfile, shortfilename);
       
   205 	test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
       
   206 
       
   207 	r=TheFs.GetLongName(restestfile1, longfilename);
       
   208 	test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
       
   209 
       
   210 	r=file1.Create(TheFs,oldName,EFileWrite);
       
   211 	test(r==KErrNone || r==KErrAlreadyExists);
       
   212 	file1.Close();
       
   213 
       
   214 	r=TheFs.Replace(oldName,restestfile);
       
   215 	test(r==KErrNone);
       
   216 	
       
   217 	r=TheFs.Rename(restestfile,restestfile1);
       
   218 	test(r==KErrNone);
       
   219 	
       
   220 	r=TheFs.Entry(restestfile1,entry);
       
   221 	test(r==KErrNone);
       
   222 
       
   223 	r=TheFs.SetEntry(restestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
       
   224 	test(r==KErrNone);
       
   225 
       
   226 	r=TheFs.Delete(restestfile1);
       
   227 	test(r==KErrNone);
       
   228 
       
   229 	}
       
   230 
       
   231 
       
   232 LOCAL_C void privatefalseIDRFsTest()
       
   233 //
       
   234 //
       
   235 //
       
   236 	{
       
   237 	//private//FalseID
       
   238 	pritestfalseidname=KPrivateFalseID;
       
   239 	pritestfalseidname[0]=(TText)('A' + gTheDriveNum);
       
   240 	
       
   241 	mkdirname.Zero();
       
   242 	mkdirname.Append(pritestfalseidname);
       
   243 	mkdirname.Append(KMkDirSub);
       
   244 
       
   245 	r=TheFs.MkDirAll(mkdirname);	
       
   246 	test(r==KErrNone);
       
   247 
       
   248 	r=TheFs.RmDir(mkdirname);	
       
   249 	test(r==KErrNone);
       
   250 
       
   251 	r=TheFs.SetSubst(pritestfalseidname,EDriveO);
       
   252 	test(r==KErrNone);
       
   253 
       
   254 	r=TheFs.RealName(_L("O:\\File.XXX"),realName);
       
   255 	test(r==KErrNone);
       
   256 
       
   257 	r=TheFs.SetSubst(_L(""),EDriveO);
       
   258 	test(r==KErrNone);
       
   259 
       
   260 	r=TheFs.SetSessionPath(pritestfalseidname);
       
   261 	test(r==KErrNone);
       
   262 
       
   263 	TheFs.NotifyChange(ENotifyAll,aStat2,pritestfalseidname);
       
   264 	test(aStat2==KRequestPending);
       
   265 
       
   266 
       
   267 	pritestfile=KPrivateFalseID;
       
   268 	pritestfile[0]=(TText)('A' + gTheDriveNum);
       
   269 	pritestfile1=pritestfile;
       
   270 	pritestfile.Append(KFilePri2);
       
   271 	pritestfile1.Append(KFilePri3);
       
   272 	
       
   273 	oldName=KOldFile;
       
   274 	oldName[0]=(TText)gDriveToTest;
       
   275 
       
   276 	r=TheFs.GetShortName(pritestfile, shortfilename);
       
   277 	test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
       
   278 
       
   279 	r=TheFs.GetLongName(pritestfile1, longfilename);
       
   280 	test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
       
   281 
       
   282 	r=file1.Create(TheFs,oldName,EFileWrite);
       
   283 	test(r==KErrNone || r==KErrAlreadyExists);
       
   284 	file1.Close();
       
   285 
       
   286 	r=TheFs.Replace(oldName,pritestfile);
       
   287 	test(r==KErrNone);
       
   288 	
       
   289 	r=TheFs.Rename(pritestfile,pritestfile1);
       
   290 	test(r==KErrNone);
       
   291 	
       
   292 	r=TheFs.Entry(pritestfile1,entry);
       
   293 	test(r==KErrNone);
       
   294 
       
   295 	r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
       
   296 	test(r==KErrNone);
       
   297 
       
   298 	r=TheFs.Delete(pritestfile1);
       
   299 	test(r==KErrNone);
       
   300 
       
   301 	}
       
   302 
       
   303 
       
   304 
       
   305 LOCAL_C void privateRFsTest()
       
   306 //
       
   307 //
       
   308 //
       
   309 	{
       
   310 	//private
       
   311 	pritestname=KPrivatePath;
       
   312 	pritestname[0]=(TText)('A' + gTheDriveNum);
       
   313 	
       
   314 	mkdirname.Zero();
       
   315 	mkdirname.Append(pritestname);
       
   316 	mkdirname.Append(KMkDirSub);
       
   317 
       
   318 	r=TheFs.MkDirAll(mkdirname);	
       
   319 	test(r==KErrNone);
       
   320 
       
   321 	r=TheFs.RmDir(mkdirname);	
       
   322 	test(r==KErrNone);
       
   323 
       
   324 	r=TheFs.SetSubst(pritestname,EDriveO);
       
   325 	test(r==KErrNone);
       
   326 
       
   327 	r=TheFs.RealName(_L("O:\\File.XXX"),realName);
       
   328 	test(r==KErrNone);
       
   329 
       
   330 	r=TheFs.SetSubst(_L(""),EDriveO);
       
   331 	test(r==KErrNone);
       
   332 
       
   333 	r=TheFs.SetSessionPath(pritestname);
       
   334 	test(r==KErrNone);
       
   335 
       
   336 	TheFs.NotifyChange(ENotifyAll,aStat2,pritestname);
       
   337 	test(aStat2==KRequestPending);
       
   338 
       
   339 
       
   340 	pritestfile=KPrivatePath;
       
   341 	pritestfile[0]=(TText)('A' + gTheDriveNum);
       
   342 	pritestfile1=pritestfile;
       
   343 	pritestfile.Append(KFilePri2);
       
   344 	pritestfile1.Append(KFilePri3);
       
   345 	
       
   346 	oldName=KOldFile;
       
   347 	oldName[0]=(TText)gDriveToTest;
       
   348 
       
   349 	r=TheFs.GetShortName(pritestfile, shortfilename);
       
   350 	test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
       
   351 
       
   352 	r=TheFs.GetLongName(pritestfile1, longfilename);
       
   353 	test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
       
   354 
       
   355 	r=file1.Create(TheFs,oldName,EFileWrite);
       
   356 	test(r==KErrNone || r==KErrAlreadyExists);
       
   357 	file1.Close();
       
   358 
       
   359 	r=TheFs.Replace(oldName,pritestfile);
       
   360 	test(r==KErrNone);
       
   361 	
       
   362 	r=TheFs.Rename(pritestfile,pritestfile1);
       
   363 	test(r==KErrNone);
       
   364 	
       
   365 	r=TheFs.Entry(pritestfile1,entry);
       
   366 	test(r==KErrNone);
       
   367 
       
   368 	r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
       
   369 	test(r==KErrNone);
       
   370 
       
   371 	r=TheFs.Delete(pritestfile1);
       
   372 	test(r==KErrNone);
       
   373 
       
   374 	}
       
   375 
       
   376 
       
   377 LOCAL_C void privateSIDRFstest()
       
   378 	{
       
   379 	theprivatepath[0]=(TText)gDriveToTest;	
       
   380 	test.Printf(_L("the Private Path = %S"),&theprivatepath);
       
   381 
       
   382 	mkdirname.Zero();
       
   383 	mkdirname.Append(theprivatepath);
       
   384 	mkdirname.Append(KMkDirSub);
       
   385 	r=TheFs.MkDirAll(mkdirname);	
       
   386 	test(r==KErrNone);
       
   387 
       
   388 	r=TheFs.RmDir(mkdirname);	
       
   389 	test(r==KErrNone);
       
   390 
       
   391 	r=TheFs.SetSubst(theprivatepath,EDriveO);	
       
   392 	test(r==KErrNone);
       
   393 
       
   394 	r=TheFs.RealName(_L("O:\\File.XXX"),realName);
       
   395 	test(r==KErrNone);
       
   396 
       
   397 	r=TheFs.SetSubst(_L(""),EDriveO);	
       
   398 	test(r==KErrNone);
       
   399 
       
   400 	r=TheFs.SetSessionPath(theprivatepath);
       
   401 	test(r==KErrNone);
       
   402 
       
   403 	TheFs.NotifyChange(ENotifyAll,aStat3,theprivatepath);
       
   404 	test(aStat3==KRequestPending);
       
   405 
       
   406 	pritestfile=theprivatepath;
       
   407 	pritestfile[0]=(TText)('A' + gTheDriveNum);
       
   408 	pritestfile1=pritestfile;
       
   409 	pritestfile.Append(KFilePri2);
       
   410 	pritestfile1.Append(KFilePri3);
       
   411 	
       
   412 	oldName=KOldFile;
       
   413 	oldName[0]=(TText)gDriveToTest;
       
   414 
       
   415 	r=TheFs.GetShortName(pritestfile, shortfilename);
       
   416 	test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
       
   417 
       
   418 	r=TheFs.GetLongName(pritestfile1, longfilename);
       
   419 	test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
       
   420 
       
   421 	r=file1.Create(TheFs,oldName,EFileWrite);
       
   422 	test(r==KErrNone || r==KErrAlreadyExists);
       
   423 	file1.Close();
       
   424 
       
   425 	r=TheFs.Replace(oldName,pritestfile);
       
   426 	test(r==KErrNone);
       
   427 	
       
   428 	r=TheFs.Rename(pritestfile,pritestfile1);
       
   429 	test(r==KErrNone || r==KErrAlreadyExists);
       
   430 	
       
   431 	r=TheFs.Entry(pritestfile1,entry);
       
   432 	test(r==KErrNone);
       
   433 
       
   434 	r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
       
   435 	test(r==KErrNone);
       
   436 
       
   437 	r=TheFs.Delete(pritestfile1);
       
   438 	test(r==KErrNone);
       
   439 	}
       
   440 
       
   441 
       
   442 LOCAL_C void systemRFiletest()
       
   443 //
       
   444 //RFile testing with session path set to //system//
       
   445 //
       
   446 	{
       
   447 
       
   448 	r=TheFs.SetSessionPath(systestname);
       
   449 	test(r==KErrNone);
       
   450 
       
   451 	r=file1.Temp(TheFs,systestname,fromTemp,EFileWrite);
       
   452 	test(r==KErrNone);
       
   453 	file1.Close();
       
   454 
       
   455 	r=file1.Create(TheFs,KFileSys,EFileWrite);
       
   456 	test(r==KErrNone);
       
   457 	file1.Close();
       
   458 
       
   459 	r=file1.Open(TheFs,KFileSys,EFileWrite);
       
   460 	test(r==KErrNone);
       
   461 	file1.Close();
       
   462 
       
   463 	r=file1.Open(TheFs,KFileSys,EFileRead);
       
   464 	test(r==KErrNone);
       
   465 	file1.Close();
       
   466 	
       
   467 	r=file1.Replace(TheFs,KFileSys,EFileWrite);
       
   468 	test(r==KErrNone);
       
   469 	
       
   470 	r=file1.Rename(KFileSys3);
       
   471 	test(r==KErrNone);
       
   472 	file1.Close();
       
   473 
       
   474     TFindFile finder(TheFs);
       
   475     CDir* dir = NULL;
       
   476     r=finder.FindWildByDir(KWildFile, KWildPath, dir);
       
   477 	if (!(r==KErrNone))
       
   478         test.Printf(_L("T_DCALLCAPS: test find wildcards r = %d (expected KErrNone)\n"), r);
       
   479 	test(r==KErrNone);
       
   480 	delete dir;
       
   481 	}
       
   482 
       
   483 LOCAL_C void resourceRFiletest()
       
   484 //
       
   485 //RFile testing with session path set to //resource//
       
   486 //
       
   487 	{
       
   488 	r=TheFs.SetSessionPath(restestname);
       
   489 	test(r==KErrNone);
       
   490 
       
   491 	r=file1.Temp(TheFs,restestname,fromTemp,EFileWrite);
       
   492 	test(r==KErrNone);
       
   493 	file1.Close();
       
   494 
       
   495 	r=file1.Create(TheFs,KFileRes,EFileWrite);
       
   496 	test(r==KErrNone);
       
   497 	file1.Close();
       
   498 
       
   499 	r=file1.Open(TheFs,KFileRes,EFileWrite|EFileShareExclusive );
       
   500 	test(r==KErrNone);
       
   501 	
       
   502 	r=file1.Rename(KFileRes3);
       
   503 	test(r==KErrNone);
       
   504 	file1.Close();
       
   505 
       
   506 	r=file1.Open(TheFs,KFileRes3,EFileShareReadersOrWriters|EFileRead);
       
   507 	test(r==KErrNone);
       
   508 	file1.Close();
       
   509 
       
   510 	r=file1.Open(TheFs,KFileRes3,EFileShareReadersOrWriters|EFileWrite);
       
   511 	test(r==KErrNone);
       
   512 	file1.Close();
       
   513 
       
   514 	r=file1.Open(TheFs,KFileRes3,EFileShareReadersOnly);
       
   515 	test(r==KErrNone);
       
   516 
       
   517 	r=file1.ChangeMode(EFileShareExclusive);
       
   518 	test(r==KErrNone);
       
   519 	file1.Close();
       
   520 
       
   521 	r=file1.Replace(TheFs,KFileRes,EFileWrite);
       
   522 	test(r==KErrNone);
       
   523 	file1.Close();	
       
   524 	}
       
   525 
       
   526 
       
   527 LOCAL_C void privatefalseIDRFiletest()
       
   528 //
       
   529 //RFile testing with session path set to //Private//falseID
       
   530 //
       
   531 	{
       
   532 	r=TheFs.SetSessionPath(pritestfalseidname);
       
   533 	test(r==KErrNone);
       
   534 
       
   535 	r=file1.Temp(TheFs,pritestfalseidname,fromTemp,EFileWrite);
       
   536 	test(r==KErrNone);
       
   537 	file1.Close();
       
   538 
       
   539 	r=file1.Create(TheFs,KFilePri,EFileWrite);
       
   540 	test(r==KErrNone);
       
   541 	file1.Close();
       
   542 
       
   543 	r=file1.Open(TheFs,KFilePri,EFileWrite);
       
   544 	test(r==KErrNone);
       
   545 	file1.Close();
       
   546 
       
   547 	r=file1.Open(TheFs,KFilePri,EFileRead);
       
   548 	test(r==KErrNone);
       
   549 	file1.Close();
       
   550 	
       
   551 	r=file1.Replace(TheFs,KFilePri,EFileWrite);
       
   552 	test(r==KErrNone);
       
   553 	
       
   554 	r=file1.Rename(KFilePri3);
       
   555 	test(r==KErrNone);
       
   556 	file1.Close();
       
   557 	}
       
   558 
       
   559 LOCAL_C void privateRFiletest()
       
   560 //
       
   561 //RFile testing with session path set to //Private//falseID
       
   562 //
       
   563 	{
       
   564 	r=TheFs.SetSessionPath(pritestname);
       
   565 	test(r==KErrNone);
       
   566 
       
   567 	r=file1.Temp(TheFs,pritestname,fromTemp,EFileWrite);
       
   568 	test(r==KErrNone);
       
   569 	file1.Close();
       
   570 
       
   571 	r=file1.Create(TheFs,KFilePri,EFileWrite);
       
   572 	test(r==KErrNone);
       
   573 	file1.Close();
       
   574 
       
   575 	r=file1.Open(TheFs,KFilePri,EFileWrite);
       
   576 	test(r==KErrNone);
       
   577 	file1.Close();
       
   578 	
       
   579 	r=file1.Open(TheFs,KFilePri,EFileRead);
       
   580 	test(r==KErrNone);
       
   581 	file1.Close();
       
   582 
       
   583 	r=file1.Replace(TheFs,KFilePri,EFileWrite);
       
   584 	test(r==KErrNone);
       
   585 	
       
   586 	r=file1.Rename(KFilePri3);
       
   587 	test(r==KErrNone);
       
   588 	file1.Close();
       
   589 	}
       
   590 
       
   591 
       
   592 
       
   593 LOCAL_C void privateSIDRFiletest()
       
   594 //
       
   595 //Rfile Testing with session path set to //Private//UID//
       
   596 //
       
   597 	{
       
   598 	r=TheFs.SetSessionToPrivate(gTheDriveNum);
       
   599 	test(r==KErrNone);
       
   600 	
       
   601 	r=file1.Temp(TheFs,theprivatepath,fromTemp,EFileWrite);
       
   602 	test(r==KErrNone);
       
   603 	file1.Close();
       
   604 
       
   605 	r=file1.Create(TheFs,KFilePri,EFileWrite);
       
   606 	test(r==KErrNone);
       
   607 	file1.Close();
       
   608 
       
   609 	r=file1.Open(TheFs,KFilePri,EFileWrite);
       
   610 	test(r==KErrNone);
       
   611 	file1.Close();
       
   612 	
       
   613 	r=file1.Open(TheFs,KFilePri,EFileRead);
       
   614 	test(r==KErrNone);
       
   615 	file1.Close();
       
   616 
       
   617 	r=file1.Replace(TheFs,KFilePri,EFileWrite);
       
   618 	test(r==KErrNone);
       
   619 	
       
   620 	r=file1.Rename(KFilePri3);
       
   621 	test(r==KErrNone);
       
   622 	file1.Close();
       
   623 	}
       
   624 
       
   625 LOCAL_C void RDirtest()
       
   626 //
       
   627 //
       
   628 //
       
   629 	{
       
   630 
       
   631 	//system
       
   632 	CDir*	dirEntries;
       
   633 	TBuf<30> dirNameBuf(KSystemPath);
       
   634 	dirNameBuf[0]=(TText)gDriveToTest;
       
   635 	r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
       
   636 	test(r==KErrNone);
       
   637 	dir.Close();
       
   638 	r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
       
   639 	test(r==KErrNone);
       
   640 	dirNameBuf.Zero();
       
   641 	delete dirEntries;
       
   642 	//Private//falseID
       
   643 	dirNameBuf=KPrivateFalseID;
       
   644 	dirNameBuf[0]=(TText)gDriveToTest;
       
   645 	r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
       
   646 	test(r==KErrNone);
       
   647 	dir.Close();
       
   648 	r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
       
   649 	test(r==KErrNone);
       
   650 	dirNameBuf.Zero();
       
   651 	delete dirEntries;
       
   652 	//Private
       
   653 	dirNameBuf=KPrivatePath;
       
   654 	dirNameBuf[0]=(TText)gDriveToTest;
       
   655 	r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
       
   656 	test(r==KErrNone);
       
   657 	dir.Close();
       
   658 	r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
       
   659 	test(r==KErrNone);
       
   660 	dirNameBuf.Zero();
       
   661 	delete dirEntries;
       
   662 	//Private/uid
       
   663 	TheFs.PrivatePath(dirNameBuf);
       
   664 	dirNameBuf.Insert(0,_L("?:"));
       
   665 	dirNameBuf[0]=(TText)gDriveToTest;
       
   666 	r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
       
   667 	test(r==KErrNone);
       
   668 	dir.Close();
       
   669 	r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
       
   670 	test(r==KErrNone);
       
   671 	dirNameBuf.Zero();
       
   672 	delete dirEntries;
       
   673 	//Resource
       
   674 	dirNameBuf=KResourcePath;
       
   675 	dirNameBuf[0]=(TText)gDriveToTest;
       
   676 	r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
       
   677 	test(r==KErrNone);
       
   678 	r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
       
   679 	test(r==KErrNone);
       
   680 	dir.Close();
       
   681 	delete dirEntries;
       
   682 	}
       
   683 
       
   684 
       
   685 LOCAL_C void TestAllCaps()
       
   686 //
       
   687 //	Test with root capabilities
       
   688 //
       
   689 	{
       
   690 	r=TheFs.FileSystemName(fsname,gTheDriveNum);
       
   691 	test(r==KErrNone || r==KErrNotFound);
       
   692 	r=DismountFileSystem(TheFs, fsname,gTheDriveNum);
       
   693 	test(r==KErrNone || r==KErrNotFound);
       
   694 //	r=TheFs.RemoveFileSystem(fsname);	//can not test due to bug else where fix exists
       
   695 //	test(r==KErrNone);
       
   696 //	r=TheFs.AddFileSystem(fsname);
       
   697 //	test(r==KErrNone);
       
   698 	r=MountFileSystem(TheFs,fsname,gTheDriveNum);
       
   699 	test(r==KErrNone);
       
   700 	r=TheFs.SetDriveName(gTheDriveNum,KDriveName);
       
   701 	test(r==KErrNone);
       
   702 #ifndef __WINS__
       
   703  	r=TheFs.SetVolumeLabel(KVolLable, gTheDriveNum);
       
   704 	test(r==KErrNone);
       
   705 #endif
       
   706 
       
   707 	systemRFsTest();
       
   708 	ResourceRFsTest();
       
   709 	privateRFsTest();	
       
   710 	privateSIDRFstest();
       
   711 	privatefalseIDRFsTest();
       
   712 
       
   713 	systemRFiletest();
       
   714 	resourceRFiletest();
       
   715 	privateRFiletest();
       
   716 	privateSIDRFiletest();
       
   717 	privatefalseIDRFiletest();
       
   718 
       
   719 	//check notifier return values set in rfs testing
       
   720 	User::WaitForRequest(aStat1);
       
   721 	User::WaitForRequest(aStat2);
       
   722 	User::WaitForRequest(aStat3);
       
   723 	User::WaitForRequest(aStat4);
       
   724 	test(aStat1==KErrNone);
       
   725 	test(aStat2==KErrNone);
       
   726 	test(aStat3==KErrNone);
       
   727 	test(aStat4==KErrNone);
       
   728 
       
   729 	r=TheFs.SetSessionPath(systestname);
       
   730 	test(r==KErrNone);
       
   731 	
       
   732 //Test RRawDisk class
       
   733 	r=rawdisk.Open(TheFs,gTheDriveNum);
       
   734 	test(r==KErrNone);
       
   735 	rawdisk.Close();
       
   736 
       
   737 	RDirtest();
       
   738 
       
   739 #ifdef __WINS__
       
   740 	if (User::UpperCase(driveBuf[0]) != 'C')
       
   741 #endif
       
   742 		{
       
   743 		//Test RFormat class
       
   744 		r=format.Open(TheFs,driveBuf,EHighDensity,count);
       
   745 		test(r==KErrNone);
       
   746 
       
   747 		while(count)	
       
   748 			{
       
   749 			TInt r=format.Next(count);
       
   750 			test(r==KErrNone);
       
   751 			}
       
   752 		format.Close();
       
   753 		}
       
   754 
       
   755 	driveBuf[0]=(TText)gDriveToTest;
       
   756 	r=TheFs.ScanDrive(driveBuf);
       
   757 	test(r==KErrNone || r==KErrNotSupported);
       
   758 	r=TheFs.CheckDisk(driveBuf);
       
   759 	test(r==KErrNone || r==KErrNotSupported);
       
   760 	}
       
   761 
       
   762 LOCAL_C void TestCaps()
       
   763 //
       
   764 //	test format etc that require certain capabilities
       
   765 //
       
   766 	{
       
   767 #ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
       
   768 	const char myDiagMsg[] = __PLATSEC_DIAGNOSTIC_STRING("Capability Check Failure");
       
   769 #endif //!__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
       
   770 
       
   771 	r=RProcess().HasCapability(ECapabilityAllFiles, __PLATSEC_DIAGNOSTIC_STRING(myDiagMsg));
       
   772 	test(r);
       
   773 	r=RProcess().HasCapability(ECapabilityTCB, __PLATSEC_DIAGNOSTIC_STRING(myDiagMsg));
       
   774 	test(r);
       
   775 	r=RProcess().HasCapability(ECapabilityDiskAdmin, __PLATSEC_DIAGNOSTIC_STRING(myDiagMsg));
       
   776 	test(r);
       
   777 
       
   778 	driveBuf[0]=(TText)gDriveToTest;
       
   779 	r=TheFs.SessionPath(temp);
       
   780 	test(r==KErrNone);
       
   781 
       
   782 	test.Printf(_L("Session path: %S"),&temp);
       
   783 
       
   784 	r=TheFs.CreatePrivatePath(gTheDriveNum);
       
   785 	test(r==KErrNone || r== KErrAlreadyExists);
       
   786 
       
   787 	TBuf<18> tempPri;
       
   788 	r=TheFs.PrivatePath(tempPri);
       
   789 	test(r==KErrNone);
       
   790 	theprivatepath = _L("?:");
       
   791 	theprivatepath.Append(tempPri);
       
   792 
       
   793 	TestAllCaps();
       
   794 	
       
   795 	TFileName thesessionpath;
       
   796 
       
   797 	r=TheFs.SetSessionToPrivate(gTheDriveNum);
       
   798 	test(r==KErrNone);
       
   799 	r=TheFs.SessionPath(thesessionpath);
       
   800 	test(r==KErrNone);
       
   801 	
       
   802 	test(thesessionpath == theprivatepath);
       
   803 	}
       
   804 
       
   805 LOCAL_C void CleanupL()
       
   806 //
       
   807 // Clean up tests
       
   808 //
       
   809 	{
       
   810 	test.Next(_L("Delete test directory"));
       
   811 	CFileMan* fMan=CFileMan::NewL(TheFs);
       
   812 	TInt r=fMan->RmDir(gSessionPath);
       
   813 	test(r==KErrNone || KErrPathNotFound);
       
   814 	delete fMan;
       
   815 	}
       
   816 
       
   817 GLDEF_C void CallTestsL(/*TChar aDriveLetter*/)
       
   818 //
       
   819 // Do all tests
       
   820 //
       
   821 	{
       
   822 	TurnAllocFailureOff();
       
   823 	TheFs.CharToDrive(gDriveToTest,gTheDriveNum);
       
   824 
       
   825 	TBuf<30> sesspath;
       
   826 	sesspath=_L("?:\\");
       
   827 	sesspath[0] = (TText)gDriveToTest;
       
   828 
       
   829 	TInt r= TheFs.SetSessionPath(sesspath);
       
   830 	test(r==KErrNone);
       
   831 
       
   832 	//cleanup from previous run of this test
       
   833 	TBuf<20> delDir;
       
   834 	CFileMan* fMan=CFileMan::NewL(TheFs);
       
   835 	delDir=KResourcePath;
       
   836 	delDir[0]=(TText)gDriveToTest;
       
   837 	r=fMan->RmDir(delDir);
       
   838 	test(r==KErrNone || KErrNotFound);
       
   839 	delDir=KSystemPath;
       
   840 	delDir[0]=(TText)gDriveToTest;
       
   841 	r=fMan->RmDir(delDir);
       
   842 	test(r==KErrNone || KErrNotFound);
       
   843 	delDir=KPrivatePath;
       
   844 	delDir[0]=(TText)gDriveToTest;
       
   845 	r=fMan->RmDir(delDir);
       
   846 	test(r==KErrNone || KErrNotFound);
       
   847 	delete fMan;
       
   848 
       
   849 	//check double mode ie that Defpath still works	
       
   850 	RFs fs1;
       
   851 	RFs fs2;
       
   852 	
       
   853 	r=fs1.Connect();
       
   854 	test(r==KErrNone);
       
   855 	r=fs1.SessionPath(sesspath);
       
   856 	test(r==KErrNone);
       
   857 	test.Printf(_L("session1 Path=%S"),&sesspath);
       
   858 
       
   859 	TBuf<30> privatepath;
       
   860 	r=fs1.SetSessionToPrivate(gTheDriveNum);
       
   861 	test(r==KErrNone);
       
   862 	r=fs1.PrivatePath(privatepath);
       
   863 	test(r==KErrNone);
       
   864 	r=privatepath.Compare(KExpectedPrivatePath());
       
   865 	test(r==0);
       
   866 	r=fs1.SessionPath(sesspath);
       
   867 	test(r==KErrNone);
       
   868 	r=privatepath.Compare(sesspath.Mid(KPathPosition));
       
   869 	test(r==0);
       
   870 	r=fs1.CreatePrivatePath(gTheDriveNum);
       
   871 	test(r==KErrNone);
       
   872 	fs1.Close();
       
   873 
       
   874 	r=fs2.Connect();
       
   875 	test(r==KErrNone);
       
   876 	r=fs2.SessionPath(sesspath);
       
   877 	test(r==KErrNone);
       
   878 	test.Printf(_L("session2 Path=%S"),&sesspath);
       
   879 	fs2.Close();
       
   880 
       
   881 	TestCaps();
       
   882 
       
   883 	test.Printf(_L("No of files open=%d"), TheFs.ResourceCount());
       
   884 
       
   885 	CleanupL();
       
   886 	}