os/kernelhwsrv/kerneltest/f32test/server/t_nmbs.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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 "t_server.h"
    19 #include "t_chlffs.h"
    20 
    21 GLDEF_D RTest test(_L("T_NMBS"));
    22 
    23 LOCAL_C void testMkDirRmDir()
    24 //
    25 // Test the MkDir functions.
    26 //
    27 	{
    28 
    29 	test.Next(_L("Test MkDir"));
    30 
    31 	TInt r=TheFs.RmDir(_L("\\F32-TST\\TNMBS\\"));
    32 	test(r==KErrNone);
    33 	r=TheFs.MkDir(_L("\\F32-TST\\TNMBS\\TEST\\"));
    34 	test(r==KErrPathNotFound);
    35 	r=TheFs.MkDir(_L("\\F32-TST\\TNMBS\\"));
    36 	test(r==KErrNone);
    37 	r=TheFs.MkDir(_L("\\F32-TST\\TNMBS\\TEST\\"));
    38 	test(r==KErrNone);
    39 
    40 	test.Next(_L("Test RmDir 1.0"));
    41 	r=TheFs.RmDir(_L("\\F32-TST\\TNMBS\\TEST\\"));
    42 	test(r==KErrNone);
    43 	r=TheFs.RmDir(_L("\\F32-TST\\TNMBS\\"));
    44 	test(r==KErrNone);
    45 
    46 	test.Next(_L("Test MkDirAll 1.0"));
    47 	r=TheFs.MkDirAll(_L("\\F32-TST\\TNMBS\\TEST\\"));
    48 	test(r==KErrNone);
    49 
    50 	test.Next(_L("Test RmDir 2.0"));
    51 	r=TheFs.RmDir(_L("\\F32-TST\\TNMBS\\TEST\\"));
    52 	test(r==KErrNone);
    53 	r=TheFs.RmDir(_L("\\F32-TST\\TNMBS\\"));
    54 	test(r==KErrNone);
    55 
    56 	test.Next(_L("Test MkDirAll 2.0"));
    57 	r=TheFs.MkDirAll(_L("\\F32-TST\\TNMBS\\"));
    58 	test(r==KErrNone);
    59 	r=TheFs.MkDirAll(_L("\\F32-TST\\TNMBS\\TEST\\"));
    60 	test(r==KErrNone);
    61 
    62 	test.Next(_L("Test RmDir 3.0"));
    63 	r=TheFs.RmDir(_L("\\F32-TST\\TNMBS\\TEST\\"));
    64 	test(r==KErrNone);
    65 	r=TheFs.RmDir(_L("\\F32-TST\\TNMBS\\"));
    66 	test(r==KErrNone);
    67 
    68 	test.Next(_L("Test mkdir and rmdir on root"));
    69 	r=TheFs.RmDir(_L("\\File.TXT"));
    70 	test(r==KErrInUse);
    71 	r=TheFs.MkDir(_L("\\asdf.ere"));
    72 	test(r==KErrAlreadyExists);
    73 	r=TheFs.MkDirAll(_L("\\asdf.ere"));
    74 	test(r==KErrAlreadyExists);
    75 
    76 	test.Next(_L("Test error code return values"));
    77 	r=TheFs.MkDir(_L("\\F32-TST\\\\ABCDEF\\"));
    78 
    79 	test(r==KErrBadName);
    80 
    81 	test.Next(_L("Test MkDir with trailing spaces"));
    82 	r=TheFs.MkDir(_L("\\F32-TST\\TESTMKDIR    \\"));
    83 	test(r==KErrNone);
    84 	r=TheFs.RmDir(_L("\\F32-TST\\TESTMKDIR\\"));
    85 	test(r==KErrNone);
    86 	r=TheFs.MkDirAll(_L("\\F32-TST\\TESTMKDIR    \\NOTCREATED\\NORTHIS   \\"));
    87 	test(r==KErrPathNotFound);
    88 	r=TheFs.RmDir(_L("\\F32-TST\\TESTMKDIR\\NOTCREATED\\"));
    89 	test(r==KErrNotFound);
    90 	r=TheFs.RmDir(_L("\\F32-TST\\TESTMKDIR\\"));
    91 	test(r==KErrNone);
    92 
    93 	r=TheFs.MkDirAll(_L("\\F32-TST\\TNMBS\\"));
    94 	test(r==KErrNone);
    95 	}
    96 
    97 LOCAL_C void testRename()
    98 //
    99 // Test the rename function.
   100 //
   101 	{
   102 
   103 	test.Next(_L("Test rename directories"));
   104 	TInt r=TheFs.MkDirAll(_L("\\F32-TST\\ABCDEF\\GPQ\\"));
   105 	test(r==KErrNone || r==KErrAlreadyExists);
   106 	r=TheFs.Rename(_L("\\F32-TST\\ABCDEF\\"),_L("\\F32-TST\\ABCDEF\\LMED"));
   107 	test(r==KErrInUse);
   108 	r=TheFs.Rename(_L("\\F32-TST\\ABCDEF\\GPQ"),_L("\\F32-TST\\LMED"));
   109 	test(r==KErrNone);
   110 	r=TheFs.RmDir(_L("\\F32-TST\\LMED\\"));
   111 	test(r==KErrNone);
   112 
   113 	MakeDir(_L("\\F32-TST\\ABC\\"));
   114 	MakeFile(_L("\\F32-TST\\ABCDEF\\GPQ\\asdf.txt"));
   115 	MakeFile(_L("\\F32-TST\\asdf.txt"));
   116 	
   117 	test.Next(_L("Test rename directory while subfile is open"));
   118 	RFile f;
   119 	r=f.Open(TheFs,_L("\\F32-TST\\ABCDEF\\GPQ\\asdf.txt"),EFileRead);
   120 	test(r==KErrNone);
   121 	r=TheFs.Rename(_L("\\F32-TST\\ABCDEF"),_L("\\F32-TST\\xxxyyy"));
   122 	test(r==KErrInUse);
   123 	r=TheFs.Rename(_L("\\F32-TST\\ABCDEF"),_L("\\F32-TST\\xxxyyy"));
   124 	test(r==KErrInUse);
   125 	r=TheFs.Rename(_L("\\F32-TST\\ABC"),_L("\\F32-TST\\XXX"));
   126 	test(r==KErrNone);
   127 	f.Close();
   128 	r=TheFs.Rename(_L("\\F32-TST\\ABCDEF"),_L("\\F32-TST\\xxxyyy"));
   129 	test(r==KErrNone);
   130 	r=TheFs.Rename(_L("\\F32-TST\\XXX"),_L("\\F32-TST\\ABC"));
   131 	test(r==KErrNone);
   132 	r=TheFs.Rename(_L("\\"),_L("\\BLARG"));
   133 	test(r==KErrBadName);
   134 
   135 	r=f.Open(TheFs,_L("\\F32-TST\\asdf.txt"),EFileRead);
   136 	test(r==KErrNone);
   137 	r=TheFs.Rename(_L("\\F32-TST\\xxxyyy"),_L("\\F32-TST\\ABCDEF"));
   138 	test(r==KErrNone);
   139 	r=TheFs.Rename(_L("\\F32-TST\\"),_L("\\ABCDEF"));
   140 	test(r==KErrInUse);
   141 	f.Close();
   142 
   143 	r=TheFs.Delete(_L("\\F32-TST\\ABCDEF\\GPQ\\asdf.txt"));
   144 	test(r==KErrNone);
   145 	r=TheFs.Delete(_L("\\F32-TST\\asdf.txt"));
   146 	test(r==KErrNone);
   147 	r=TheFs.RmDir(_L("\\F32-TST\\ABCDEF\\GPQ\\"));
   148 	test(r==KErrNone);
   149 	r=TheFs.RmDir(_L("\\F32-TST\\ABC\\"));
   150 	test(r==KErrNone);
   151 
   152 	r=TheFs.Rename(_L("\\TST-E32\\123456"),_L("\\F32-TST\\ABCDEF"));
   153 	test(r==KErrPathNotFound);
   154 	r=TheFs.Rename(_L("\\F32-TST\\123456"),_L("\\F32-TST\\ABCDEF"));
   155 	test(r==KErrNotFound);
   156 	r=TheFs.Rename(_L("\\TST-E32\\123456"),_L("\\F32-TST\\FEDCBA"));
   157 	test(r==KErrPathNotFound);
   158 	r=TheFs.Rename(_L("\\F32-TST\\FEDCBA"),_L("\\TST-E32\\123456"));
   159 	test(r==KErrNotFound);
   160 	r=TheFs.Rename(_L("\\F32-TST\\ABCDEF"),_L("\\F32-TST\\123456"));
   161 	test(r==KErrNone);
   162 	r=TheFs.Rename(_L("\\F32-TST\\123456"),_L("\\F32-TST\\XYZABC"));
   163 	test(r==KErrNone);
   164 
   165 	test.Next(_L("Test rename files"));
   166 	r=f.Create(TheFs,_L("\\F32-TST\\XYZABC\\OLDNAME.TXT"),EFileRead|EFileWrite);
   167 	test(r==KErrNone);
   168 	f.Close();
   169 	r=TheFs.Rename(_L("\\F32-TST\\XYZABC\\OLDNAME.TXT"),_L("\\F32-TST\\XYZABC\\NEWNAME.TXT"));
   170 	test(r==KErrNone);
   171 	r=TheFs.Delete(_L("\\F32-TST\\XYZABC\\NEWNAME.TXT"));
   172 	test(r==KErrNone);
   173 
   174 	test.Next(_L("Test rename checks for duplicate entries"));
   175 	r=TheFs.MkDirAll(_L("\\F32-TST\\ABCDEF\\"));
   176 	test(r==KErrNone);
   177 	r=TheFs.Rename(_L("\\F32-TST\\ABCDEF"),_L("\\F32-TST\\XYZABC"));
   178 	test(r==KErrAlreadyExists);
   179 	r=f.Create(TheFs,_L("\\F32-TST\\XYZABC\\OLDNAME.TXT"),EFileRead|EFileWrite);
   180 	test(r==KErrNone);
   181 	f.Close();
   182 	r=f.Create(TheFs,_L("\\F32-TST\\XYZABC\\NEWNAME.TXT"),EFileRead|EFileWrite);
   183 	test(r==KErrNone);
   184 	f.Close();
   185 	r=TheFs.Rename(_L("\\F32-TST\\XYZABC\\OLDNAME.TXT"),_L("\\F32-TST\\XYZABC\\NEWNAME.TXT"));
   186 	test(r==KErrAlreadyExists);
   187 
   188 	test.Next(_L("Test rename across directories"));
   189 	r=TheFs.Rename(_L("\\F32-TST\\XYZABC\\NEWNAME.TXT"),_L("\\F32-TST\\ABCDEF\\OLDNAME.TXT"));
   190 	test(r==KErrNone);
   191 	r=TheFs.Rename(_L("\\F32-TST\\XYZABC\\NEWNAME.TXT"),_L("\\F32-TST\\ABCDEF\\OLDNAME.TXT"));
   192 	test(r==KErrNotFound);
   193 	r=TheFs.Rename(_L("\\F32-TST\\XYZABC\\NEWNAME.TXT"),_L("\\F32-TST\\ABCDEF\\DIFNAME.TXT"));
   194 	test(r==KErrNotFound);
   195 	r=TheFs.Rename(_L("\\F32-TST\\XYZABC"),_L("\\F32-TST\\ABCDEF\\XYZABC"));
   196 	test(r==KErrNone);
   197 	r=TheFs.Rename(_L("\\F32-TST\\ABCDEF\\XYZABC\\OLDNAME.TXT"),_L("\\F32-TST\\ABCDEF\\NEWNAME.TXT"));
   198 	test(r==KErrNone);
   199 	r=TheFs.Rename(_L("\\F32-TST\\ABCDEF\\NewNAME.TXT"),_L("\\F32-TST\\ABCDEF\\XYZABC\\OLDNAME.TXT"));
   200 	test(r==KErrNone);
   201 	test.Next(_L("Test rename across drive error code"));
   202 	r=TheFs.Rename(_L("Z:\\BLEG"),_L("C:\\FRUM"));
   203 	test(r==KErrArgument);	
   204 	test.Next(_L("Test rename to identical names"));
   205 	r=TheFs.Rename(_L("\\F32-TST\\ABCDEF\\XYZABC\\OLDNAME.TXT"),_L("\\F32-TST\\ABCDEF\\XYZABC\\OLDNAME.TXT"));
   206 	test(r==KErrNone);
   207 	CheckFileExists(_L("\\F32-TST\\ABCDEF\\XYZABC\\OLDNAME.TXT"),KErrNone);
   208 	r=TheFs.Rename(_L("\\F32-TST\\ABCDEF\\XYZABC\\OLDNAME.TXT"),_L("\\F32-TST\\ABCDEF\\XYZABC\\OLdnAME.TXT"));
   209 	test(r==KErrNone);
   210 	CheckFileExists(_L("\\F32-TST\\ABCDEF\\XYZABC\\OLDNAME.TXT"),KErrNone,EFalse);
   211 	CheckFileExists(_L("\\F32-TST\\ABCDEF\\XYZABC\\OLdnAME.TXT"),KErrNone,ETrue);
   212 
   213 	r=TheFs.Rename(_L("\\F32-TST\\ABCDEF\\XYZABC\\OLDNAME.TXT"),_L("\\F32-TST\\ABCDEF\\NEWNAME.TXT"));
   214 	test(r==KErrNone);
   215 	test.Next(_L("Test RmDir"));
   216 	r=TheFs.Delete(_L("\\F32-TST\\ABCDEF\\NEWNAME.TXT"));
   217 	test(r==KErrNone);
   218 	r=TheFs.Delete(_L("\\F32-TST\\ABCDEF\\OLDNAME.TXT"));
   219 	test(r==KErrNone);
   220 	r=TheFs.RmDir(_L("\\F32-TST\\ABCDEF\\XYZABC\\"));
   221 	test(r==KErrNone);
   222 	r=TheFs.RmDir(_L("\\F32-TST\\ABCDEF\\"));
   223 	test(r==KErrNone);
   224 	}
   225 LOCAL_C void TestLongFileName()
   226 	{
   227 	#ifndef __EPOC32__ //emulator
   228 	if (gDriveToTest.GetLowerCase()=='c')
   229 		return;//don't perform this test for c: in emulator as emulator uses windows system calls
   230 		//windows doesn't create a directory with length more than 244 characters
   231 	#endif 
   232 	
   233 	 test.Next(_L("Test renaming 257 characters directories"));
   234 	_LIT(KLongFileName256, "256dir_IncludingBackslash_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
   235 	_LIT(KLongFileName257, "257dir_IncludingBackslash_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
   236 	TBuf<260> Path;
   237 	TBuf<10> baseDir;
   238 			
   239 	baseDir.Format(_L("%c:\\"),(TUint)(gDriveToTest));
   240 	Path.Copy(baseDir);
   241 	Path.Append(KLongFileName256);
   242 	Path.Append(_L("\\"));
   243 	
   244 	TInt 	result = KErrNone;
   245 	//-- 1. create directory in Root which total path length is 256 symbols.	result = TheFs.MkDirAll(Path);
   246 	result=TheFs.MkDirAll(Path);
   247 	test((result==KErrNone)||(result==KErrAlreadyExists));
   248 	
   249 	test.Next(_L("Renaming a 265 char directory to a 257 char directory"));
   250 	result=TheFs.SetSessionPath(baseDir);
   251 	test(result==KErrNone);	
   252 	TheFs.SessionPath(baseDir);
   253 	test.Printf(_L("Session path was set to: %S"), &baseDir);
   254 
   255 	//-- 2. try to rename this directory to one with 257 character total path length
   256 	test.Printf(_L("Renaming 256-char directory to 257"));
   257 	result = KErrNone;
   258 	Path.Copy(KLongFileName257);
   259 	result = TheFs.Rename(KLongFileName256, Path);
   260 	test(result==KErrBadName);
   261 	//-- 3. try to rename this directory to one with 258 character total path length
   262 
   263 	Path.Append(_L("z"));
   264 	result = TheFs.Rename(KLongFileName256, Path);
   265 	test(result==KErrBadName);
   266 
   267 	}
   268 LOCAL_C void testRenameCase()
   269 //
   270 // Test renaming "AGENDA" to "agenda"
   271 //
   272 	{
   273 
   274 	test.Next(_L("Test rename case"));
   275 	MakeDir(_L("\\F32-TST\\RENAMECASE\\"));
   276 	TInt r=TheFs.SetSessionPath(_L("\\F32-TST\\RENAMECASE\\"));
   277 	test(r==KErrNone);
   278 
   279 	MakeFile(_L("file1.txt"));
   280 	MakeFile(_L("FILE2.TXT"));
   281 	MakeFile(_L("AGENDA"));
   282 	MakeFile(_L("agenda.one"));
   283 
   284 	TEntry entry;
   285 	r=TheFs.Rename(_L("FILE1.TXT"),_L("FILE1.TXT"));
   286 	test(r==KErrNone);
   287 	r=TheFs.Entry(_L("File1.txt"),entry);
   288 	test(r==KErrNone);
   289 	test(entry.iName==_L("FILE1.TXT"));
   290 
   291 	r=TheFs.Rename(_L("file2.txt"),_L("file2.txt"));
   292 	test(r==KErrNone);
   293 	r=TheFs.Entry(_L("File2.txt"),entry);
   294 	test(r==KErrNone);
   295 	test(entry.iName==_L("file2.txt"));
   296 
   297 	r=TheFs.Rename(_L("agenda."),_L("agenda.two"));
   298 	test(r==KErrNone);
   299 	r=TheFs.Entry(_L("Agenda.two"),entry);
   300 	test(r==KErrNone);
   301 	test(entry.iName==_L("agenda.two"));
   302 
   303 	r=TheFs.Rename(_L("AGENDA.ONE"),_L("AGENDA.ONE"));
   304 	test(r==KErrNone);
   305 	r=TheFs.Entry(_L("Agenda.one"),entry);
   306 	test(r==KErrNone);
   307 	test(entry.iName==_L("AGENDA.ONE"));
   308 
   309 	r=TheFs.Rename(_L("FILE1.TXT"),_L("file1.txt"));
   310 	test(r==KErrNone);
   311 	r=TheFs.Entry(_L("File1.txt"),entry);
   312 	test(r==KErrNone);
   313 	test(entry.iName==_L("file1.txt"));
   314 
   315 	r=TheFs.Rename(_L("file2.txt"),_L("FILE2.TXT"));
   316 	test(r==KErrNone);
   317 	r=TheFs.Entry(_L("File2.txt"),entry);
   318 	test(r==KErrNone);
   319 	test(entry.iName==_L("FILE2.TXT"));
   320 
   321 	r=TheFs.Rename(_L("agenda.two"),_L("AGENDA"));
   322 	test(r==KErrNone);
   323 	r=TheFs.Entry(_L("Agenda"),entry);
   324 	test(r==KErrNone);
   325 	test(entry.iName==_L("AGENDA"));
   326 
   327 	r=TheFs.Rename(_L("AGENDA.ONE"),_L("agenda.one"));
   328 	test(r==KErrNone);
   329 	r=TheFs.Entry(_L("Agenda.one"),entry);
   330 	test(r==KErrNone);
   331 	test(entry.iName==_L("agenda.one"));
   332 
   333 	r=TheFs.Rename(_L("FILE1.TXT"),_L("FILe1.txt"));
   334 	test(r==KErrNone);
   335 	r=TheFs.Entry(_L("File1.txt"),entry);
   336 	test(r==KErrNone);
   337 	test(entry.iName==_L("FILe1.txt"));
   338 
   339 	r=TheFs.Rename(_L("file2.txt"),_L("FILE3.TXT"));
   340 	test(r==KErrNone);
   341 	r=TheFs.Entry(_L("File3.txt"),entry);
   342 	test(r==KErrNone);
   343 	test(entry.iName==_L("FILE3.TXT"));
   344 
   345 	r=TheFs.Rename(_L("agenda."),_L("AGENDA1"));
   346 	test(r==KErrNone);
   347 	r=TheFs.Entry(_L("Agenda1"),entry);
   348 	test(r==KErrNone);
   349 	test(entry.iName==_L("AGENDA1"));
   350 
   351 	r=TheFs.Rename(_L("AGENDA.ONE"),_L("Agenda.One"));
   352 	test(r==KErrNone);
   353 	r=TheFs.Entry(_L("Agenda.one"),entry);
   354 	test(r==KErrNone);
   355 	test(entry.iName==_L("Agenda.One"));
   356 
   357 	r=TheFs.Delete(_L("file1.txt"));
   358 	test(r==KErrNone);
   359 	r=TheFs.Delete(_L("file3.txt"));
   360 	test(r==KErrNone);
   361 	r=TheFs.Delete(_L("Agenda1"));
   362 	test(r==KErrNone);
   363 	r=TheFs.Delete(_L("AGENDA.ONE"));
   364 	test(r==KErrNone);
   365 	r=TheFs.RmDir(_L("\\F32-TST\\RENAMECASE\\"));
   366 	test(r==KErrNone);
   367 	r=TheFs.SetSessionPath(gSessionPath);
   368 	test(r==KErrNone);
   369 	}
   370 
   371 LOCAL_C void testReplace()
   372 //
   373 // Test the replace function
   374 //
   375 	{
   376 
   377 	test.Next(_L("Test Replace"));
   378 	TInt r=TheFs.MkDirAll(_L("\\F32-TST\\ABCDEF\\"));
   379 	test(r==KErrNone);
   380 	r=TheFs.Replace(_L("\\TST-E32\\123456"),_L("\\F32-TST\\ABCDEF"));
   381 	test(r==KErrAccessDenied); // Do not replace directories
   382 	r=TheFs.Replace(_L("\\F32-TST\\123456"),_L("\\F32-TST\\ABCDEF"));
   383 	test(r==KErrAccessDenied);
   384 	r=TheFs.Replace(_L("\\TST-E32\\123456"),_L("\\F32-TST\\FEDCBA"));
   385 	test(r==KErrPathNotFound);
   386 	r=TheFs.Replace(_L("\\F32-TST\\ABCDEF"),_L("\\F32-TST\\123456"));
   387 	test(r==KErrAccessDenied);
   388 
   389 	test.Next(_L("Replace a file with itself (8.3 filename)"));
   390 	MakeFile(_L("\\F32-TST\\ABCDEF\\TEST1.SPR"));
   391 	r=TheFs.Replace(_L("\\F32-TST\\ABCDEF\\TEST1.SPR"),_L("\\F32-TST\\ABCDEF\\TEST1.SPR"));
   392 	test(r==KErrNone);
   393 	CheckFileExists(_L("\\F32-TST\\ABCDEF\\TEST1.SPR"),KErrNone);
   394 	r=TheFs.Replace(_L("\\F32-TST\\ABCDEF\\TEST1.SPR"),_L("\\F32-TST\\ABCDEF\\test1.spr"));
   395 	test(r==KErrNone);
   396 	CheckFileExists(_L("\\F32-TST\\ABCDEF\\TEST1.SPR"),KErrNone,ETrue); // Replace does not rename existing file
   397 	CheckFileExists(_L("\\F32-TST\\ABCDEF\\test1.spr"),KErrNone,EFalse);
   398 
   399 	test.Next(_L("Replace a file with itself (vfat filename)"));
   400 	MakeFile(_L("\\F32-TST\\ABCDEF\\TEST_SHEET(01).SPR"));
   401 	r=TheFs.Replace(_L("\\F32-TST\\ABCDEF\\TEST_SHEET(01).SPR"),_L("\\F32-TST\\ABCDEF\\TEST_SHEET(01).SPR"));
   402 	test(r==KErrNone);
   403 	CheckFileExists(_L("\\F32-TST\\ABCDEF\\TEST_SHEET(01).SPR"),KErrNone);
   404 	r=TheFs.Replace(_L("\\F32-TST\\ABCDEF\\TEST_SHEET(01).SPR"),_L("\\F32-TST\\ABCDEF\\test_sheet(01).spr"));
   405 	test(r==KErrNone);
   406 	CheckFileExists(_L("\\F32-TST\\ABCDEF\\TEST_SHEET(01).SPR"),KErrNone,ETrue); // Replace does not rename existing file
   407 	CheckFileExists(_L("\\F32-TST\\ABCDEF\\test_sheet(01).spr"),KErrNone,EFalse);
   408 
   409 	test.Next(_L("Replace preserves file contents (8.3 filename)"));
   410 	MakeFile(_L("\\F32-TST\\ABCDEF\\SHEET1.SPR"),_L8("Original Data"));
   411 	MakeFile(_L("\\F32-TST\\ABCDEF\\TEMP0001.SPR"),_L8("NewData"));
   412 	r=TheFs.Replace(_L("\\F32-TST\\ABCDEF\\TEMP0001.SPR"),_L("\\F32-TST\\ABCDEF\\SHEET1.SPR"));
   413 	test(r==KErrNone);
   414 	CheckFileContents(_L("\\F32-TST\\ABCDEF\\SHEET1.SPR"),_L8("NewData"));
   415 	CheckFileExists(_L("\\F32-TST\\ABCDEF\\TEMP0001.SPR"),KErrNotFound);
   416 
   417 	r=TheFs.Rename(_L("\\F32-TST\\ABCDEF\\SHEET1.SPR"),_L("\\F32-TST\\ABCDEF\\TEMP0001.SPR"));
   418 	test(r==KErrNone);
   419     r=TheFs.Replace(_L("\\F32-TST\\ABCDEF\\TEMP0001.SPR"),_L("\\F32-TST\\ABCDEF\\SHEET1.SPR"));
   420 	test(r==KErrNone);
   421 	CheckFileContents(_L("\\F32-TST\\ABCDEF\\SHEET1.SPR"),_L8("NewData"));
   422 	CheckFileExists(_L("\\F32-TST\\ABCDEF\\TEMP0001.SPR"),KErrNotFound);
   423 
   424 	test.Next(_L("Replace preserves file contents (vfat fileName)"));
   425 	MakeFile(_L("\\F32-TST\\ABCDEF\\SHEET_TEST1.SPR"),_L8("Original Data"));
   426 	MakeFile(_L("\\F32-TST\\ABCDEF\\NEW_TEMP0001.SPR"),_L8("NewData"));
   427 	r=TheFs.Replace(_L("\\F32-TST\\ABCDEF\\NEW_TEMP0001.SPR"),_L("\\F32-TST\\ABCDEF\\SHEET_TEST1.SPR"));
   428 	test(r==KErrNone);
   429 	CheckFileContents(_L("\\F32-TST\\ABCDEF\\SHEET_TEST1.SPR"),_L8("NewData"));
   430 	CheckFileExists(_L("\\F32-TST\\ABCDEF\\NEW_TEMP0001.SPR"),KErrNotFound);
   431 
   432 	r=TheFs.Rename(_L("\\F32-TST\\ABCDEF\\SHEET_TEST1.SPR"),_L("\\F32-TST\\ABCDEF\\NEW_TEMP0001.SPR"));
   433 	test(r==KErrNone);
   434     r=TheFs.Replace(_L("\\F32-TST\\ABCDEF\\NEW_TEMP0001.SPR"),_L("\\F32-TST\\ABCDEF\\SHEET_TEST1.SPR"));
   435 	test(r==KErrNone);
   436 	CheckFileContents(_L("\\F32-TST\\ABCDEF\\SHEET_TEST1.SPR"),_L8("NewData"));
   437 	CheckFileExists(_L("\\F32-TST\\ABCDEF\\NEW_TEMP0001.SPR"),KErrNotFound);
   438 
   439 	r=TheFs.RmDir(_L("\\F32-TST\\ABCDEF\\"));
   440 	test(r==KErrInUse);
   441 	r=TheFs.RmDir(_L("\\F32-TST\\ABCDEF\\SHEET1.SPR\\"));
   442 	test(r==KErrPathNotFound);
   443 	r=TheFs.Delete(_L("\\F32-TST\\ABCDEF\\SHEET1.SPR"));
   444 	test(r==KErrNone);
   445 	r=TheFs.Delete(_L("\\F32-TST\\ABCDEF\\SHEET_TEST1.SPR"));
   446 	test(r==KErrNone);
   447 	r=TheFs.Delete(_L("\\F32-TST\\ABCDEF\\TEST1.SPR"));
   448 	test(r==KErrNone);
   449 	r=TheFs.Delete(_L("\\F32-TST\\ABCDEF\\TEST_SHEET(01).SPR"));
   450 	test(r==KErrNone);
   451 	r=TheFs.RmDir(_L("\\F32-TST\\ABCDEF\\"));
   452 	test(r==KErrNone);
   453 
   454 	test.Next(_L("Check file date is retained"));
   455 	MakeFile(_L("OldFile.Old"));
   456 	MakeFile(_L("NewFile.new"));
   457 
   458 	TDateTime newDate(1998,(TMonth)2,3,11,12,0,0);
   459 	TTime newTime(newDate);
   460 	
   461 	r=TheFs.SetEntry(_L("NewFile.new"),newTime,0,0);
   462 	test(r==KErrNone);
   463 	
   464 	TEntry entry;
   465 	r=TheFs.Entry(_L("NewFile.new"),entry);
   466 	test(r==KErrNone);
   467 	
   468 	TTime checkReturnedTime=entry.iModified;
   469 	TDateTime dateTime=checkReturnedTime.DateTime();
   470 	
   471 	test(entry.iModified==newTime);
   472 
   473 	TDateTime oldDate(1996,(TMonth)2,3,23,0,0,0);
   474 	TTime oldTime(oldDate);
   475 	r=TheFs.SetEntry(_L("OldFile.old"),oldTime,0,0);
   476 	test(r==KErrNone);
   477 
   478 	TheFs.Replace(_L("NewFile.new"),_L("OldFile.old"));
   479 	test(r==KErrNone);
   480 	TTime check;
   481 	r=TheFs.Modified(_L("OldFile.old"),check);
   482 	test(r==KErrNone);
   483 	TDateTime checkDateTime=check.DateTime();
   484 	
   485 	test(checkDateTime.Year()==dateTime.Year());
   486 	test(checkDateTime.Month()==dateTime.Month());
   487 	test(checkDateTime.Day()==dateTime.Day());
   488 	test(checkDateTime.Hour()==dateTime.Hour());
   489 	test(checkDateTime.Minute()==dateTime.Minute());
   490 	test(checkDateTime.Second()==dateTime.Second());
   491 
   492 	test.Next(_L("Replace 'Agenda' with 'Agenda.'"));
   493 	MakeFile(_L("Agenda"));
   494 	r=TheFs.Replace(_L("Agenda"),_L("Agenda."));
   495 	test(r==KErrNone);
   496 	CheckFileExists(_L("Agenda"),KErrNone,ETrue);
   497 	CheckFileExists(_L("Agenda."),KErrNone,ETrue);
   498 	CheckFileExists(_L("AGENDA"),KErrNone,EFalse);
   499 	CheckFileExists(_L("AGENDA."),KErrNone,EFalse);
   500 
   501 	r=TheFs.Replace(_L("Agenda"),_L("Agenda."));
   502 	test(r==KErrNone);
   503 	CheckFileExists(_L("Agenda"),KErrNone,ETrue);
   504 	CheckFileExists(_L("Agenda."),KErrNone,ETrue);
   505 	CheckFileExists(_L("AGENDA"),KErrNone,EFalse);
   506 	CheckFileExists(_L("AGENDA."),KErrNone,EFalse);
   507 
   508 	r=TheFs.Replace(_L("Agenda."),_L("AGENDA"));
   509 	test(r==KErrNone);
   510 	CheckFileExists(_L("Agenda"),KErrNone,ETrue);  // Replace does not rename existing file
   511 	CheckFileExists(_L("Agenda."),KErrNone,ETrue);
   512 	CheckFileExists(_L("AGENDA"),KErrNone,EFalse);
   513 	CheckFileExists(_L("AGENDA."),KErrNone,EFalse);
   514 
   515 	r=TheFs.Replace(_L("AGENDA."),_L("AGENDA.")); // Unchanged, ie still 'Agenda'
   516 	test(r==KErrNone);
   517 	CheckFileExists(_L("Agenda"),KErrNone,ETrue);
   518 	CheckFileExists(_L("Agenda."),KErrNone,ETrue);
   519 	CheckFileExists(_L("AGENDA"),KErrNone,EFalse);
   520 	CheckFileExists(_L("AGENDA."),KErrNone,EFalse);
   521 	}
   522 
   523 LOCAL_C void testEntry()
   524 //
   525 // Test RFs::Entry(..) function
   526 //
   527 	{
   528 
   529 	test.Next(_L("Get directory entry"));
   530 	TEntry entry;
   531 	TInt r=TheFs.Entry(_L("\\BLEERRG\\"),entry);
   532 	test(r==KErrNotFound); // BLEERRG does not exist
   533 	r=TheFs.Entry(_L("\\F32-TST"),entry);
   534 	test(r==KErrNone);
   535 	test(entry.iName==_L("F32-TST")||entry.iName==_L("F32-TST."));
   536 	if (IsTestingLFFS())
   537 		{
   538 		r=TheFs.Rename(_L("\\F32-TST.\\"),_L("\\F32-TST\\"));
   539 		test(r==KErrBadName);
   540 		r=TheFs.Entry(_L("\\F32-TST"),entry);
   541 		test(r==KErrNone);
   542 		}
   543 	test(entry.iName==_L("F32-TST"));
   544 	test(entry.IsDir());
   545 
   546 	test.Next(_L("Get file entry"));
   547 	RFile f;
   548 	r=f.Replace(TheFs,_L("ENTRY.TXT"),EFileStream);
   549 	test(r==KErrNone);
   550 	r=f.Write(_L8("Entry data"));
   551 	test(r==KErrNone);
   552 	f.Close();
   553 	r=TheFs.Entry(_L("\\F32-TST\\TNMBS\\ENTRY.TXT"),entry);
   554 	test(r==KErrNone);
   555 	test(entry.iName==_L("ENTRY.TXT"));
   556 	test(!entry.IsDir());
   557 
   558 	test.Next(_L("Get the root directory"));
   559 	r=TheFs.Entry(_L("\\"),entry);
   560 	test(r==KErrBadName);
   561 	}
   562 
   563 LOCAL_C void testRenameRegression()
   564 //
   565 // Regression tests for rename
   566 //
   567 	{
   568 
   569 	test.Next(_L("More rename tests"));
   570 	MakeFile(_L("\\F32-TST\\asdf"));
   571 	TInt r=TheFs.Rename(_L("\\F32-TST\\asdf"),_L("*"));
   572 	test(r==KErrBadName);
   573 	r=TheFs.Rename(_L("\\F32-TST\\"),_L("*"));
   574 	test(r==KErrBadName);
   575 	r=TheFs.Rename(_L("\\F32-TST\\"),_L("\\F32-TST.\\"));
   576 	test(r==KErrBadName);
   577 	CheckFileExists(_L("\\F32-TST\\asdf"),KErrNone);
   578 	r=TheFs.Rename(_L("\\F32-TST\\asdf"),_L("\\F32-TST\\Asdf."));
   579 	test(r==KErrNone);
   580 	CheckFileExists(_L("\\F32-TST\\asdf"),KErrNone,EFalse);
   581 	CheckFileExists(_L("\\F32-TST\\Asdf"),KErrNone,ETrue);
   582 
   583 	TBuf<4> shortName;
   584 	shortName.SetLength(1);
   585 	shortName[0]=0xff;
   586 	r=TheFs.Rename(_L("\\F32-TST\\asdf"),shortName);
   587 	test(r==KErrNone);
   588 	r=TheFs.Delete(_L("\\F32-TST\\Asdf"));
   589 	test(r==KErrNotFound);
   590 	r=TheFs.Delete(shortName);
   591 	test(r==KErrNone);
   592 	}
   593 
   594 LOCAL_C void testMaxNameLength()
   595 //
   596 // Create files and directories with the maximum name length
   597 //
   598 	{
   599 
   600 	test.Next(_L("Test max name length"));
   601 	TBuf<128> longNameBase=_L("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
   602 	TFullName longName=_L("\\F32-TST\\MAXNAMELEN\\");
   603 
   604 	longName.Append(longNameBase);
   605 	longName.Append(_L("\\"));
   606 	longName.Append(longNameBase);
   607 	longName.Append(_L("\\"));
   608 
   609 	TInt r=TheFs.MkDirAll(longName);
   610 	test(r==KErrNone);
   611 
   612 	TInt i=0;
   613 	FOREVER
   614 		{
   615 		longName.Append(_L("X"));
   616 		longName.Append(_L("\\"));
   617 		r=TheFs.MkDirAll(longName);
   618 		if (r!=KErrNone)
   619 			break;
   620 		i++;
   621 		}
   622 	
   623 	longName.SetLength(longName.Length()-2);
   624 	r=TheFs.RmDir(longName);
   625 	test(r==KErrNone); // Make room for file
   626 	longName.SetLength(longName.Length()-2);
   627 
   628 	TFullName oldSessionPath;
   629 	r=TheFs.SessionPath(oldSessionPath);
   630 	test(r==KErrNone);
   631 	r=TheFs.SetSessionPath(longName);
   632 	test(r==KErrNone);
   633 	r=TheFs.SessionPath(longName);
   634 	test(r==KErrNone);
   635 
   636 	test.Printf(_L("MaxPathLength achieved = %d chars\n"),longName.Length());
   637 	TBuf<32> fileName=_L("012345678901234567890");
   638 	RFile f;
   639 	while (fileName.Length())
   640 		{
   641 		r=f.Replace(TheFs,fileName,EFileWrite);
   642 		if (r==KErrNone)
   643 			break;
   644 		fileName.SetLength(fileName.Length()-1);
   645 		}
   646 	
   647 	f.Close();
   648 	test.Printf(_L("Added filename %S\n"),&fileName);
   649 	r=f.Open(TheFs,fileName,EFileRead);
   650 	test(r==KErrNone);
   651 	f.Close();
   652 
   653 	CFileMan* fMan=CFileMan::NewL(TheFs);
   654 	r=fMan->RmDir(_L("\\F32-TST\\MAXNAMELEN\\"));
   655 	test(r==KErrNone);
   656 	delete fMan;
   657 
   658 	r=f.Open(TheFs,fileName,EFileRead);
   659 	test(r==KErrPathNotFound);
   660 	r=TheFs.SetSessionPath(oldSessionPath);
   661 	test(r==KErrNone);
   662 	}
   663 
   664 LOCAL_C void testErrorReturnValues()
   665 //
   666 // Test error return values
   667 //
   668 	{
   669 
   670     TInt r;
   671 	test.Next(_L("Create folder with the name of an existing file"));
   672 	MakeFile(_L("\\BLUE"));
   673     if (!IsTestingLFFS())
   674         { //FIXME: Bad error codes from LFFS
   675 	    r=TheFs.MkDir(_L("\\BLUE\\"));
   676         test(r==KErrAccessDenied);
   677         MakeFile(_L("\\RED\\BLUE"));
   678         r=TheFs.MkDir(_L("\\RED\\BLUE\\"));
   679         test(r==KErrAccessDenied);
   680         r=TheFs.MkDirAll(_L("\\BLUE\\GREEN\\ORANGE\\"));
   681         test(r==KErrAccessDenied);
   682         }
   683 
   684 	test.Next(_L("Create folder with the name of an existing folder"));
   685 	MakeDir(_L("\\VOLVO\\"));
   686 	r=TheFs.MkDir(_L("\\VOLVO\\"));
   687 	test(r==KErrAlreadyExists);
   688 	MakeDir(_L("\\FORD\\VOLKSWAGEN\\"));
   689 	r=TheFs.MkDirAll(_L("\\ford\\volkswagen\\"));
   690 	test(r==KErrAlreadyExists);
   691 
   692 	RFile f;
   693     if (!IsTestingLFFS())
   694         { //FIXME Bad error codes from LFFS
   695 	    test.Next(_L("Create a file with the name of an existing folder"));
   696 	    r=f.Create(TheFs,_L("\\VOLVO"),EFileRead|EFileWrite);
   697 	    test(r==KErrAccessDenied);
   698 	    r=f.Replace(TheFs,_L("\\VOLVO"),EFileRead|EFileWrite);
   699 	    test(r==KErrAccessDenied);
   700 	    r=f.Open(TheFs,_L("\\VOLVO"),EFileRead|EFileWrite);
   701 	    test(r==KErrAccessDenied);
   702 	    r=f.Create(TheFs,_L("\\FORD\\VOLKSWAGEN"),EFileRead|EFileWrite);
   703 	    test(r==KErrAccessDenied);
   704 	    r=f.Replace(TheFs,_L("\\FORD\\VOLKSWAGEN"),EFileRead|EFileWrite);
   705 	    test(r==KErrAccessDenied);
   706 	    r=f.Open(TheFs,_L("\\FORD\\VOLKSWAGEN"),EFileRead|EFileWrite);
   707 	    test(r==KErrAccessDenied);
   708         }
   709 
   710 	test.Next(_L("Create a file with the name of an existing file"));
   711 	r=f.Create(TheFs,_L("\\BLUE"),EFileRead|EFileWrite);
   712 	test(r==KErrAlreadyExists);
   713 	}
   714 
   715 LOCAL_C void testSetEntry()
   716 //
   717 // Test set entry
   718 //
   719 	{
   720 
   721 	test.Next(_L("Test SetEntry"));
   722 //	TDateTime dateTime(1968,ENovember,19,12,59,0,0); Year must be > 1980
   723 	TDateTime dateTime(1981,ENovember,19,12,59,0,0);
   724 	TTime time(dateTime);
   725 	MakeFile(_L("DUMENTRY."));
   726 	
   727 	RFile f;
   728 	TInt r=f.Open(TheFs,_L("dumentry"),EFileRead);
   729 	test(r==KErrNone);
   730 	r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttReadOnly,KEntryAttArchive);
   731 	test(r==KErrInUse);
   732 	f.Close();
   733 	
   734 	r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttReadOnly,KEntryAttArchive);
   735 	test(r==KErrNone);
   736 	CheckEntry(_L("DUMEntry"),KEntryAttReadOnly,TTime(dateTime));
   737 	r=TheFs.SetEntry(_L("dumentry."),time,0,KEntryAttReadOnly);
   738 	test(r==KErrNone);
   739 	CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
   740 	r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttDir,0);
   741 	test(r==KErrNone);
   742 	CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
   743 	r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttVolume,0);
   744 	test(r==KErrNone);
   745 	CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
   746 	r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttRemote,0);
   747 	test(r==KErrNone);
   748 	CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
   749 	r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttDir|KEntryAttVolume,0);
   750 	test(r==KErrNone);
   751 	CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
   752 	r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttDir|KEntryAttRemote,0);
   753 	test(r==KErrNone);
   754 	CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
   755 	r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttVolume|KEntryAttRemote,0);
   756 	test(r==KErrNone);
   757 	CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
   758 	r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttDir|KEntryAttVolume|KEntryAttRemote,0);
   759 	test(r==KErrNone);
   760 	CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
   761 	r=TheFs.SetEntry(_L("dumentry."),time,0,KEntryAttDir);
   762 	test(r==KErrNone);
   763 	CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
   764 	r=TheFs.SetEntry(_L("dumentry."),time,0,KEntryAttVolume);
   765 	test(r==KErrNone);
   766 	CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
   767 	r=TheFs.SetEntry(_L("dumentry."),time,0,KEntryAttRemote);
   768 	test(r==KErrNone);
   769 	CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
   770 	r=TheFs.SetEntry(_L("dumentry."),time,0,KEntryAttDir|KEntryAttVolume);
   771 	test(r==KErrNone);
   772 	CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
   773 	r=TheFs.SetEntry(_L("dumentry."),time,0,KEntryAttDir|KEntryAttRemote);
   774 	test(r==KErrNone);
   775 	CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
   776 	r=TheFs.SetEntry(_L("dumentry."),time,0,KEntryAttVolume|KEntryAttRemote);
   777 	test(r==KErrNone);
   778 	CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
   779 	r=TheFs.SetEntry(_L("dumentry."),time,0,KEntryAttDir|KEntryAttVolume|KEntryAttRemote);
   780 	test(r==KErrNone);
   781 	CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
   782 	r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttDir,KEntryAttVolume);
   783 	test(r==KErrNone);
   784 	CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
   785 	r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttDir,KEntryAttRemote);
   786 	test(r==KErrNone);
   787 	CheckEntry(_L("DUMEntry"),0,TTime(dateTime));	
   788 	r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttVolume,KEntryAttDir);
   789 	test(r==KErrNone);
   790 	CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
   791 	r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttVolume,KEntryAttRemote);
   792 	test(r==KErrNone);
   793 	CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
   794 	r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttRemote,KEntryAttDir);
   795 	test(r==KErrNone);
   796 	CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
   797 	r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttRemote,KEntryAttVolume);
   798 	test(r==KErrNone);
   799 	CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
   800 
   801 	r=f.Open(TheFs,_L("dumentry"),EFileWrite);
   802 	test(r==KErrNone);	
   803 
   804 	r=f.SetAtt(KEntryAttDir,0);
   805 	test(r==KErrNone);
   806 	CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
   807 	r=f.SetAtt(KEntryAttVolume,KEntryAttDir);
   808 	test(r==KErrNone);
   809 	CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
   810 	f.Close();
   811 	r=TheFs.Delete(_L("dumEntry."));
   812 	test(r==KErrNone);
   813 
   814 	MakeDir(_L("\\DumEntry\\"));
   815 	r=TheFs.SetEntry(_L("\\dumentry\\"),time,KEntryAttReadOnly,KEntryAttArchive);
   816 	test(r==KErrNone);
   817 	CheckEntry(_L("\\DUMEntry"),KEntryAttReadOnly|KEntryAttDir,TTime(dateTime));
   818 	r=TheFs.SetEntry(_L("\\dumentry."),time,0,KEntryAttReadOnly);
   819 	test(r==KErrNone);
   820 	CheckEntry(_L("\\DUMEntry"),KEntryAttDir,TTime(dateTime));
   821 	r=TheFs.SetEntry(_L("\\dumentry"),time,KEntryAttDir,0);
   822 	test(r==KErrNone);
   823 	CheckEntry(_L("\\DUMEntry"),KEntryAttDir,TTime(dateTime));
   824 	r=TheFs.SetEntry(_L("\\dumentry"),time,KEntryAttVolume,0);
   825 	test(r==KErrNone);
   826 	CheckEntry(_L("\\DUMEntry"),KEntryAttDir,TTime(dateTime));
   827 	r=TheFs.SetEntry(_L("\\dumentry"),time,KEntryAttVolume|KEntryAttDir,0);
   828 	test(r==KErrNone);
   829 	CheckEntry(_L("\\DUMEntry"),KEntryAttDir,TTime(dateTime));
   830 	r=TheFs.SetEntry(_L("\\dumentry"),time,0,KEntryAttVolume|KEntryAttDir);
   831 	test(r==KErrNone);
   832 	CheckEntry(_L("\\DUMEntry"),KEntryAttDir,TTime(dateTime));
   833 	r=TheFs.SetEntry(_L("\\dumentry"),time,0,KEntryAttVolume);
   834 	test(r==KErrNone);
   835 	CheckEntry(_L("\\DUMEntry"),KEntryAttDir,TTime(dateTime));
   836 	r=TheFs.SetEntry(_L("\\dumentry"),time,0,KEntryAttDir);
   837 	test(r==KErrNone);
   838 	CheckEntry(_L("\\DUMEntry"),KEntryAttDir,TTime(dateTime));
   839 	r=TheFs.SetEntry(_L("\\dumentry"),time,KEntryAttVolume,KEntryAttDir);
   840 	test(r==KErrNone);
   841 	CheckEntry(_L("\\DUMEntry"),KEntryAttDir,TTime(dateTime));
   842 	r=TheFs.SetEntry(_L("\\dumentry"),time,KEntryAttDir,KEntryAttVolume);
   843 	test(r==KErrNone);
   844 	CheckEntry(_L("\\DUMEntry"),KEntryAttDir,TTime(dateTime));
   845 	r=TheFs.RmDir(_L("\\dumEntry\\"));
   846 	test(r==KErrNone);
   847 	}
   848 
   849 	
   850 LOCAL_C void testSetFileAttributes()
   851 //
   852 // Test RFile::SetAtt() and RFile::Set()
   853 //
   854 	{
   855 //	First test RFile::SetAtt() function
   856 	
   857 	test.Next(_L("Test RFile::SetAtt()"));
   858 
   859 //	Create a file "TEMPFILE.TMP" and set attributes to hidden	
   860 	RFile file;
   861 	TInt r=file.Replace(TheFs,_L("TEMPFILE.TMP"),0);
   862 	test(r==KErrNone || r==KErrPathNotFound);	
   863 	r=file.SetAtt(KEntryAttHidden,0);
   864 	test(r==KErrNone);
   865 	file.Close();
   866 
   867 //	Check attributes are as set
   868 	file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
   869 	TUint atts;
   870 	r=file.Att(atts);
   871 	test(r==KErrNone);
   872 	file.Close();
   873 	test(atts&KEntryAttHidden);
   874 
   875 //	Change attributes from hidden to system	
   876 	file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
   877 	r=file.SetAtt(KEntryAttSystem,KEntryAttHidden);
   878 	test(r==KErrNone);
   879 	file.Close();
   880 
   881 //	Check attributes have been changed
   882 	file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
   883 	r=file.Att(atts);
   884 	test(r==KErrNone);
   885 	file.Close();
   886 	test(atts&KEntryAttSystem);
   887 
   888 //	Change attributes to normal
   889 	file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
   890 	r=file.SetAtt(KEntryAttNormal,KEntryAttSystem|KEntryAttArchive);
   891 	test(r==KErrNone);
   892 	file.Close();
   893 
   894 //	Check attributes have been changed
   895 	file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
   896 	r=file.Att(atts);
   897 	test(r==KErrNone);
   898 	file.Close();
   899 	test(atts==KEntryAttNormal);
   900 
   901 //	Attempt to change attributes from normal file to directory	
   902 	file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
   903 	r=file.SetAtt(KEntryAttDir,KEntryAttNormal);
   904 	test(r==KErrNone);	//	Returns KErrNone but DOESN'T change the file to a directory
   905 	file.Close();
   906 
   907 //	Check the file has not been changed to a directory
   908 	file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
   909 	r=file.Att(atts);
   910 	test(r==KErrNone);
   911 	file.Close();
   912 	test((TInt)(atts&KEntryAttDir)==KErrNone);
   913 
   914 //	Change the attributes from normal file to hidden file
   915 	file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
   916 	r=file.SetAtt(KEntryAttHidden,KEntryAttNormal);
   917 	test(r==KErrNone);
   918 	file.Close();
   919 
   920 //	Check the attributes have been changed
   921 	file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
   922 	r=file.Att(atts);
   923 	test(r==KErrNone);
   924 	file.Close();
   925 	test(atts&KEntryAttHidden);
   926 
   927 //	Try to change the attributes from hidden file to volume	
   928 	file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
   929 	r=file.SetAtt(KEntryAttVolume,KEntryAttHidden);
   930 	test(r==KErrNone);	//	Returns KErrNone but DOESN'T change the file to a volume
   931 	file.Close();
   932 
   933 //	Check that the hidden file has not been changed to a volume
   934 	file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
   935 	r=file.Att(atts);
   936 	test(r==KErrNone);
   937 	file.Close();
   938 	test((TInt)(atts&KEntryAttVolume)==KErrNone);
   939 
   940 //	Test RFile::Set() function	
   941 	
   942 	test.Next(_L("Test RFile::Set()"));	
   943 
   944 //	Check attributes 
   945 	file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
   946 	r=file.Att(atts);
   947 	test(r==KErrNone);
   948 	file.Close();
   949 	test(atts==KEntryAttNormal);
   950 
   951 //	Change attributes from hidden to system	- and change modification time
   952 	TDateTime dateTime(1998,EMay,25,18,23,0,0);
   953 	TTime modTime1(dateTime);
   954 	TTime retTime;
   955 	file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
   956 	r=file.Set(modTime1,KEntryAttSystem,KEntryAttNormal);
   957 	test(r==KErrNone);
   958 	file.Close();
   959 
   960 //	Check attributes have been changed
   961 	file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
   962 	r=file.Att(atts);
   963 	test(r==KErrNone);
   964 	r=file.Modified(retTime);
   965 	test(r==KErrNone);
   966 	file.Close();
   967 	test(atts&KEntryAttSystem);
   968 	test(retTime==modTime1);
   969 
   970 //	Change attributes to normal - and change modification time
   971 	dateTime.Set(1997,EMay,24,17,25,0,0);
   972 	TTime modTime2(dateTime);
   973 	file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
   974 	r=file.Set(modTime2,KEntryAttNormal,KEntryAttSystem|KEntryAttArchive);
   975 	test(r==KErrNone);
   976 	file.Close();
   977 
   978 //	Check attributes have been changed
   979 	file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
   980 	r=file.Att(atts);
   981 	test(r==KErrNone);
   982 	r=file.Modified(retTime);
   983 	test(r==KErrNone);
   984 	file.Close();
   985 	test(atts==KEntryAttNormal);
   986 	test(retTime==modTime2);
   987 
   988 //	Attempt to change attributes from normal file to directory	
   989 	file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
   990 	r=file.Set(modTime1,KEntryAttDir,KEntryAttNormal);
   991 	test(r==KErrNone);	//	Returns KErrNone but DOESN'T change the file to a directory
   992 	file.Close();
   993 
   994 //	Check the file has not been changed to a directory
   995 	file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
   996 	r=file.Att(atts);
   997 	test(r==KErrNone);
   998 	r=file.Modified(retTime);
   999 	test(r==KErrNone);
  1000 	file.Close();
  1001 	test((TInt)(atts&KEntryAttDir)==KErrNone);
  1002 	test(retTime==modTime1);//	Modification time should have been set successfully
  1003 
  1004 //	Change the attributes from normal file to hidden file - and change modification time
  1005 	file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
  1006 	r=file.Set(modTime1,KEntryAttHidden,KEntryAttNormal);
  1007 	test(r==KErrNone);
  1008 	file.Close();
  1009 
  1010 //	Check the attributes have been changed
  1011 	file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
  1012 	r=file.Att(atts);
  1013 	test(r==KErrNone);
  1014 	r=file.Modified(retTime);
  1015 	file.Close();
  1016 	test(atts&KEntryAttHidden);
  1017 	test(retTime==modTime1);
  1018 
  1019 //	Try to change the attributes from hidden file to volume	
  1020 	file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
  1021 	r=file.Set(modTime2,KEntryAttVolume,KEntryAttHidden);
  1022 	test(r==KErrNone);	//	Returns KErrNone but DOESN'T change the file to a volume
  1023 	file.Close();
  1024 
  1025 //	Check that the hidden file has not been changed to a volume
  1026 	file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
  1027 	r=file.Att(atts);
  1028 	test(r==KErrNone);
  1029 	r=file.Modified(retTime);
  1030 	test(r==KErrNone);
  1031 	file.Close();
  1032 	test((TInt)(atts&KEntryAttVolume)==KErrNone);
  1033 	test(retTime==modTime2);	//	Modification time should have been set successfully
  1034 	
  1035 	r=TheFs.Delete(_L("TEMPFILE.TMP"));
  1036 	
  1037 	}	
  1038 
  1039 
  1040 GLDEF_C void CallTestsL()
  1041 //
  1042 // Do tests relative to session path
  1043 //
  1044 	{
  1045 
  1046 	TurnAllocFailureOff();
  1047 	CreateTestDirectory(_L("\\F32-TST\\TNMBS\\"));
  1048 	testMkDirRmDir(); // Must come first
  1049 	testSetEntry();
  1050 	testSetFileAttributes();
  1051 	testRename();
  1052 	TestLongFileName();
  1053 	testRenameRegression();
  1054 	testRenameCase();
  1055 	testMaxNameLength();
  1056 	testEntry();
  1057 	testReplace();
  1058 	testErrorReturnValues();
  1059 	DeleteTestDirectory();
  1060 	}
  1061