1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/server/b_gen.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1488 @@
1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include <f32file.h>
1.20 +#include <e32test.h>
1.21 +#include <e32math.h>
1.22 +#include <e32hal.h>
1.23 +#include "t_server.h"
1.24 +#include "t_chlffs.h"
1.25 +
1.26 +#ifdef __VC32__
1.27 + // Solve compilation problem caused by non-English locale
1.28 + #pragma setlocale("english")
1.29 +#endif
1.30 +
1.31 +GLDEF_D RTest test(_L("B_GEN"));
1.32 +//
1.33 +// File test - general test of local filing system routines
1.34 +// (finishes with formating current device).
1.35 +// Modified from BB's epoc test code
1.36 +
1.37 +#define MINIMUM_DATE (315532800L)
1.38 +#define DateTests 10
1.39 +
1.40 +// GLREF_D P_DEVICE p_file;
1.41 +// GLREF_D P_DEVICE p_wind,p_screen,p_cons;
1.42 +
1.43 +GLDEF_D TBuf<0x100> gNameBuf;
1.44 +GLDEF_D TBuf<0x100> gNameOut;
1.45 +GLDEF_D RFile gFile;
1.46 +GLDEF_D RFile gFileErr;
1.47 +GLDEF_D RFile gFile2;
1.48 +GLDEF_D RDir gDir;
1.49 +GLDEF_D RFormat gFormat;
1.50 +//GLDEF_D void *chan1,*chan2;
1.51 +GLDEF_D TFileName fBuf;
1.52 +//GLDEF_D TUint8 fBuf[P_FNAMESIZE];
1.53 +
1.54 +
1.55 +LOCAL_D TBuf8<0x4000> gDataBuf;
1.56 +LOCAL_D TEntry gFileEntry;
1.57 +// LOCAL_D P_DINFO volInfo;
1.58 +LOCAL_D TVolumeInfo volInfo;
1.59 +// LOCAL_D P_NINFO nInfo;
1.60 +LOCAL_D TFileName pathBuf;
1.61 +
1.62 +
1.63 +LOCAL_D TInt NameErr=KErrBadName;
1.64 +LOCAL_D TInt DirErr=KErrPathNotFound;
1.65 +LOCAL_D TInt AccessErr=KErrAccessDenied;
1.66 +LOCAL_D TInt LockedErr=KErrInUse;
1.67 +LOCAL_D TInt ExistsErr=KErrAlreadyExists;
1.68 +LOCAL_D TInt NotExistsErr=KErrNotFound;
1.69 +LOCAL_D TInt EofErr=KErrEof;
1.70 +LOCAL_D TInt DeviceErr=KErrNotReady;
1.71 +//LOCAL_D TInt NoFileSystemErr=KErrNotReady;
1.72 +//LOCAL_D TInt NotSupportedErr=KErrNotSupported;
1.73 +LOCAL_D TInt ReadOnlyErr=KErrAccessDenied;
1.74 +
1.75 +LOCAL_D TInt P_FASTREAM=EFileStream;
1.76 +LOCAL_D TInt P_FAEXEC=0;
1.77 +LOCAL_D TInt P_FAMOD=KEntryAttArchive;
1.78 +LOCAL_D TInt P_FAREAD=KEntryAttReadOnly;
1.79 +//LOCAL_D TInt P_FAHIDDEN=KEntryAttHidden;
1.80 +//LOCAL_D TInt P_FASYSTEM=KEntryAttSystem;
1.81 +//LOCAL_C TInt P_FAVOLUME=KEntryAttVolume;
1.82 +LOCAL_C TInt P_FADIR=KEntryAttDir;
1.83 +LOCAL_C TInt P_FRANDOM=0;
1.84 +LOCAL_C TInt P_FABS=ESeekStart;
1.85 +
1.86 +LOCAL_C TInt P_FUPDATE=EFileWrite;
1.87 +
1.88 +
1.89 +LOCAL_C void doError(const TDesC &aMess, TInt anErr, TInt line)
1.90 + {
1.91 + test.Printf(_L("%S failed at line %d. Error %d\n"),&aMess, line, anErr);
1.92 + test(0);
1.93 + }
1.94 +#define Error(aMess, anErr) doError(aMess, anErr, __LINE__)
1.95 +
1.96 +LOCAL_C void doError2(const TDesC &aMess, TInt anErr, TInt line, TInt callLine)
1.97 + {
1.98 + test.Printf(_L("%S failed at line %d. Error %d. Called from line %d\n"),&aMess, line, anErr, callLine); \
1.99 + test(0);
1.100 + }
1.101 +#define Error2(aMess, anErr, line) doError2(aMess, anErr, __LINE__, line)
1.102 +
1.103 +LOCAL_C void testWrite(const TDesC& aName,TInt aLen,TInt32 aSize,TBool aShouldChange)
1.104 +//
1.105 +// Write to a file
1.106 +//
1.107 + {
1.108 +
1.109 + TTime saveTime;
1.110 + TInt c;
1.111 + test.Printf(_L("Write %u bytes %u\n"),aLen,aShouldChange);
1.112 + if ((c=TheFs.Entry(aName,gFileEntry))!=KErrNone)
1.113 + Error(_L("File info 600"),c);
1.114 + saveTime=gFileEntry.iModified;
1.115 + User::After(3000000L); // 30 tenths of a sec = 30 00000 micro seconds
1.116 + if ((c=gFile.Open(TheFs,aName,EFileWrite))!=KErrNone)
1.117 + Error(_L("Open 50"),c);
1.118 + if ((c=gFile.Write(gDataBuf,aLen))!=KErrNone)
1.119 + Error(_L("Write"),c);
1.120 + gFile.Close();
1.121 + if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone)
1.122 + Error(_L("File info 601"),c);
1.123 + if ((saveTime!=gFileEntry.iModified)!=aShouldChange)
1.124 + Error(_L("Change flag check 6"),0);
1.125 + if (gFileEntry.iSize!=aSize)
1.126 + Error(_L("Size check 602"),0);
1.127 + }
1.128 +
1.129 +LOCAL_C void testSetEof(const TDesC& aName,TUint32 aPos,TBool aShouldChange)
1.130 +//
1.131 +// Set the end of a file
1.132 +//
1.133 + {
1.134 +
1.135 + TTime saveTime;
1.136 + TInt c;
1.137 + test.Printf(_L("Set EOF to %u %u\n"),aPos,aShouldChange);
1.138 + if ((c=TheFs.Entry(aName,gFileEntry))!=KErrNone)
1.139 + Error(_L("File info 500"),c);
1.140 + saveTime=gFileEntry.iModified;
1.141 + User::After(3000000L);
1.142 + if ((c=gFile.Open(TheFs,aName,EFileWrite))!=KErrNone)
1.143 + Error(_L("Open 50"),c);
1.144 + if ((c=gFile.SetSize(aPos))!=KErrNone)
1.145 + Error(_L("Set EOF 50"),c);
1.146 + gFile.Close();
1.147 + if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone)
1.148 + Error(_L("File info 501"),c);
1.149 + if ((saveTime!=gFileEntry.iModified)!=aShouldChange)
1.150 + Error(_L("Change flag check 5"),0);
1.151 + }
1.152 +
1.153 +
1.154 +LOCAL_C void testDir(const TDesC& aDirName)
1.155 +//
1.156 +// Create a directory
1.157 +//
1.158 + {
1.159 +
1.160 + TInt c;
1.161 + test.Printf(_L("Test dir %S\n"),&aDirName);
1.162 + c=gDir.Open(TheFs,aDirName,KEntryAttNormal);
1.163 +
1.164 + if (c!=KErrNone)
1.165 + Error(_L("Directory open 1000"),c);
1.166 +
1.167 + gDir.Close();
1.168 +
1.169 + TChar drive(aDirName[0]);
1.170 + TInt driveNo;
1.171 + c=RFs::CharToDrive(drive,driveNo);
1.172 + test(c==KErrNone);
1.173 + if ((c=TheFs.Volume(volInfo,driveNo))!=KErrNone)
1.174 + Error(_L("Device info 1000"),c);
1.175 + }
1.176 +
1.177 +
1.178 +/*
1.179 +LOCAL_C void testNodeInfo(const TDesC& aName,TInt type,TInt anErr)
1.180 +//
1.181 +// Test p_ninfo.
1.182 +//
1.183 + {
1.184 +
1.185 +// TInt c;
1.186 + test.Printf(_L("Node info: %S\n"),&aName);
1.187 +// if ((c=p_ninfo(aDirName,&nInfo))!=anErr)
1.188 +// Error(_L("Device info"),c);
1.189 + if (anErr==0)
1.190 + {
1.191 +// if (!(nInfo.version==2 || nInfo.version==3))
1.192 +// Error(_L("Node version check"),0);
1.193 +// if (nInfo.type!=type)
1.194 +// Error(_L("Node type check"),0);
1.195 + }
1.196 + }
1.197 +*/
1.198 +
1.199 +LOCAL_C void testDeviceInfo(const TDesC& aDeviceName,TInt anErr)
1.200 +//
1.201 +// Test p_dinfo.
1.202 +//
1.203 + {
1.204 +
1.205 + TInt c;
1.206 + test.Printf(_L("Device info: %S\n"),&aDeviceName);
1.207 + TInt drive=KDefaultDrive;
1.208 + if (aDeviceName.Length())
1.209 + {
1.210 + c=RFs::CharToDrive(aDeviceName[0],drive);
1.211 + test(c==KErrNone);
1.212 + }
1.213 + if ((c=TheFs.Volume(volInfo,drive))!=anErr)
1.214 + Error(_L("Device info"),c);
1.215 + if (anErr==0)
1.216 + {
1.217 +// if (!(volInfo.version==2 || volInfo.version==3)) ********* version is not a member of TVolumeInfo
1.218 +// Error(_L("Device version check"),0);
1.219 + if (volInfo.iFree>volInfo.iSize)
1.220 + Error(_L("Free greater than size check"),0);
1.221 + }
1.222 + }
1.223 +
1.224 +LOCAL_C void testFileInfo(const TDesC& aFileName,TInt anErr)
1.225 +//
1.226 +// Test entry info
1.227 +//
1.228 + {
1.229 +
1.230 + TInt c;
1.231 + test.Printf(_L("File info: %S\n"),&aFileName);
1.232 + if ((c=TheFs.Entry(aFileName,gFileEntry))!=anErr)
1.233 + Error(_L("Get info 100"),c);
1.234 + if (anErr==0)
1.235 + {
1.236 + if (aFileName.Length()>=2 && aFileName[0]=='Z' && aFileName[1]==':')
1.237 + {
1.238 + if ((gFileEntry.iAtt&(P_FAREAD|P_FAEXEC|P_FASTREAM)) != (TUint32)(P_FAREAD|P_FAEXEC|P_FASTREAM) && gFileEntry.iAtt!=KEntryAttDir)
1.239 + Error(_L("Info status check Z:\\"),0);
1.240 + }
1.241 + else
1.242 + {
1.243 + if (gFileEntry.iAtt&KEntryAttDir)
1.244 + return; // Found directory entry
1.245 + if (gFileEntry.iAtt!=(TUint32)(P_FASTREAM|P_FAMOD))
1.246 + Error(_L("Info status check"),0);
1.247 + if (gFileEntry.iSize!=0L)
1.248 + Error(_L("Info size check"),0);
1.249 + }
1.250 + }
1.251 + }
1.252 +
1.253 +LOCAL_C void testRenameFromRoot(const TDesC& aRName,const TDesC& aDName)
1.254 +//
1.255 +//
1.256 +//
1.257 + {
1.258 +
1.259 + TInt c;
1.260 + if ((c=TheFs.Rename(aRName,aDName))!=KErrNone)
1.261 + Error(_L("Rename 92"),c);
1.262 + if ((c=gFile.Open(TheFs,aDName,EFileStream))!=KErrNone)
1.263 + Error(_L("Open 92"),c);
1.264 + gFile.Close();
1.265 + if ((c=TheFs.Delete(aRName))!=NotExistsErr)
1.266 + Error(_L("Delete 92"),c);
1.267 + }
1.268 +
1.269 +LOCAL_C void testRenameToRoot(const TDesC& pName,const TDesC& rName)
1.270 +//
1.271 +//
1.272 +//
1.273 + {
1.274 +
1.275 + TInt c;
1.276 + if ((c=gFile.Replace(TheFs,pName,EFileStream))!=KErrNone)
1.277 + Error(_L("Create 91"),c);
1.278 + gFile.Close();
1.279 + if ((c=TheFs.Rename(pName,rName))!=KErrNone)
1.280 + Error(_L("Rename 91"),c);
1.281 + if ((c=gFile.Open(TheFs,rName,EFileStream))!=KErrNone)
1.282 + Error(_L("Open 91"),c);
1.283 + gFile.Close();
1.284 + if ((c=TheFs.Delete(pName))!=NotExistsErr)
1.285 + Error(_L("Delete 91"),c);
1.286 + }
1.287 +
1.288 +LOCAL_C void verifyTestPat1()
1.289 +//
1.290 +//
1.291 +//
1.292 + {
1.293 +
1.294 + TInt i;
1.295 + TInt c;
1.296 + if ((c=gFile.Open(TheFs,_L("\\TESTPAT1.DAT"),EFileStream))!=KErrNone)
1.297 + Error(_L("Create testpat1"),c);
1.298 + gDataBuf.SetLength(0);
1.299 + if ((c=gFile.Read(gDataBuf,512))!=KErrNone || gDataBuf.Length()!=512)
1.300 + Error(_L("Read 90"),c);
1.301 + gFile.Close();
1.302 + for (i=0;i<512;i++)
1.303 + {
1.304 + if (gDataBuf[i]!='X')
1.305 + Error(_L("Data check"),0);
1.306 + }
1.307 + }
1.308 +
1.309 +void TestINC103141() // PDEF104017
1.310 + {
1.311 + test.Printf(_L("Test INC103141\n"));
1.312 + _LIT(KDir1, "\\INC103141\\TEST");
1.313 + _LIT(KDir2, "\\INC103141\\test");
1.314 + TBuf<32> dirname;
1.315 + dirname.Copy(KDir1);
1.316 + dirname.Append(KPathDelimiter);
1.317 + MakeDir(dirname);
1.318 + TInt err = TheFs.Rename(KDir1, KDir2);
1.319 + test(err == KErrNone);
1.320 + err = TheFs.RmDir(dirname);
1.321 + test(err == KErrNone);
1.322 + err = TheFs.RmDir(KDir1);
1.323 + test(err == KErrNone);
1.324 + }
1.325 +
1.326 +LOCAL_C void testRename()
1.327 +//
1.328 +// Test TheFs.Rename function.
1.329 +//
1.330 + {
1.331 +
1.332 + TBuf<32> xName;
1.333 + TInt i;
1.334 + TInt c;
1.335 + test.Printf(_L("Test TheFs.Rename\n"));
1.336 +
1.337 + test.Printf(_L("Test rename into root\n"));
1.338 + if ((c=gFile.Replace(TheFs,_L("\\TESTPAT1.DAT"),EFileStream|P_FUPDATE))!=KErrNone)
1.339 + Error(_L("Create testpat1"),c);
1.340 + gDataBuf.Fill('X',512);
1.341 + if ((c=gFile.Write(gDataBuf,512))!=KErrNone)
1.342 + Error(_L("Write 90"),c);
1.343 + gFile.Close();
1.344 + if ((c=TheFs.MkDir(_L("\\DIRX\\")))!=KErrNone)
1.345 + Error(_L("Make dir 90"),c);
1.346 + for (i=0;i<32;i++)
1.347 + {
1.348 + xName.Format(_L("\\DIRX\\FILEX%u"),i);
1.349 + TPtrC rootName(xName.Ptr()+5,xName.Length()-5);
1.350 + testRenameToRoot(xName,rootName);
1.351 + verifyTestPat1();
1.352 + }
1.353 +
1.354 + test.Printf(_L("Test rename from root\n"));
1.355 + for (i=0;i<32;i++)
1.356 + {
1.357 + xName.Format(_L("\\DIRX\\FILEX%u"),i);
1.358 + TPtrC rootName(xName.Ptr()+5,xName.Length()-5);
1.359 + testRenameFromRoot(rootName,xName);
1.360 + verifyTestPat1();
1.361 + }
1.362 + for (i=0;i<32;i++)
1.363 + {
1.364 + xName.Format(_L("\\DIRX\\FILEX%u"),i);
1.365 + if ((c=TheFs.Delete(xName))!=KErrNone)
1.366 + Error(_L("Delete 93"),c);
1.367 + }
1.368 + if ((c=TheFs.RmDir(_L("\\DIRX\\")))!=KErrNone)
1.369 + Error(_L("Delete DIRX"),c);
1.370 + verifyTestPat1();
1.371 + if ((c=TheFs.Delete(_L("\\TESTPAT1.DAT")))!=KErrNone)
1.372 + Error(_L("Delete 80"),c);
1.373 +
1.374 + test.Printf(_L("Test rename with wild cards\n"));
1.375 + if ((c=TheFs.Rename(_L("*.*"),_L("FRED")))!=NameErr)
1.376 + Error(_L("Rename 100"),c);
1.377 + if ((c=TheFs.Rename(_L("?"),_L("FRED")))!=NameErr)
1.378 + Error(_L("Rename 101"),c);
1.379 + if ((c=TheFs.Rename(_L(""),_L("FRED")))!=KErrBadName) // NameErr)
1.380 + Error(_L("Rename 101.11"),c);
1.381 + if ((c=TheFs.Rename(_L("."),_L("FRED")))!=NameErr)
1.382 + Error(_L("Rename 101.12"),c);
1.383 + if ((c=TheFs.Rename(_L("NOEXIST"),_L("*")))!=NameErr)
1.384 + Error(_L("Rename 101.1"),c);
1.385 + if ((c=gFile.Create(TheFs,_L("FILE1"),EFileStream))!=KErrNone)
1.386 + Error(_L("Create 101.2"),c);
1.387 + gFile.Close();
1.388 + if ((c=TheFs.Rename(_L("FILE1"),_L("AAA?")))!=NameErr)
1.389 + Error(_L("Rename 101.3"),c);
1.390 + if ((c=TheFs.Rename(_L("FILE1"),_L("")))!=KErrBadName) // NameErr)
1.391 + Error(_L("Rename 101.41"),c);
1.392 + if ((c=TheFs.Rename(_L(""),_L("")))!=KErrBadName) // NameErr)
1.393 + Error(_L("Rename 101.42"),c);
1.394 + if ((c=TheFs.Delete(_L("FILE1")))!=KErrNone)
1.395 + Error(_L("Delete 101.5"),c);
1.396 + if ((c=TheFs.Rename(_L("\\"),_L("FRED")))!=NameErr)
1.397 + Error(_L("Rename 101.6"),c);
1.398 +
1.399 + test.Printf(_L("Test rename of directories\n"));
1.400 + if ((c=TheFs.MkDir(_L("\\DIR1\\")))!=KErrNone)
1.401 + Error(_L("Make dir 102"),c);
1.402 + if ((c=TheFs.Rename(_L("\\DIR1"),_L("\\A2345678.123")))!=KErrNone)
1.403 + Error(_L("Rename 103.1"),c);
1.404 + if ((c=TheFs.Rename(_L("\\A2345678.123"),_L("\\DIR2")))!=KErrNone)
1.405 + Error(_L("Rename 103.2"),c);
1.406 + if ((c=TheFs.Rename(_L("\\DIR2"),_L("\\A234567.1234")))!=KErrNone) // ****** NameErr) Long filenames are supported
1.407 + Error(_L("Rename 103.3"),c);
1.408 + if ((c=TheFs.Rename(_L("\\A234567.1234"),_L("\\DIR2")))!=KErrNone)
1.409 + Error(_L("Rename 103.3"),c);
1.410 + if ((c=TheFs.MkDir(_L("\\DIR1\\")))!=KErrNone)
1.411 + Error(_L("Make dir 104"),c);
1.412 +
1.413 + test.Printf(_L("Test rename of open files\n"));
1.414 + if ((c=gFile.Create(TheFs,_L("\\DIR1\\FILE1"),EFileStreamText))!=KErrNone)
1.415 + Error(_L("Create 105"),c);
1.416 + if ((c=TheFs.Rename(_L("\\DIR1\\FILE1"),_L("\\DIR1\\FILE1")))!=LockedErr)
1.417 + Error(_L("Rename 106"),c);
1.418 + if ((c=TheFs.Rename(_L("\\DIR1\\FILE1"),_L("\\DIR2\\FILE1")))!=LockedErr)
1.419 + Error(_L("Rename 106.1"),c);
1.420 + if ((c=gFile2.Open(TheFs,_L("\\DIR2\\FILE1"),EFileStream))!=NotExistsErr)
1.421 + Error(_L("Create 105"),c);
1.422 + gFile.Close();
1.423 +
1.424 + test.Printf(_L("Test rename to same name\n"));
1.425 + if ((c=TheFs.Rename(_L("\\DIR1\\FILE1"),_L("\\DIR1\\FILE1")))!=KErrNone) // !=ExistsErr)
1.426 + Error(_L("Rename 105.1"),c);
1.427 + if ((c=TheFs.Rename(_L("\\DIR1"),_L("\\DIR1")))!=KErrNone) // !=ExistsErr)
1.428 + Error(_L("Rename 105.2"),c);
1.429 +
1.430 + test.Printf(_L("Test rename of read-only files\n")); // IS ALLOWED //
1.431 + if ((c=TheFs.SetAtt(_L("\\DIR1\\FILE1"),KEntryAttReadOnly,0))!=KErrNone)
1.432 + Error(_L("Att 106"),c);
1.433 + if ((c=TheFs.Entry(_L("\\DIR1\\FILE1"),gFileEntry))!=KErrNone)
1.434 + Error(_L("File info 106.1"),c);
1.435 + test.Printf(_L("STATUS=%04x\n"),gFileEntry.iAtt);
1.436 + if (gFileEntry.iAtt!=(TUint32)(P_FAREAD|P_FASTREAM|P_FAMOD))
1.437 + Error(_L("Status check 106.2"),0);
1.438 + if ((c=TheFs.Entry(_L("\\DIR1"),gFileEntry))!=KErrNone)
1.439 + Error(_L("File info 106.3"),c);
1.440 + test.Printf(_L("STATUS=%04x\n"),gFileEntry.iAtt);
1.441 + if (gFileEntry.iAtt!=(TUint32)(P_FASTREAM|P_FADIR))
1.442 + Error(_L("Status check 106.4"),0);
1.443 +
1.444 + if ((c=TheFs.Rename(_L("\\DIR1\\FILE1"),_L("\\DIR1\\FILE1")))!=KErrNone) // !=ExistsErr)
1.445 + Error(_L("Rename 107"),c);
1.446 + if ((c=TheFs.Rename(_L("\\DIR1\\FILE1"),_L("\\DIR1\\FILE2")))!=KErrNone)
1.447 + Error(_L("Rename 108"),c);
1.448 + if ((c=TheFs.Rename(_L("\\DIR1\\FILE2"),_L("\\DIR2\\FILE2")))!=KErrNone)
1.449 + Error(_L("Rename 109"),c);
1.450 + if ((c=gFile2.Open(TheFs,_L("\\DIR2\\FILE2"),EFileStream))!=KErrNone)
1.451 + Error(_L("Create 110"),c);
1.452 + gFile2.Close();
1.453 + if ((c=TheFs.Rename(_L("\\DIR2\\FILE2"),_L("\\DIR1\\FILE1")))!=KErrNone)
1.454 + Error(_L("Rename 110.1"),c);
1.455 + if ((c=TheFs.SetAtt(_L("\\DIR1\\FILE1"),0,KEntryAttReadOnly))!=KErrNone)
1.456 + Error(_L("Att 111"),c);
1.457 +
1.458 + test.Printf(_L("Test rename of files across directories\n"));
1.459 + if ((c=TheFs.Rename(_L("\\DIR1\\FILE1"),_L("\\DIR2\\FILE1")))!=KErrNone)
1.460 + Error(_L("Rename 112"),c);
1.461 + if ((c=gFile.Open(TheFs,_L("\\DIR2\\FILE1"),EFileStream))!=KErrNone)
1.462 + Error(_L("Exist 113"),c);
1.463 + gFile.Close();
1.464 +
1.465 + test.Printf(_L("Test rename of directories across directories\n"));
1.466 + if ((c=TheFs.Rename(_L("\\DIR1"),_L("\\DIR2\\DIR1")))!=KErrNone) // ******** AccessErr)
1.467 + Error(_L("Rename 114"),c);
1.468 + if ((c=TheFs.Rename(_L("\\DIR1"),_L("\\")))!=NameErr)
1.469 + Error(_L("Rename 114.1"),c);
1.470 +
1.471 + if ((c=TheFs.Delete(_L("\\DIR2\\FILE1")))!=KErrNone)
1.472 + Error(_L("Delete 115"),c);
1.473 + if ((c=TheFs.RmDir(_L("\\DIR2\\DIR1\\")))!=KErrNone)
1.474 + Error(_L("Delete 115"),c);
1.475 + if ((c=TheFs.RmDir(_L("\\DIR2\\")))!=KErrNone)
1.476 + Error(_L("Delete 115"),c);
1.477 +
1.478 + TestINC103141(); // PDEF104017
1.479 + }
1.480 +
1.481 +LOCAL_C void testDelete()
1.482 +//
1.483 +// Test RFs::Delete function.
1.484 +//
1.485 + {
1.486 +
1.487 + TInt c;
1.488 + test.Printf(_L("Test RFs::Delete\n"));
1.489 + test.Printf(_L("Test delete non-empty directories\n"));
1.490 + if ((c=TheFs.MkDir(_L("\\TESTDIR\\")))!=KErrNone)
1.491 + Error(_L("Make dir 500"),c);
1.492 + if ((c=gFile.Create(TheFs,_L("\\TESTDIR\\NAME.EXT"),EFileStream))!=KErrNone)
1.493 + Error(_L("Create"),c);
1.494 + if ((c=TheFs.Delete(_L("\\TESTDIR\\")))!=KErrBadName) // ******* AccessErr)
1.495 + Error(_L("Delete 501"),c);
1.496 +
1.497 + test.Printf(_L("Test delete open file\n"));
1.498 + if ((c=TheFs.Delete(_L("\\TESTDIR\\NAME.EXT")))!=LockedErr)
1.499 + Error(_L("Delete 502"),c);
1.500 + gFile.Close();
1.501 + if ((c=TheFs.Delete(_L("\\TESTDIR\\NAME.EXT")))!=KErrNone)
1.502 + Error(_L("Delete 503"),c);
1.503 + if ((c=TheFs.RmDir(_L("\\TESTDIR\\")))!=KErrNone)
1.504 + Error(_L("Delete 504"),c);
1.505 + }
1.506 +
1.507 +LOCAL_C void testUnique(TUint fileFormat)
1.508 +//
1.509 +// Test RFile::Temp
1.510 +//
1.511 + {
1.512 +
1.513 + TInt pos;
1.514 + TInt c;
1.515 + test.Printf(_L("Test RFile::Temp\n"));
1.516 + gDataBuf.SetLength(1);
1.517 + if ((c=gFile.Temp(TheFs,_L(""),gNameBuf,fileFormat))!=KErrNone)
1.518 + Error(_L("Directory open 2000"),c);
1.519 + if ((c=gFile.Write(gDataBuf,0))!=KErrNone)
1.520 + Error(_L("Write 2000"),c);
1.521 + if ((c=gFile.Write(gDataBuf,1))!=KErrNone)
1.522 + Error(_L("Write 2000"),c);
1.523 + pos=0L;
1.524 + if ((c=gFile.Seek(ESeekStart,pos))!=KErrNone) // !=E_FILE_INV) Temp file is random access
1.525 + Error(_L("Seek 2000"),c);
1.526 + gFile.Close();
1.527 + if ((c=TheFs.Delete(gNameBuf))!=KErrNone)
1.528 + Error(_L("Delete"),c);
1.529 + }
1.530 +
1.531 +LOCAL_C void testFileName(const TDesC& aFileName,TInt res)
1.532 +//
1.533 +//
1.534 +//
1.535 + {
1.536 +
1.537 + TInt c;
1.538 + if ((c=aFileName.Length())>20)
1.539 + test.Printf(_L("%u char name\n"),c);
1.540 + else
1.541 + test.Printf(_L("\"%S\"\n"),&aFileName);
1.542 + if ((c=gFile.Create(TheFs,aFileName,EFileStream))!=res)
1.543 + Error(_L("Create 200"),c);
1.544 + if (res==KErrNone)
1.545 + {
1.546 + gFile.Close();
1.547 + if ((c=gFile.Open(TheFs,aFileName,EFileStream))!=KErrNone)
1.548 + Error(_L("Open 200"),c);
1.549 + gFile.Close();
1.550 + if ((c=TheFs.Delete(aFileName))!=KErrNone)
1.551 + Error(_L("Delete 200"),c);
1.552 + }
1.553 + else
1.554 + {
1.555 + if ((c=gFile.Open(TheFs,aFileName,EFileStream))!=res) // test eg *.* //
1.556 + Error(_L("Open 201"),c);
1.557 + if ((c=gFile.Replace(TheFs,aFileName,EFileStream))!=res)
1.558 + Error(_L("Replace 202"),c);
1.559 + }
1.560 + }
1.561 +
1.562 +#if defined(_UNICODE)
1.563 +LOCAL_C void testFileName(const TDesC8& aFileName,TInt res)
1.564 +//
1.565 +// Defined to cope with all the instances of testFileName(gDataBuf,...)
1.566 +//
1.567 + {
1.568 + TPtrC gDataBuf16((TText*)aFileName.Ptr(),gDataBuf.Size()/sizeof(TText8));
1.569 + testFileName(gDataBuf16,res);
1.570 + }
1.571 +#endif
1.572 +
1.573 +LOCAL_C void testVolumeName(const TDesC& aVolumeName,TInt aResultExpected)
1.574 +//
1.575 +//
1.576 +//
1.577 + {
1.578 +
1.579 + TInt result;
1.580 + test.Printf(_L("\"%S\"\n"),&aVolumeName);
1.581 + TInt drive=KDefaultDrive;
1.582 + if (aVolumeName.Length()>=2 && aVolumeName[0]=='Z' && aVolumeName[1]==':')
1.583 + {
1.584 + drive=25;
1.585 + TPtr volName((TText*)&aVolumeName[2],(aVolumeName.Length()-2),(aVolumeName.Length()-2));
1.586 + result=TheFs.SetVolumeLabel(volName,drive);
1.587 + }
1.588 + else
1.589 + result=TheFs.SetVolumeLabel(aVolumeName,drive);
1.590 +
1.591 + if (result==KErrGeneral)
1.592 + {
1.593 + test.Printf(_L("KErrGeneral: Cannot set volume label on a substed drive!\n"));
1.594 + return;
1.595 + }
1.596 + if (result!=aResultExpected)
1.597 + Error(_L("Set volume name returned"),result);
1.598 +
1.599 +/* if (aResultExpected==FALSE)
1.600 + {
1.601 + if ((result=TheFs.Volume(volInfo))!=KErrNone)
1.602 + Error(_L("Volume Info failed"),result);
1.603 + TPtrC vol(aVolumeName);
1.604 + if (vol!=volInfo.iName)
1.605 + Error(_L("Check volume name failed"),0);
1.606 + }
1.607 +*/
1.608 + }
1.609 +
1.610 +#define testMakeDir(aDirName, res) TestMakeDirLine(aDirName, res, __LINE__)
1.611 +LOCAL_C void TestMakeDirLine(const TDesC& aDirName,TInt res, TInt line)
1.612 +//
1.613 +//
1.614 +//
1.615 + {
1.616 +
1.617 + TInt c;
1.618 + TUint l;
1.619 + TFileName buf;
1.620 + if ((c=aDirName.Length())>20)
1.621 + test.Printf(_L("%u char name\n"),c);
1.622 + else
1.623 + test.Printf(_L("\"%S\"\n"),&aDirName);
1.624 + if ((c=TheFs.MkDirAll(aDirName))!=res)
1.625 + Error2(_L("Make directory 1"),c, line);
1.626 + if (res==FALSE)
1.627 + {
1.628 + TParse parse;
1.629 + c=TheFs.Parse(aDirName,parse);
1.630 + test(c==KErrNone);
1.631 + buf=parse.Path();
1.632 + buf.Append(_L("*"));
1.633 + if (buf.Length()<=64)
1.634 + {
1.635 + test.Printf(_L("Open dir...\n"));
1.636 + if ((c=gDir.Open(TheFs,buf,KEntryAttMaskSupported))!=KErrNone)
1.637 + Error2(_L("Directory open 1"),c, line);
1.638 + gDataBuf[0]=0;
1.639 + if ((c=gDir.Read(gFileEntry))!=EofErr)
1.640 + {
1.641 + test.Printf(_L("buf=\"%S\"\n"),&gFileEntry.iName);
1.642 + Error2(_L("Directory read"),c, line);
1.643 + }
1.644 + gDir.Close();
1.645 + }
1.646 + buf=aDirName;
1.647 + l=buf.Length();
1.648 + FOREVER
1.649 + {
1.650 + test.Printf(_L("Delete \"%S\"\n"),&buf);
1.651 + if ((c=TheFs.RmDir(buf))!=KErrNone)
1.652 + Error2(_L("Delete directory"),c, line);
1.653 + while (--l)
1.654 + {
1.655 + if (buf[l]=='\\')
1.656 + {
1.657 + buf.SetLength(l);
1.658 + if (buf.LocateReverse('\\')==0)
1.659 + return;
1.660 + break;
1.661 + }
1.662 + }
1.663 + if (l == 0)
1.664 + break;
1.665 + }
1.666 + }
1.667 + }
1.668 +
1.669 +#if defined(_UNICODE)
1.670 +LOCAL_C void TestMakeDirLine(const TDesC8& aDirName, TInt res, TInt line)
1.671 +//
1.672 +// Defined to cope with all the instances of testMakeDir(gDataBuf,...)
1.673 +//
1.674 +{
1.675 +
1.676 + TPtrC gDataBuf16((TText*)aDirName.Ptr(),gDataBuf.Size()/sizeof(TText8));
1.677 + // Not sizeof(TText16) since gDataBuf is a TBuf*!
1.678 + TestMakeDirLine(gDataBuf16, res, line);
1.679 +}
1.680 +#endif
1.681 +
1.682 +#ifdef TEST_MEDIA
1.683 +LOCAL_C void testMedia(const TDesC& instructions,TInt anErr)
1.684 +//
1.685 +//
1.686 +//
1.687 + {
1.688 +
1.689 + TBuf<0x40> errBuf;
1.690 + TInt openErr;
1.691 + TInt c;
1.692 +// p_errs(&errBuf[0],anErr);
1.693 + pathBuf=fBuf;
1.694 + pathBuf.SetLength(7);
1.695 + test.Printf(_L("Test %S\n"),&errBuf);
1.696 + test.Printf(_L("%S %S\n"),&instructions,&pathBuf);
1.697 + p_getch();
1.698 + openErr=anErr;
1.699 + if (anErr==WriteProtectErr)
1.700 + openErr=0;
1.701 + if ((c=gFile.Open(TheFs,fBuf,P_FDIR))!=openErr)
1.702 + Error(_L("Directory open 100"),c);
1.703 + if (openErr==KErrNone)
1.704 + {
1.705 + if (c=gFile.Close())
1.706 + Error(_L("Close 100"),c);
1.707 + }
1.708 + gNameBuf.SetLength(0);
1.709 + if ((c=gFile.Open(TheFs,gNameBuf,P_FUNIQUE|EFileStream))!=anErr)
1.710 + Error(_L("Create unique 100"),c);
1.711 + if (anErr==0)
1.712 + {
1.713 + if (c=gFile.Close())
1.714 + Error(_L("Close 100"),c);
1.715 + }
1.716 + }
1.717 +#endif
1.718 +
1.719 +GLDEF_C void CallTestsL()
1.720 +//
1.721 +// Do All tests
1.722 +//
1.723 + {
1.724 + TInt c;
1.725 + TInt i,count;
1.726 + TInt pos;
1.727 + TInt64 seed;
1.728 + TInt attrib,mask;
1.729 + TTime saveTime;
1.730 + TInt testSize;
1.731 +
1.732 + CreateTestDirectory(_L("\\F32-TST\\BGEN\\"));
1.733 +// if (p_date()<MINIMUM_DATE)
1.734 +// p_sdate(MINIMUM_DATE);
1.735 +
1.736 + seed=(TInt64)1732;
1.737 + fBuf=gSessionPath;
1.738 + pathBuf=fBuf;
1.739 + pathBuf.Append('*');
1.740 + testDir(pathBuf);
1.741 +// testDir(_L("Z:")); // Session Path gets added -> KErrPathNotFound
1.742 +// testDir(_L("Z:*")); // Session Path gets added -> KErrPathNotFound
1.743 +// testDir(_L("Z:*.*")); // Session Path gets added -> KErrPathNotFound
1.744 + testDir(_L("Z:\\"));
1.745 + testDir(_L("Z:\\*"));
1.746 + testDir(_L("Z:\\*.*"));
1.747 +
1.748 + test.Printf(_L("Test names containing '\\'\n"));
1.749 + if ((c=gFile.Create(TheFs,_L("Q\\ZZZ"),EFileWrite))!=NameErr)
1.750 + Error(_L("Create 1"),c);
1.751 +
1.752 + test.Printf(_L("Test create in non-exist directory\n"));
1.753 + if ((c=gFile.Create(TheFs,_L("\\Q1DDX\\ZZZ"),EFileWrite))!=DirErr)
1.754 + Error(_L("Create 2"),c);
1.755 +
1.756 + test.Printf(_L("Test filenames starting with '.'\n"));
1.757 + if ((c=gFile.Create(TheFs,_L("\\.ZZZ"),EFileWrite))!=KErrNone) // ****** NameErr)
1.758 + Error(_L("Create 3"),c);
1.759 + gFile.Close();
1.760 + if ((c=TheFs.Delete(_L("\\.ZZZ")))!=KErrNone)
1.761 + Error(_L("Delete 3"),c);
1.762 +
1.763 + test.Printf(_L("Test filenames starting with 05/E5\n"));
1.764 + gNameBuf.SetLength(5);
1.765 + gNameBuf[0]=0xE5;
1.766 + gNameBuf[1]='X';
1.767 + gNameBuf[2]='X';
1.768 + gNameBuf[3]='X';
1.769 + gNameBuf[4]=0x00;
1.770 + gNameBuf.SetLength(4);
1.771 + if ((c=gFile.Replace(TheFs,gNameBuf,EFileWrite))!=KErrNone)
1.772 + Error(_L("Replace 4"),c);
1.773 + gFile.Close();
1.774 + if ((c=gFile.Open(TheFs,gNameBuf,EFileRead))!=KErrNone)
1.775 + Error(_L("Open 4"),c);
1.776 + gFile.Close();
1.777 +
1.778 +// *************** Silly filename stuff rightly disallowed by NT
1.779 +// gNameBuf.SetLength(5);
1.780 +// gNameBuf[0]=0x05;
1.781 +// gNameBuf[1]='Y';
1.782 +// gNameBuf[2]='Y';
1.783 +// gNameBuf[3]='Y';
1.784 +// gNameBuf[4]=0x00; // Zero terminator gets lost by VFAT
1.785 +// if ((c=gFile.Replace(TheFs,gNameBuf,EFileWrite))!=KErrNone)
1.786 +// Error(_L("Create 5"),c);
1.787 +// gFile.Close();
1.788 +// gNameBuf[0]=0xE5;
1.789 +// if ((c=gFile.Open(TheFs,gNameBuf,EFileRead))!=KErrNone)
1.790 +// Error(_L("Open 5"),c);
1.791 +// gFile.Close();
1.792 +//
1.793 +
1.794 +//
1.795 +//#ifdef TEST_MEDIA
1.796 +// if (fBuf[5]!='B')
1.797 +// goto skipMediaTest;
1.798 +// testMedia(_L("OPEN DOOR ON"),NotReadyErr);
1.799 +// testMedia(_L("INSERT CORRUPT RAM PACK (WRITE ENABLED) INTO"),CorruptMediaErr);
1.800 +// testMedia(_L("INSERT CORRUPT RAM PACK (WRITE PROTECTED) INTO"),CorruptMediaErr);
1.801 +// testMedia(_L("INSERT CORRUPT FLASH PACK (WRITE ENABLED) INTO"),CorruptMediaErr);
1.802 +// testMedia(_L("INSERT CORRUPT FLASH PACK (WRITE PROTECTED) INTO"),CorruptMediaErr);
1.803 +//#ifdef FULL_TEST
1.804 +// testMedia(_L("INSERT UNKNOWN MEDIA INTO"),UnknownErr);
1.805 +//#endif
1.806 +// testMedia(_L("INSERT GOOD RAM PACK (WRITE PROTECTED) INTO"),WriteProtectErr);
1.807 +// if ((c=gFile.Open(TheFs,fBuf,P_FFORMAT))!=WriteProtectErr)
1.808 +// Error(_L("Format RAM write protect"),c);
1.809 +// testMedia(_L("INSERT GOOD FLASH PACK (WRITE PROTECTED) INTO"),WriteProtectErr);
1.810 +// if ((c=gFile.Open(TheFs,fBuf,P_FFORMAT))!=WriteProtectErr)
1.811 +// Error(_L("Format FLASH write protect"),c);
1.812 +// testMedia(_L("INSERT GOOD PACK (WRITE ENABLED) INTO"),0);
1.813 +//
1.814 +//skipMediaTest:
1.815 +//#endif // TEST_MEDIA //
1.816 +//
1.817 +
1.818 +// Test update is assumed for unique //
1.819 +
1.820 + testUnique(EFileStream);
1.821 + testUnique(EFileStreamText);
1.822 + testDelete();
1.823 + testRename();
1.824 + test.Printf(_L("Test get file info\n"));
1.825 +// testFileInfo(_L("*.*"),NameErr); ********** Allowed (?)
1.826 + testFileInfo(_L(""),KErrNone); // NameErr);
1.827 + testFileInfo(_L("\\"),NameErr);
1.828 + testFileInfo(_L("."),NameErr);
1.829 + testFileInfo(_L(".."),NameErr);
1.830 + testFileInfo(_L("a.1234"),KErrNotFound); // ********* NameErr);
1.831 + testFileInfo(_L("a23456789"),KErrNotFound); // ********* NameErr);
1.832 + testFileInfo(_L(".a"),KErrNotFound); // ********** NameErr);
1.833 + testFileInfo(_L("?"),NameErr);
1.834 + testFileInfo(_L("NOEXIST"),NotExistsErr);
1.835 + testFileInfo(_L("\\NODIR\\NAME"),DirErr);
1.836 + testFileInfo(_L("L:\\NAME"),DeviceErr);
1.837 + gNameBuf.SetLength(0);
1.838 + if ((c=gFile.Temp(TheFs,gNameBuf,gNameOut,EFileStream))!=KErrNone)
1.839 + Error(_L("Open 1.1"),c);
1.840 + testFileInfo(gNameOut,FALSE); // Not locked //
1.841 + gFile.Close();
1.842 + testFileInfo(gNameOut,FALSE);
1.843 + if ((c=TheFs.Delete(gNameOut))!=KErrNone)
1.844 + Error(_L("Delete"),c);
1.845 +
1.846 + test.Printf(_L("Test get device info\n"));
1.847 + testDeviceInfo(_L(""),FALSE); // NULL is current device //
1.848 + testDeviceInfo(_L("L:"),DeviceErr);
1.849 + testDeviceInfo(_L("Z:"),FALSE);
1.850 + testDeviceInfo(fBuf,FALSE);
1.851 +
1.852 +
1.853 +// test.Printf(_L("Test get node info\n"));
1.854 +// testNodeInfo(_L("LOC::"),P_FSYSTYPE_HIER,FALSE);
1.855 +// testNodeInfo(_L("Z:"),P_FSYSTYPE_FLAT,FALSE);
1.856 +// testNodeInfo(_L("LOC:"),P_FSYSTYPE_HIER,FALSE);
1.857 +// testNodeInfo(_L("LOC"),P_FSYSTYPE_HIER,FALSE);
1.858 +// testNodeInfo(_L("*"),P_FSYSTYPE_HIER,FALSE);
1.859 +// testNodeInfo(_L(""),P_FSYSTYPE_HIER,FALSE);
1.860 +// testNodeInfo(_L("?"),P_FSYSTYPE_HIER,FALSE);
1.861 +// testNodeInfo(_L("FRED"),P_FSYSTYPE_HIER,FALSE);
1.862 +// testNodeInfo(_L("FRED::"),P_FSYSTYPE_HIER,FALSE);
1.863 +// testNodeInfo(_L("....."),P_FSYSTYPE_HIER,FALSE);
1.864 +// testNodeInfo(_L("LOC::zzzzzzzzzzzzzzzzzzzzzzzzz"),P_FSYSTYPE_HIER,FALSE);
1.865 +// testNodeInfo(_L("LOC::\\"),P_FSYSTYPE_HIER,FALSE);
1.866 +// testNodeInfo(_L("XXX::"),0,E_GEN_FSYS);
1.867 +// testNodeInfo(_L("REM::"),0,E_GEN_FSYS);
1.868 +// testNodeInfo(_L("...::"),0,E_GEN_FSYS);
1.869 +
1.870 +// testFileInfo(_L("Z:SYS$WSRV.IMG"),FALSE);
1.871 +// testFileInfo(_L("Z:\\SYS$WSRV.IMG"),NameErr); // \ not allowed - no path //
1.872 +// testFileInfo(_L("Z:*"),FALSE); // Z: allows *'s ! //
1.873 +// testFileInfo(_L("Z:SYS$WSRV."),NotExistsErr);
1.874 +// testFileInfo(_L("XXX::"),NoFileSystemErr);
1.875 + if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin))
1.876 + testFileInfo(_L("Z:\\Sys\\Bin\\ESHELL.EXE"),FALSE); // we now have paths //
1.877 + else
1.878 + testFileInfo(_L("Z:\\System\\Bin\\ESHELL.EXE"),FALSE); // we now have paths //
1.879 +// testFileInfo(_L("Z:*"),KErrPathNotFound); // session path gets inserted ,FALSE);
1.880 +// testFileInfo(_L("Z:SYS$WSRV."),NotExistsErr);
1.881 +// testFileInfo(_L("H:"),KErrBadName); // ************** NoFileSystemErr);
1.882 +
1.883 + test.Printf(_L("Test weird filenames\n"));
1.884 +// Test SPACES //
1.885 +
1.886 + testFileName(_L("A B"),KErrNone); // ******* NameErr);
1.887 + testFileName(_L(" AB"),KErrNone); // ******* NameErr);
1.888 + testFileName(_L(" AB "),KErrNone); // ******* NameErr);
1.889 + testFileName(_L(" AB"),KErrNone);
1.890 + testFileName(_L(" AB . cdef"),KErrNone);
1.891 + testFileName(_L(" AB . cdef "),KErrNone);
1.892 + testFileName(_L("A2345678 "),KErrNone); // ******* NameErr);
1.893 + testFileName(_L("A2345678.XY "),KErrNone); // ******* NameErr);
1.894 + testFileName(_L("A2345678.XYZ "),KErrNone); // ******* NameErr);
1.895 + testFileName(_L("A2345678 XYZ"),KErrNone); // ******* NameErr);
1.896 + testFileName(_L(" "),NameErr);
1.897 + testFileName(_L("\\A B\\NAME"),KErrPathNotFound); // ******* NameErr);
1.898 + testFileName(_L("\\ \\NAME"),NameErr);
1.899 + testFileName(_L("\\asdf\\qer\\ \\asdf\\NAME"),NameErr);
1.900 + testFileName(_L(" "),NameErr);
1.901 + testFileName(_L("C:\\asdf\\ "),NameErr);
1.902 +// Test short names //
1.903 + testFileName(_L(""),NameErr);
1.904 + testFileName(_L("\\"),NameErr);
1.905 + testFileName(_L("1"),FALSE);
1.906 + testFileName(_L(".1"),KErrNone); // ******* NameErr);
1.907 + testFileName(_L(".1"),KErrNone); // ******* NameErr);
1.908 + testFileName(_L("\\.1"),KErrNone); // ******* NameErr);
1.909 + testFileName(_L("1.1"),FALSE);
1.910 +// Test long names //
1.911 + testFileName(_L("12345678.123"),FALSE);
1.912 + testFileName(_L("123456789.123"),KErrNone); // ******* NameErr);
1.913 + testFileName(_L("12345678.1234"),KErrNone); // ******* NameErr);
1.914 + testFileName(_L("1.1234"),KErrNone); // ******* NameErr);
1.915 + testFileName(_L("123456789"),KErrNone); // ******* NameErr);
1.916 + gDataBuf.SetLength(256);
1.917 + gDataBuf.Fill('A',255);
1.918 + testFileName(gDataBuf,NameErr);
1.919 + gDataBuf.SetLength(257);
1.920 + gDataBuf.Fill('B',256);
1.921 + testFileName(gDataBuf,NameErr);
1.922 + gDataBuf.SetLength(258);
1.923 + gDataBuf.Fill('C',257);
1.924 + testFileName(gDataBuf,NameErr);
1.925 + gDataBuf.SetLength(4096);
1.926 + gDataBuf.Fill('D',4095);
1.927 + testFileName(gDataBuf,NameErr);
1.928 +// Test DOTS //
1.929 + testFileName(_L("A.X"),FALSE);
1.930 + testFileName(_L("A..X"),KErrNone); // ******* NameErr);
1.931 + testFileName(_L("A.........X"),KErrNone); // ******* NameErr);
1.932 + testFileName(_L("A."),FALSE);
1.933 + testFileName(_L(".X"),KErrNone); // ******* NameErr);
1.934 + testFileName(_L("."),NameErr);
1.935 + testFileName(_L(".."),NameErr);
1.936 +// testFileName(_L("..."),KErrNone); // NameErr); // !!! ********* NT error KErrAccessDenied (?)
1.937 + testFileName(_L("\\a.x\\NAME"),DirErr); // DirErr == KErrPathNotFound
1.938 + testFileName(_L("\\a..x\\NAME"),DirErr); // ******** NameErr);
1.939 + testFileName(_L("\\.\\NAME"),NameErr);
1.940 + testFileName(_L("\\..\\NAME"),NameErr);
1.941 +// testFileName(_L("\\...\\NAME"),KErrPathNotFound); // ******** NameErr); // !! NT treats ... as .. ??
1.942 +// Test WILD CARDS //
1.943 + testFileName(_L("*.*"),NameErr);
1.944 + testFileName(_L("*"),NameErr);
1.945 + testFileName(_L("\\*"),NameErr);
1.946 + testFileName(_L("?"),NameErr);
1.947 + testFileName(_L("\\?"),NameErr);
1.948 + testFileName(_L("\\A?B\\NAME"),NameErr);
1.949 + testFileName(_L("\\A*B\\NAME"),NameErr);
1.950 + testFileName(_L("\\*\\NAME"),NameErr);
1.951 + testFileName(_L("\\********.***\\NAME"),NameErr);
1.952 + testFileName(_L("A?X"),NameErr);
1.953 +
1.954 + test.Printf(_L("Test set volume name\n"));
1.955 +// New behaviour: SetVolumeName accepts any string < 12 chars
1.956 +// No modifications are made on the string.
1.957 +#if defined(__WINS__)
1.958 + TInt ret=TheFs.SetVolumeLabel(_L("TEST"),KDefaultDrive);
1.959 + if(ret==KErrNotSupported||ret==KErrAccessDenied)
1.960 + {
1.961 + test.Printf(_L("Error: Cannot set volume label on substed drive\n"));
1.962 + //test.Getch();
1.963 + }
1.964 + else
1.965 +#endif
1.966 + {
1.967 + testVolumeName(_L("TESTNAME.VOL"),KErrBadName); // 12 chars - too long for volume label
1.968 + testVolumeName(_L("TESTNAME"),FALSE); // OK for 8 bit - too long for UNICODE
1.969 + testVolumeName(_L("PQRSTUVWXYZ"),FALSE); // just uses the first 5 characters
1.970 + testVolumeName(_L("ABCDE"),FALSE);
1.971 + testVolumeName(_L("FGHIJK"),FALSE);
1.972 + testVolumeName(_L(""),FALSE);
1.973 + testVolumeName(_L(""),FALSE);
1.974 + testVolumeName(_L("\\"),FALSE);
1.975 + gNameBuf.SetLength(0);
1.976 + if ((c=gFile.Temp(TheFs,gNameBuf,gNameOut,EFileStream))!=KErrNone)
1.977 + Error(_L("Open 60"),c);
1.978 + testVolumeName(_L("TEST_NAME"),FALSE); // Check not locked
1.979 + gFile.Close();
1.980 + if ((c=TheFs.Delete(gNameOut))!=KErrNone)
1.981 + Error(_L("Delete"),c);
1.982 + testVolumeName(_L("voL1"),FALSE);
1.983 + testVolumeName(_L("\\vol1"),FALSE);
1.984 + testVolumeName(_L("\\12345678.123"),KErrBadName);
1.985 + testVolumeName(_L("\\123456.123"),FALSE);
1.986 + testVolumeName(_L("\\vol1\\"),KErrNone);
1.987 + testVolumeName(_L("."),KErrBadName); // Bug fix SW1-728 to prevent illegal characters
1.988 + testVolumeName(_L(".."),KErrBadName); // in the volume name
1.989 + testVolumeName(_L("A."),KErrBadName);
1.990 + if (!IsTestingLFFS())
1.991 + { // ???
1.992 + testVolumeName(_L("!\"\x9C$%^&@.(){"),KErrBadName);
1.993 + testVolumeName(_L("!\"\x9C$%^&@("),KErrBadName);
1.994 + }
1.995 + testVolumeName(_L("*.*"),KErrBadName); // Wild cards not allowed
1.996 + testVolumeName(_L("?.?"),KErrBadName);
1.997 + testVolumeName(_L("????????.???"),KErrBadName);
1.998 + testVolumeName(_L("????????.??"),KErrBadName);
1.999 + testVolumeName(_L("ABC>DEF"),KErrBadName);
1.1000 + testVolumeName(_L("ABC<DEF"),KErrBadName);
1.1001 + testVolumeName(_L("ABC|DEF"),KErrBadName);
1.1002 + testVolumeName(_L("ABC/DEF"),KErrBadName);
1.1003 + testVolumeName(_L("ABC\"DEF"),KErrBadName);
1.1004 + testVolumeName(_L("ABC*DEF"),KErrBadName);
1.1005 + testVolumeName(_L("ABC:DEF"),KErrBadName);
1.1006 + testVolumeName(_L("ABC?DEF"),KErrBadName);
1.1007 + testVolumeName(_L("ABC\\DEF"),KErrBadName);
1.1008 + testVolumeName(_L("ABCDEFGHIJKLMNOPQRSTUVWXYZ"),KErrBadName); // Too long
1.1009 + testVolumeName(_L("VOLUME1"),FALSE); // Too long in UNICODE
1.1010 + testVolumeName(_L("Z:VOLUME1"),KErrAccessDenied);
1.1011 + }
1.1012 +
1.1013 + test.Printf(_L("Test make directory\n"));
1.1014 +
1.1015 +// Test path
1.1016 + testMakeDir(_L("\\A2345678.A23\\NAME"),FALSE);
1.1017 + testMakeDir(_L("\\A23456789.A23\\NAME"),KErrNone); // ******** NameErr);
1.1018 + testMakeDir(_L("\\A2345678.A234\\NAME"),KErrNone); // ******** NameErr);
1.1019 + testMakeDir(_L("\\A.1234\\NAME"),KErrNone); // ********* NameErr);
1.1020 + testMakeDir(_L("\\A2345678\\NAME"),FALSE);
1.1021 + testMakeDir(_L("\\A23456789\\NAME"),KErrNone); // ******** NameErr);
1.1022 + testMakeDir(_L("\\A.X\\NAME"),FALSE);
1.1023 + testMakeDir(_L("\\A..X\\NAME"),KErrNone); // ******** NameErr);
1.1024 + testMakeDir(_L("\\A.\\NAME"),NameErr);
1.1025 + testMakeDir(_L("\\.X\\NAME"),KErrNone); // ******** NameErr);
1.1026 + testMakeDir(_L("\\.\\NAME"),NameErr);
1.1027 + testMakeDir(_L("\\..\\NAME"),NameErr);
1.1028 + testMakeDir(_L("\\\\NAME"),NameErr);
1.1029 + testMakeDir(_L("\\\\"),NameErr);
1.1030 + testMakeDir(_L("\\A\\A2\\A23\\a2345678\\a2345678.\\a2345678.1\\a2345678.123"),NameErr);
1.1031 + testMakeDir(_L("\\A\\A2\\A23\\a2345678\\a2345678.\\a2345678.1\\a2345678..123"),NameErr); // ******* NameErr);
1.1032 + testMakeDir(_L("\\A\\A2\\A23\\a2345678\\a2345678.\\a2345678.1\\a2345678.1234"),NameErr); // ******* NameErr);
1.1033 + gDataBuf.SetLength(256);
1.1034 + gDataBuf.Fill('V',255);
1.1035 + testMakeDir(gDataBuf,NameErr);
1.1036 + gDataBuf.SetLength(257);
1.1037 + gDataBuf.Fill('W',256);
1.1038 + testMakeDir(gDataBuf,NameErr);
1.1039 + gDataBuf.SetLength(258);
1.1040 + gDataBuf.Fill('X',257);
1.1041 + testMakeDir(gDataBuf,NameErr);
1.1042 + gDataBuf.SetLength(259);
1.1043 + gDataBuf.Fill('Y',258);
1.1044 + testMakeDir(gDataBuf,NameErr);
1.1045 + gDataBuf.SetLength(4096);
1.1046 + gDataBuf.Fill('Z',4095);
1.1047 + testMakeDir(gDataBuf,NameErr);
1.1048 +
1.1049 +// Test names
1.1050 + testMakeDir(_L("A..X"),KErrAlreadyExists); // ******* NameErr);
1.1051 + testMakeDir(_L("\\A\\"),FALSE);
1.1052 + testMakeDir(_L("\\12345678.123\\"),FALSE);
1.1053 + testMakeDir(_L("\\.\\"),NameErr);
1.1054 + testMakeDir(_L("\\..\\"),NameErr);
1.1055 + testMakeDir(_L("\\X\\"),FALSE);
1.1056 + testMakeDir(_L("\\12345678.1234\\"),KErrNone); // ******* NameErr);
1.1057 + testMakeDir(_L("\\123456789\\"),KErrNone); // ******** NameErr);
1.1058 +// Test max levels
1.1059 + testMakeDir(_L("\\A\\B\\C\\D\\E\\F\\G\\H\\I\\J\\K\\L\\M\\N\\O\\P\\Q\\R\\S\\T\\U\\V\\W\\X\\Y\\Z"),FALSE);
1.1060 + testMakeDir(_L("\\00000000.000\\11111111.111\\22222222.222\\33333333.333\\45678901.3"),FALSE);
1.1061 + testMakeDir(_L("\\00000000.000\\11111111.111\\22222222.222\\33333333.333\\45678901.34"),FALSE);
1.1062 + testMakeDir(_L("\\00000000.000\\11111111.111\\22222222.222\\33333333.333\\45678901.345"),FALSE);
1.1063 + testMakeDir(_L("\\00000000.000\\11111111.111\\22222222.222\\33333333.333\\45678901.3\\xxxxxxxx.xxx"),FALSE);
1.1064 + testMakeDir(_L("\\00000000.000\\11111111.111\\22222222.222\\33333333.333\\45678901.34\\xxxxxxxx.xxx"),KErrNone); // ******* NameErr);
1.1065 + testMakeDir(_L("\\00000000.000\\11111111.111\\22222222.222\\33333333.333\\45678901.345\\xxxxxxxx.xxx"),KErrNone); // ******* NameErr);
1.1066 + testMakeDir(_L("\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\23"),FALSE);
1.1067 + testMakeDir(_L("\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\23456789.123"),FALSE);
1.1068 + testMakeDir(_L("\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\23\\5"),FALSE);
1.1069 + testMakeDir(_L("\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\23\\56789012.456"),FALSE);
1.1070 + testMakeDir(_L("\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\234\\6"),KErrNone); // ******** NameErr);
1.1071 + testMakeDir(_L("Z:\\ROMDIR\\"),KErrAccessDenied); // *********** NotSupportedErr);
1.1072 + test.Printf(_L("Test setEof to same length\n"));
1.1073 + gNameBuf.SetLength(0);
1.1074 + if ((c=gFile.Temp(TheFs,gNameBuf,gNameOut,EFileStream|P_FUPDATE))!=KErrNone)
1.1075 + Error(_L("Open 50"),c);
1.1076 + gFile.Close();
1.1077 + testSetEof(gNameOut,0L,FALSE); // should be no change //
1.1078 + testSetEof(gNameOut,1L,TRUE); // should be change //
1.1079 + testSetEof(gNameOut,1L,FALSE); // should be no change //
1.1080 + testSetEof(gNameOut,1L,FALSE);
1.1081 + if (fBuf[5]=='M')
1.1082 + testSize=650L; // No room on M: for 65536 ! //
1.1083 + else
1.1084 + testSize=65536L;
1.1085 + testSetEof(gNameOut,testSize,TRUE);
1.1086 + testSetEof(gNameOut,testSize,FALSE);
1.1087 + testSetEof(gNameOut,testSize+1L,TRUE);
1.1088 + testSetEof(gNameOut,testSize,TRUE);
1.1089 +
1.1090 + testSetEof(gNameOut,0L,TRUE);
1.1091 + testSetEof(gNameOut,0L,FALSE);
1.1092 + if ((c=TheFs.Delete(gNameOut))!=KErrNone)
1.1093 + Error(_L("Delete"),c);
1.1094 +
1.1095 + test.Printf(_L("Test read of zero bytes\n"));
1.1096 + gNameBuf.SetLength(0);
1.1097 +
1.1098 + if ((c=gFile.Temp(TheFs,gNameBuf,gNameOut,EFileStream|P_FUPDATE))!=KErrNone)
1.1099 + Error(_L("Open 60"),c);
1.1100 + if ((c=gFile.Read(gDataBuf,0))!=KErrNone) // ******** EofErr)
1.1101 + Error(_L("Read 61"),c);
1.1102 + if ((c=gFile.Read(gDataBuf,0))!=KErrNone) // ******** EofErr)
1.1103 + Error(_L("Read 62"),c);
1.1104 + if ((c=gFile.Write(gDataBuf,0))!=KErrNone)
1.1105 + Error(_L("Write 63"),c);
1.1106 + if ((c=gFile.Read(gDataBuf,0))!=KErrNone) // ******** EofErr)
1.1107 + Error(_L("Read 64"),c);
1.1108 + gFile.Close();
1.1109 + if ((c=gFile.Open(TheFs,gNameOut,EFileStream|P_FUPDATE|P_FRANDOM))!=KErrNone)
1.1110 + Error(_L("Open 70"),c);
1.1111 + if ((c=gFile.Read(gDataBuf,0))!=KErrNone) // ******** EofErr)
1.1112 + Error(_L("Read 71"),c);
1.1113 + gDataBuf.SetLength(1);
1.1114 + gDataBuf[0]=0xf0;
1.1115 + if ((c=gFile.Write(gDataBuf,1))!=KErrNone)
1.1116 + Error(_L("Write 72"),c);
1.1117 + if ((c=gFile.Read(gDataBuf,0))!=KErrNone) // ********* EofErr)
1.1118 + Error(_L("Read 73"),c);
1.1119 + pos=0L;
1.1120 + if ((c=gFile.Seek((TSeek)P_FABS,pos))!=KErrNone)
1.1121 + Error(_L("Seek 74"),c);
1.1122 + gDataBuf.SetLength(1);
1.1123 + gDataBuf[0]=0x83;
1.1124 + if ((c=gFile.Read(gDataBuf,0))!=KErrNone)
1.1125 + Error(_L("Read 75"),c);
1.1126 +// if (gDataBuf[0]!=0x83) *********** Read zeros the length of a buffer after a zero length read
1.1127 + if (gDataBuf.Length()!=0)
1.1128 + Error(_L("buffer 1 check"),0);
1.1129 + if ((c=gFile.Read(gDataBuf,0))!=KErrNone)
1.1130 + Error(_L("Read 76"),c);
1.1131 + if ((c=gFile.Read(gDataBuf,1))!=KErrNone || gDataBuf.Length()!=1)
1.1132 + Error(_L("Read 77"),c);
1.1133 + if (gDataBuf[0]!=0xf0)
1.1134 + Error(_L("buffer 1 check"),0);
1.1135 + if ((c=gFile.Read(gDataBuf,0))!=KErrNone) // ******** EofErr)
1.1136 + Error(_L("Read 78"),c);
1.1137 + if ((c=gFile.Read(gDataBuf,16384))!=KErrNone) // ******* EofErr)
1.1138 + Error(_L("Read 79"),c);
1.1139 + gFile.Close();
1.1140 + if ((c=TheFs.Delete(gNameOut))!=KErrNone)
1.1141 + Error(_L("Delete"),c);
1.1142 +
1.1143 + test.Printf(_L("Test write of zero bytes\n"));
1.1144 + gNameBuf.SetLength(0);
1.1145 + if ((c=gFile.Temp(TheFs,gNameBuf,gNameOut,EFileStream|P_FUPDATE))!=KErrNone)
1.1146 + Error(_L("Open 50"),c);
1.1147 + gFile.Close();
1.1148 +// ********** Error(_L("Close"),c); close has no return value
1.1149 + gDataBuf.SetLength(16384);
1.1150 +
1.1151 + testWrite(gNameOut,0,0L,FALSE); // should be no change //
1.1152 + testWrite(gNameOut,1,1L,TRUE); // should be change //
1.1153 + testWrite(gNameOut,0,1L,FALSE);
1.1154 + testWrite(gNameOut,0,1L,FALSE);
1.1155 + testWrite(gNameOut,16384,16384L,TRUE);
1.1156 + testWrite(gNameOut,0,16384L,FALSE);
1.1157 + testWrite(gNameOut,16383,16384L,TRUE);
1.1158 +
1.1159 +
1.1160 + if ((c=TheFs.Delete(gNameOut))!=KErrNone)
1.1161 + Error(_L("Delete"),c);
1.1162 +
1.1163 + test.Printf(_L("Test ReadOnly files\n"));
1.1164 + gNameBuf.SetLength(0);
1.1165 + if ((c=gFile.Create(TheFs,_L("TEST1.TMP"),EFileStream|P_FUPDATE))!=KErrNone)
1.1166 + Error(_L("Create 40"),c);
1.1167 + gFile.Close();
1.1168 + if ((c=gFile.Temp(TheFs,gNameBuf,gNameOut,EFileStream|P_FUPDATE))!=KErrNone)
1.1169 + Error(_L("Open 40"),c);
1.1170 + mask=0;
1.1171 + attrib=KEntryAttReadOnly; // Remove writable //
1.1172 + if ((c=TheFs.SetAtt(gNameOut,attrib,mask))!=LockedErr)
1.1173 + Error(_L("TheFs.SetAtt not locked"),c);
1.1174 + gFile.Close();
1.1175 + if ((c=TheFs.SetAtt(gNameOut,attrib,mask))!=KErrNone)
1.1176 + Error(_L("Att 41"),c);
1.1177 + if ((c=gFile.Open(TheFs,gNameOut,EFileStream|P_FUPDATE))!=AccessErr)
1.1178 + Error(_L("Open 41"),c);
1.1179 + if ((c=gFile.Open(TheFs,gNameOut,EFileStream))!=KErrNone)
1.1180 + Error(_L("Open 42"),c);
1.1181 + if ((c=gFileErr.Open(TheFs,gNameOut,EFileStream))!=LockedErr)
1.1182 + Error(_L("Open 43"),c);
1.1183 + if ((c=TheFs.Rename(_L("TEST1.TMP"),gNameOut))!=ExistsErr)
1.1184 + Error(_L("Rename 43.1"),c);
1.1185 + if ((c=gFileErr.Create(TheFs,gNameOut,EFileStream))!=ExistsErr) // LockedErr)
1.1186 + Error(_L("Open 44"),c);
1.1187 + if ((c=gFileErr.Replace(TheFs,gNameOut,EFileStream))!=LockedErr)
1.1188 + Error(_L("Open 45"),c);
1.1189 + gFile.Close();
1.1190 + if ((c=gFile.Create(TheFs,gNameOut,EFileStream))!=ExistsErr)
1.1191 + Error(_L("Create 46"),c);
1.1192 + if ((c=gFile.Replace(TheFs,gNameOut,EFileStream))!=AccessErr)
1.1193 + Error(_L("Replace 47"),c);
1.1194 + if ((c=gFile.Create(TheFs,_L("FILE1.TMP"),EFileStream))!=KErrNone)
1.1195 + Error(_L("Create 48"),c);
1.1196 + if ((c=TheFs.Rename(_L("FILE1.TMP"),_L("FILE2.TMP")))!=LockedErr)
1.1197 + Error(_L("Rename 49"),c);
1.1198 + gFile.Close();
1.1199 + if ((c=TheFs.Rename(_L("FILE1.TMP"),_L("FILE2.TMP")))!=KErrNone)
1.1200 + Error(_L("Rename 50"),c);
1.1201 + if ((c=TheFs.Rename(_L("FILE2.TMP"),gNameOut))!=ExistsErr)
1.1202 + Error(_L("Rename 51"),c);
1.1203 + if ((c=TheFs.Delete(gNameOut))!=AccessErr)
1.1204 + Error(_L("Delete"),c);
1.1205 + mask=KEntryAttReadOnly;
1.1206 + attrib=0;
1.1207 + if ((c=TheFs.SetAtt(gNameOut,attrib,mask))!=KErrNone)
1.1208 + Error(_L("Att 42"),c);
1.1209 + if ((c=TheFs.Delete(gNameOut))!=KErrNone)
1.1210 + Error(_L("Delete 1"),c);
1.1211 + if ((c=TheFs.Delete(_L("TEST1.TMP")))!=KErrNone)
1.1212 + Error(_L("Delete 2"),c);
1.1213 + if ((c=TheFs.Delete(_L("FILE2.TMP")))!=KErrNone)
1.1214 + Error(_L("Delete 3"),c);
1.1215 +
1.1216 + test.Printf(_L("Test write/setEof without UPDATE\n"));
1.1217 + if ((c=gFile.Create(TheFs,_L("B_GEN.001"),EFileStream))!=KErrNone)
1.1218 + Error(_L("Open 30"),c);
1.1219 + gFile.Close();
1.1220 + if ((c=gFile.Open(TheFs,_L("B_GEN.001"),EFileStream))!=KErrNone)
1.1221 + Error(_L("Open 30"),c);
1.1222 + pos=1L;
1.1223 + if ((c=gFile.SetSize(pos))!=ReadOnlyErr)
1.1224 + Error(_L("Set EOF 30"),c);
1.1225 + if ((c=TheFs.Entry(_L("B_GEN.001"),gFileEntry))!=KErrNone)
1.1226 + Error(_L("File info 30"),c);
1.1227 + if (gFileEntry.iSize!=0L)
1.1228 + Error(_L("Size check 30"),0);
1.1229 + if ((c=gFile.Write(gDataBuf,1))!=ReadOnlyErr)
1.1230 + Error(_L("Write 30"),c);
1.1231 + if ((c=TheFs.Entry(_L("B_GEN.001"),gFileEntry))!=KErrNone)
1.1232 + Error(_L("File info 31"),c);
1.1233 + if (gFileEntry.iSize!=0L)
1.1234 + Error(_L("Size check 31"),0);
1.1235 + gFile.Close();
1.1236 + if ((c=TheFs.Entry(_L("B_GEN.001"),gFileEntry))!=KErrNone)
1.1237 + Error(_L("File info 32"),c);
1.1238 + if (gFileEntry.iSize!=0L)
1.1239 + Error(_L("Size check 32"),0);
1.1240 + if ((c=TheFs.Delete(_L("B_GEN.001")))!=KErrNone)
1.1241 + Error(_L("Delete"),c);
1.1242 +
1.1243 +
1.1244 + test.Printf(_L("Test dir entries are written out\n"));
1.1245 + gNameBuf.SetLength(0);
1.1246 + if ((c=gFile.Temp(TheFs,gNameBuf,gNameOut,EFileStream|P_FRANDOM))!=KErrNone)
1.1247 + Error(_L("Open 20"),c);
1.1248 + if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone)
1.1249 + Error(_L("File info 0"),c);
1.1250 + if ((gFileEntry.iAtt & P_FAMOD)==0)
1.1251 + Error(_L("Status 20"),0);
1.1252 + test.Printf(_L("Size=%u\n"),gFileEntry.iSize);
1.1253 + if (gFileEntry.iSize!=0L)
1.1254 + Error(_L("Size check 0"),0);
1.1255 + saveTime=gFileEntry.iModified;
1.1256 + test.Printf(_L("Wait 3 seconds...\n"));
1.1257 + User::After(3000000L);
1.1258 + gDataBuf.SetLength(1);
1.1259 + if ((c=gFile.Write(gDataBuf,1))!=KErrNone)
1.1260 + Error(_L("Write 1"),c);
1.1261 + if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone)
1.1262 + Error(_L("File info 1"),c);
1.1263 + test.Printf(_L("Size=%u\n"),gFileEntry.iSize);
1.1264 + if (gFileEntry.iSize!=1L)
1.1265 + Error(_L("Size check 1"),0);
1.1266 + if (gFileEntry.iModified==saveTime)
1.1267 + Error(_L("Time update"),0);
1.1268 + gDataBuf.SetLength(16384);
1.1269 + if ((c=gFile.Write(gDataBuf,16384))!=KErrNone)
1.1270 + Error(_L("Write 2"),c);
1.1271 + if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone)
1.1272 + Error(_L("File info 2"),c);
1.1273 + test.Printf(_L("Size=%u\n"),gFileEntry.iSize);
1.1274 + if (gFileEntry.iSize!=16385L)
1.1275 + Error(_L("Size check 2"),0);
1.1276 + pos=0L;
1.1277 + if ((c=gFile.Seek((TSeek)P_FABS,pos))!=KErrNone)
1.1278 + Error(_L("Seek 0"),c);
1.1279 + if ((c=gFile.Write(gDataBuf,1))!=KErrNone)
1.1280 + Error(_L("Write 3"),c);
1.1281 + if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone)
1.1282 + Error(_L("File info 3"),c);
1.1283 + test.Printf(_L("Size=%u\n"),gFileEntry.iSize);
1.1284 + if (gFileEntry.iSize!=16385L)
1.1285 + Error(_L("Size check 3"),0);
1.1286 + pos=0L;
1.1287 + if ((c=gFile.Seek((TSeek)P_FABS,pos))!=KErrNone)
1.1288 + Error(_L("Seek 1"),c);
1.1289 + if ((c=gFile.Write(gDataBuf,16384))!=KErrNone)
1.1290 + Error(_L("Write 4"),c);
1.1291 + if ((c=gFile.Write(gDataBuf,1))!=KErrNone)
1.1292 + Error(_L("Write 5"),c);
1.1293 + if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone)
1.1294 + Error(_L("File info 4"),c);
1.1295 + test.Printf(_L("Size=%u\n"),gFileEntry.iSize);
1.1296 + if (gFileEntry.iSize!=16385L)
1.1297 + Error(_L("Size check 4"),0);
1.1298 + if ((c=gFile.Write(gDataBuf,1))!=KErrNone)
1.1299 + Error(_L("Write 6"),c);
1.1300 + if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone)
1.1301 + Error(_L("File info 5"),c);
1.1302 + test.Printf(_L("Size=%u\n"),gFileEntry.iSize);
1.1303 + if (gFileEntry.iSize!=16386L)
1.1304 + Error(_L("Size check 5"),0);
1.1305 + for (i=0;i<50;i++)
1.1306 + {
1.1307 + TInt r=(Math::Rand(seed) & 0x7fff);
1.1308 + test.Printf(_L("%u) Set eof to %u\n"),i,r);
1.1309 + pos=r;
1.1310 + if ((c=gFile.SetSize(pos))!=KErrNone)
1.1311 + Error(_L("Set EOF 1"),c);
1.1312 + if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone)
1.1313 + Error(_L("File info 6"),c);
1.1314 + if (gFileEntry.iSize!=r)
1.1315 + Error(_L("Size check 6"),i);
1.1316 + }
1.1317 + pos=0L;
1.1318 + if ((c=gFile.SetSize(pos))!=KErrNone)
1.1319 + Error(_L("Set EOF 2"),c);
1.1320 + if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone)
1.1321 + Error(_L("File info 7"),c);
1.1322 + if (gFileEntry.iSize!=0L)
1.1323 + Error(_L("Size check 7"),0);
1.1324 + gFile.Close();
1.1325 + if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone)
1.1326 + Error(_L("File info 8"),c);
1.1327 + if (gFileEntry.iSize!=0L)
1.1328 + Error(_L("Size check 7"),0);
1.1329 + mask=P_FAMOD;
1.1330 + attrib=0;
1.1331 + if ((c=TheFs.SetAtt(gNameOut,attrib,mask))!=KErrNone)
1.1332 + Error(_L("Att 20"),c);
1.1333 +
1.1334 +//
1.1335 + if ((c=gFile.Open(TheFs,gNameOut,EFileStream|P_FUPDATE|P_FRANDOM))!=KErrNone)
1.1336 + Error(_L("Open 21"),c);
1.1337 + if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone)
1.1338 + Error(_L("File info 9"),c);
1.1339 + if (gFileEntry.iAtt & P_FAMOD)
1.1340 + Error(_L("Status 21"),0);
1.1341 + if ((c=gFile.Write(gDataBuf,0))!=KErrNone)
1.1342 + Error(_L("Write 21"),c);
1.1343 + if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone)
1.1344 + Error(_L("File info 9"),c);
1.1345 + if ((gFileEntry.iAtt & P_FAMOD)) // write 0 should not modify //
1.1346 + Error(_L("Status 22"),0);
1.1347 + gFile.Close();
1.1348 + mask=P_FAMOD;
1.1349 + attrib=0;
1.1350 + if ((c=TheFs.SetAtt(gNameOut,attrib,mask))!=KErrNone)
1.1351 + Error(_L("Att 20"),c);
1.1352 + if ((c=gFile.Open(TheFs,gNameOut,EFileStream|P_FUPDATE|P_FRANDOM))!=KErrNone)
1.1353 + Error(_L("Open 22"),c);
1.1354 + if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone)
1.1355 + Error(_L("File info 9"),c);
1.1356 + if (gFileEntry.iAtt & P_FAMOD)
1.1357 + Error(_L("Status 23"),0);
1.1358 + pos=0L;
1.1359 + if ((c=gFile.SetSize(pos))!=KErrNone) // no change //
1.1360 + Error(_L("Set EOF 21"),c);
1.1361 + if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone)
1.1362 + Error(_L("File info 9"),c);
1.1363 + if ((gFileEntry.iAtt & P_FAMOD))
1.1364 + Error(_L("Status 24"),0);
1.1365 + gFile.Close();
1.1366 + if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone)
1.1367 + Error(_L("File info 0"),c);
1.1368 + if ((c=gFile.Open(TheFs,gNameOut,EFileStream|P_FUPDATE|P_FRANDOM))!=KErrNone)
1.1369 + Error(_L("Open 23"),c);
1.1370 + saveTime=gFileEntry.iModified;
1.1371 + test.Printf(_L("Wait 3 seconds...\n"));
1.1372 + User::After(3000000L);
1.1373 + if ((c=gFile.Flush())!=KErrNone) // Should not alter time //
1.1374 + Error(_L("Flush 0"),c);
1.1375 + if (gFileEntry.iModified!=saveTime)
1.1376 + Error(_L("Flush new time"),0);
1.1377 + gFile.Close();
1.1378 + if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone)
1.1379 + Error(_L("File info 61"),c);
1.1380 + if (gFileEntry.iModified!=saveTime)
1.1381 + Error(_L("Close new time"),0);
1.1382 + if ((c=gFile.Open(TheFs,gNameOut,EFileStream|P_FUPDATE|P_FRANDOM))!=KErrNone)
1.1383 + Error(_L("Open 24"),c);
1.1384 + if ((c=gFile.Write(gDataBuf,1))!=KErrNone)
1.1385 + Error(_L("Write 60"),c);
1.1386 + if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone)
1.1387 + Error(_L("File info 62"),c);
1.1388 + if (gFileEntry.iModified==saveTime)
1.1389 + Error(_L("Write new time 1"),0);
1.1390 + saveTime=gFileEntry.iModified;
1.1391 + test.Printf(_L("Wait 3 seconds...\n"));
1.1392 + User::After(3000000L);
1.1393 + if ((c=gFile.Flush())!=KErrNone) // Should alter time //
1.1394 + Error(_L("Flush 1"),c);
1.1395 + if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone)
1.1396 + Error(_L("File info 64"),c);
1.1397 + if (gFileEntry.iModified!=saveTime) // ==saveTime) // !!! Flush doesn't alter the time unless the file is modified
1.1398 + Error(_L("Flush new time 1"),0);
1.1399 + gFile.Close();
1.1400 + if ((c=TheFs.Delete(gNameOut))!=KErrNone)
1.1401 + Error(_L("Delete"),c);
1.1402 +
1.1403 + test.Printf(_L("Test set file date\n"));
1.1404 + gNameOut.SetLength(0);
1.1405 + if ((c=gFile.Temp(TheFs,gNameBuf,gNameOut,EFileStream))!=KErrNone)
1.1406 + Error(_L("Open 10"),c);
1.1407 + gFile.Close();
1.1408 + if ((c=gFile.Open(TheFs,gNameOut,EFileStream))!=KErrNone)
1.1409 + Error(_L("Open 10"),c); // Temp file is created as writable.
1.1410 + TTime fileTime(0);
1.1411 + if ((c=gFile.SetModified(fileTime))!=AccessErr) // LockedErr)
1.1412 + Error(_L("Set file date 10"),c);
1.1413 + gFile.Close();
1.1414 +
1.1415 +
1.1416 + for (i=0;i<DateTests;i++)
1.1417 + {
1.1418 +// TUint32 testSeconds[] =
1.1419 +// {
1.1420 +// 0L,
1.1421 +// 315532799L, 315532800L, 315532801L,315532802L,
1.1422 +// 0xfffffffeL,0xffffffffL,0x7fffffffL,
1.1423 +// 0x80000000L,0x80000001L
1.1424 +// };
1.1425 +// TUint32 checkSeconds[] =
1.1426 +// {
1.1427 +// 315532800L, 315532800L, 315532800L, 315532800L, 315532802L,
1.1428 +// 0xfffffffeL,0xfffffffeL,0x7ffffffeL,
1.1429 +// 0x80000000L,0x80000000L
1.1430 +// };
1.1431 +// TInt64 num64((TReal)(testSeconds[i]*1000000)); // !!! NT fails on dates < 1601
1.1432 +// TTime fileTime(num64);
1.1433 +// if ((c=TheFs.SetModified(gNameBuf,fileTime))!=KErrNone)
1.1434 +// Error(_L("Set file date 0"),c);
1.1435 +// if ((c=TheFs.Entry(gNameBuf,gFileEntry))!=KErrNone)
1.1436 +// Error(_L("File info 10"),c);
1.1437 +// num64=(TReal)checkSeconds[i]*1000000;
1.1438 +// if (gFileEntry.iModified.Int64()!=num64)
1.1439 +// Error(_L("Date check 0"),i);
1.1440 + }
1.1441 + if ((c=TheFs.Delete(gNameOut))!=KErrNone)
1.1442 + Error(_L("Delete 1"),c);
1.1443 + test.Printf(_L("Test format\n"));
1.1444 + gNameOut.SetLength(0);
1.1445 + if ((c=gFile.Temp(TheFs,gNameBuf,gNameOut,EFileStream))!=KErrNone)
1.1446 + Error(_L("Open 1"),c);
1.1447 + if ((c=gFormat.Open(TheFs,fBuf,EFullFormat,count))!=LockedErr)
1.1448 + Error(_L("Format lock check 1"),c);
1.1449 + if ((c=gFormat.Open(TheFs,fBuf,EQuickFormat,count))!=LockedErr)
1.1450 + Error(_L("Format lock check 2"),c);
1.1451 + gFile.Close();
1.1452 +
1.1453 + if ((c=gFormat.Open(TheFs,fBuf,EFullFormat,count))!=KErrNone)
1.1454 + {
1.1455 + if (c==LockedErr || c==AccessErr)
1.1456 + {
1.1457 + test.Printf(_L("Format: locked, no test\n"));
1.1458 + goto noFormat;
1.1459 + }
1.1460 + Error(_L("Format lock check"),c);
1.1461 + }
1.1462 +
1.1463 +// if ((c=p_read(chan2,&count,2))<0)
1.1464 +// {
1.1465 +// if (c==NotSupportedErr)
1.1466 +// {
1.1467 +// test.Printf(_L("Format: not supported, no test\n"));
1.1468 +// goto noFormatClose;
1.1469 +// }
1.1470 +// Error(_L("Read format count"),c);
1.1471 +// }
1.1472 +// for (i=1;;i++)
1.1473 +// {
1.1474 +// if ((c=g(chan2,&val,2))<0)
1.1475 +// {
1.1476 +// if (c==EofErr)
1.1477 +// break;
1.1478 +// Error(_L("Format"),c);
1.1479 +// }
1.1480 +// test.Printf(_L("\r%05u %05u\n"),i,val);
1.1481 +// }
1.1482 +// if ((i-1)!=count)
1.1483 +// Error(_L("Format count"),i);
1.1484 +// noFormatClose:
1.1485 +// if ((c=p_close(chan2))!=KErrNone)
1.1486 +// Error(_L("Close"),c);
1.1487 +noFormat:
1.1488 + gFormat.Close();
1.1489 + DeleteTestDirectory();
1.1490 +
1.1491 + }