sl@0: // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "t_server.h" sl@0: #include "t_chlffs.h" sl@0: sl@0: #ifdef __VC32__ sl@0: // Solve compilation problem caused by non-English locale sl@0: #pragma setlocale("english") sl@0: #endif sl@0: sl@0: GLDEF_D RTest test(_L("B_GEN")); sl@0: // sl@0: // File test - general test of local filing system routines sl@0: // (finishes with formating current device). sl@0: // Modified from BB's epoc test code sl@0: sl@0: #define MINIMUM_DATE (315532800L) sl@0: #define DateTests 10 sl@0: sl@0: // GLREF_D P_DEVICE p_file; sl@0: // GLREF_D P_DEVICE p_wind,p_screen,p_cons; sl@0: sl@0: GLDEF_D TBuf<0x100> gNameBuf; sl@0: GLDEF_D TBuf<0x100> gNameOut; sl@0: GLDEF_D RFile gFile; sl@0: GLDEF_D RFile gFileErr; sl@0: GLDEF_D RFile gFile2; sl@0: GLDEF_D RDir gDir; sl@0: GLDEF_D RFormat gFormat; sl@0: //GLDEF_D void *chan1,*chan2; sl@0: GLDEF_D TFileName fBuf; sl@0: //GLDEF_D TUint8 fBuf[P_FNAMESIZE]; sl@0: sl@0: sl@0: LOCAL_D TBuf8<0x4000> gDataBuf; sl@0: LOCAL_D TEntry gFileEntry; sl@0: // LOCAL_D P_DINFO volInfo; sl@0: LOCAL_D TVolumeInfo volInfo; sl@0: // LOCAL_D P_NINFO nInfo; sl@0: LOCAL_D TFileName pathBuf; sl@0: sl@0: sl@0: LOCAL_D TInt NameErr=KErrBadName; sl@0: LOCAL_D TInt DirErr=KErrPathNotFound; sl@0: LOCAL_D TInt AccessErr=KErrAccessDenied; sl@0: LOCAL_D TInt LockedErr=KErrInUse; sl@0: LOCAL_D TInt ExistsErr=KErrAlreadyExists; sl@0: LOCAL_D TInt NotExistsErr=KErrNotFound; sl@0: LOCAL_D TInt EofErr=KErrEof; sl@0: LOCAL_D TInt DeviceErr=KErrNotReady; sl@0: //LOCAL_D TInt NoFileSystemErr=KErrNotReady; sl@0: //LOCAL_D TInt NotSupportedErr=KErrNotSupported; sl@0: LOCAL_D TInt ReadOnlyErr=KErrAccessDenied; sl@0: sl@0: LOCAL_D TInt P_FASTREAM=EFileStream; sl@0: LOCAL_D TInt P_FAEXEC=0; sl@0: LOCAL_D TInt P_FAMOD=KEntryAttArchive; sl@0: LOCAL_D TInt P_FAREAD=KEntryAttReadOnly; sl@0: //LOCAL_D TInt P_FAHIDDEN=KEntryAttHidden; sl@0: //LOCAL_D TInt P_FASYSTEM=KEntryAttSystem; sl@0: //LOCAL_C TInt P_FAVOLUME=KEntryAttVolume; sl@0: LOCAL_C TInt P_FADIR=KEntryAttDir; sl@0: LOCAL_C TInt P_FRANDOM=0; sl@0: LOCAL_C TInt P_FABS=ESeekStart; sl@0: sl@0: LOCAL_C TInt P_FUPDATE=EFileWrite; sl@0: sl@0: sl@0: LOCAL_C void doError(const TDesC &aMess, TInt anErr, TInt line) sl@0: { sl@0: test.Printf(_L("%S failed at line %d. Error %d\n"),&aMess, line, anErr); sl@0: test(0); sl@0: } sl@0: #define Error(aMess, anErr) doError(aMess, anErr, __LINE__) sl@0: sl@0: LOCAL_C void doError2(const TDesC &aMess, TInt anErr, TInt line, TInt callLine) sl@0: { sl@0: test.Printf(_L("%S failed at line %d. Error %d. Called from line %d\n"),&aMess, line, anErr, callLine); \ sl@0: test(0); sl@0: } sl@0: #define Error2(aMess, anErr, line) doError2(aMess, anErr, __LINE__, line) sl@0: sl@0: LOCAL_C void testWrite(const TDesC& aName,TInt aLen,TInt32 aSize,TBool aShouldChange) sl@0: // sl@0: // Write to a file sl@0: // sl@0: { sl@0: sl@0: TTime saveTime; sl@0: TInt c; sl@0: test.Printf(_L("Write %u bytes %u\n"),aLen,aShouldChange); sl@0: if ((c=TheFs.Entry(aName,gFileEntry))!=KErrNone) sl@0: Error(_L("File info 600"),c); sl@0: saveTime=gFileEntry.iModified; sl@0: User::After(3000000L); // 30 tenths of a sec = 30 00000 micro seconds sl@0: if ((c=gFile.Open(TheFs,aName,EFileWrite))!=KErrNone) sl@0: Error(_L("Open 50"),c); sl@0: if ((c=gFile.Write(gDataBuf,aLen))!=KErrNone) sl@0: Error(_L("Write"),c); sl@0: gFile.Close(); sl@0: if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone) sl@0: Error(_L("File info 601"),c); sl@0: if ((saveTime!=gFileEntry.iModified)!=aShouldChange) sl@0: Error(_L("Change flag check 6"),0); sl@0: if (gFileEntry.iSize!=aSize) sl@0: Error(_L("Size check 602"),0); sl@0: } sl@0: sl@0: LOCAL_C void testSetEof(const TDesC& aName,TUint32 aPos,TBool aShouldChange) sl@0: // sl@0: // Set the end of a file sl@0: // sl@0: { sl@0: sl@0: TTime saveTime; sl@0: TInt c; sl@0: test.Printf(_L("Set EOF to %u %u\n"),aPos,aShouldChange); sl@0: if ((c=TheFs.Entry(aName,gFileEntry))!=KErrNone) sl@0: Error(_L("File info 500"),c); sl@0: saveTime=gFileEntry.iModified; sl@0: User::After(3000000L); sl@0: if ((c=gFile.Open(TheFs,aName,EFileWrite))!=KErrNone) sl@0: Error(_L("Open 50"),c); sl@0: if ((c=gFile.SetSize(aPos))!=KErrNone) sl@0: Error(_L("Set EOF 50"),c); sl@0: gFile.Close(); sl@0: if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone) sl@0: Error(_L("File info 501"),c); sl@0: if ((saveTime!=gFileEntry.iModified)!=aShouldChange) sl@0: Error(_L("Change flag check 5"),0); sl@0: } sl@0: sl@0: sl@0: LOCAL_C void testDir(const TDesC& aDirName) sl@0: // sl@0: // Create a directory sl@0: // sl@0: { sl@0: sl@0: TInt c; sl@0: test.Printf(_L("Test dir %S\n"),&aDirName); sl@0: c=gDir.Open(TheFs,aDirName,KEntryAttNormal); sl@0: sl@0: if (c!=KErrNone) sl@0: Error(_L("Directory open 1000"),c); sl@0: sl@0: gDir.Close(); sl@0: sl@0: TChar drive(aDirName[0]); sl@0: TInt driveNo; sl@0: c=RFs::CharToDrive(drive,driveNo); sl@0: test(c==KErrNone); sl@0: if ((c=TheFs.Volume(volInfo,driveNo))!=KErrNone) sl@0: Error(_L("Device info 1000"),c); sl@0: } sl@0: sl@0: sl@0: /* sl@0: LOCAL_C void testNodeInfo(const TDesC& aName,TInt type,TInt anErr) sl@0: // sl@0: // Test p_ninfo. sl@0: // sl@0: { sl@0: sl@0: // TInt c; sl@0: test.Printf(_L("Node info: %S\n"),&aName); sl@0: // if ((c=p_ninfo(aDirName,&nInfo))!=anErr) sl@0: // Error(_L("Device info"),c); sl@0: if (anErr==0) sl@0: { sl@0: // if (!(nInfo.version==2 || nInfo.version==3)) sl@0: // Error(_L("Node version check"),0); sl@0: // if (nInfo.type!=type) sl@0: // Error(_L("Node type check"),0); sl@0: } sl@0: } sl@0: */ sl@0: sl@0: LOCAL_C void testDeviceInfo(const TDesC& aDeviceName,TInt anErr) sl@0: // sl@0: // Test p_dinfo. sl@0: // sl@0: { sl@0: sl@0: TInt c; sl@0: test.Printf(_L("Device info: %S\n"),&aDeviceName); sl@0: TInt drive=KDefaultDrive; sl@0: if (aDeviceName.Length()) sl@0: { sl@0: c=RFs::CharToDrive(aDeviceName[0],drive); sl@0: test(c==KErrNone); sl@0: } sl@0: if ((c=TheFs.Volume(volInfo,drive))!=anErr) sl@0: Error(_L("Device info"),c); sl@0: if (anErr==0) sl@0: { sl@0: // if (!(volInfo.version==2 || volInfo.version==3)) ********* version is not a member of TVolumeInfo sl@0: // Error(_L("Device version check"),0); sl@0: if (volInfo.iFree>volInfo.iSize) sl@0: Error(_L("Free greater than size check"),0); sl@0: } sl@0: } sl@0: sl@0: LOCAL_C void testFileInfo(const TDesC& aFileName,TInt anErr) sl@0: // sl@0: // Test entry info sl@0: // sl@0: { sl@0: sl@0: TInt c; sl@0: test.Printf(_L("File info: %S\n"),&aFileName); sl@0: if ((c=TheFs.Entry(aFileName,gFileEntry))!=anErr) sl@0: Error(_L("Get info 100"),c); sl@0: if (anErr==0) sl@0: { sl@0: if (aFileName.Length()>=2 && aFileName[0]=='Z' && aFileName[1]==':') sl@0: { sl@0: if ((gFileEntry.iAtt&(P_FAREAD|P_FAEXEC|P_FASTREAM)) != (TUint32)(P_FAREAD|P_FAEXEC|P_FASTREAM) && gFileEntry.iAtt!=KEntryAttDir) sl@0: Error(_L("Info status check Z:\\"),0); sl@0: } sl@0: else sl@0: { sl@0: if (gFileEntry.iAtt&KEntryAttDir) sl@0: return; // Found directory entry sl@0: if (gFileEntry.iAtt!=(TUint32)(P_FASTREAM|P_FAMOD)) sl@0: Error(_L("Info status check"),0); sl@0: if (gFileEntry.iSize!=0L) sl@0: Error(_L("Info size check"),0); sl@0: } sl@0: } sl@0: } sl@0: sl@0: LOCAL_C void testRenameFromRoot(const TDesC& aRName,const TDesC& aDName) sl@0: // sl@0: // sl@0: // sl@0: { sl@0: sl@0: TInt c; sl@0: if ((c=TheFs.Rename(aRName,aDName))!=KErrNone) sl@0: Error(_L("Rename 92"),c); sl@0: if ((c=gFile.Open(TheFs,aDName,EFileStream))!=KErrNone) sl@0: Error(_L("Open 92"),c); sl@0: gFile.Close(); sl@0: if ((c=TheFs.Delete(aRName))!=NotExistsErr) sl@0: Error(_L("Delete 92"),c); sl@0: } sl@0: sl@0: LOCAL_C void testRenameToRoot(const TDesC& pName,const TDesC& rName) sl@0: // sl@0: // sl@0: // sl@0: { sl@0: sl@0: TInt c; sl@0: if ((c=gFile.Replace(TheFs,pName,EFileStream))!=KErrNone) sl@0: Error(_L("Create 91"),c); sl@0: gFile.Close(); sl@0: if ((c=TheFs.Rename(pName,rName))!=KErrNone) sl@0: Error(_L("Rename 91"),c); sl@0: if ((c=gFile.Open(TheFs,rName,EFileStream))!=KErrNone) sl@0: Error(_L("Open 91"),c); sl@0: gFile.Close(); sl@0: if ((c=TheFs.Delete(pName))!=NotExistsErr) sl@0: Error(_L("Delete 91"),c); sl@0: } sl@0: sl@0: LOCAL_C void verifyTestPat1() sl@0: // sl@0: // sl@0: // sl@0: { sl@0: sl@0: TInt i; sl@0: TInt c; sl@0: if ((c=gFile.Open(TheFs,_L("\\TESTPAT1.DAT"),EFileStream))!=KErrNone) sl@0: Error(_L("Create testpat1"),c); sl@0: gDataBuf.SetLength(0); sl@0: if ((c=gFile.Read(gDataBuf,512))!=KErrNone || gDataBuf.Length()!=512) sl@0: Error(_L("Read 90"),c); sl@0: gFile.Close(); sl@0: for (i=0;i<512;i++) sl@0: { sl@0: if (gDataBuf[i]!='X') sl@0: Error(_L("Data check"),0); sl@0: } sl@0: } sl@0: sl@0: void TestINC103141() // PDEF104017 sl@0: { sl@0: test.Printf(_L("Test INC103141\n")); sl@0: _LIT(KDir1, "\\INC103141\\TEST"); sl@0: _LIT(KDir2, "\\INC103141\\test"); sl@0: TBuf<32> dirname; sl@0: dirname.Copy(KDir1); sl@0: dirname.Append(KPathDelimiter); sl@0: MakeDir(dirname); sl@0: TInt err = TheFs.Rename(KDir1, KDir2); sl@0: test(err == KErrNone); sl@0: err = TheFs.RmDir(dirname); sl@0: test(err == KErrNone); sl@0: err = TheFs.RmDir(KDir1); sl@0: test(err == KErrNone); sl@0: } sl@0: sl@0: LOCAL_C void testRename() sl@0: // sl@0: // Test TheFs.Rename function. sl@0: // sl@0: { sl@0: sl@0: TBuf<32> xName; sl@0: TInt i; sl@0: TInt c; sl@0: test.Printf(_L("Test TheFs.Rename\n")); sl@0: sl@0: test.Printf(_L("Test rename into root\n")); sl@0: if ((c=gFile.Replace(TheFs,_L("\\TESTPAT1.DAT"),EFileStream|P_FUPDATE))!=KErrNone) sl@0: Error(_L("Create testpat1"),c); sl@0: gDataBuf.Fill('X',512); sl@0: if ((c=gFile.Write(gDataBuf,512))!=KErrNone) sl@0: Error(_L("Write 90"),c); sl@0: gFile.Close(); sl@0: if ((c=TheFs.MkDir(_L("\\DIRX\\")))!=KErrNone) sl@0: Error(_L("Make dir 90"),c); sl@0: for (i=0;i<32;i++) sl@0: { sl@0: xName.Format(_L("\\DIRX\\FILEX%u"),i); sl@0: TPtrC rootName(xName.Ptr()+5,xName.Length()-5); sl@0: testRenameToRoot(xName,rootName); sl@0: verifyTestPat1(); sl@0: } sl@0: sl@0: test.Printf(_L("Test rename from root\n")); sl@0: for (i=0;i<32;i++) sl@0: { sl@0: xName.Format(_L("\\DIRX\\FILEX%u"),i); sl@0: TPtrC rootName(xName.Ptr()+5,xName.Length()-5); sl@0: testRenameFromRoot(rootName,xName); sl@0: verifyTestPat1(); sl@0: } sl@0: for (i=0;i<32;i++) sl@0: { sl@0: xName.Format(_L("\\DIRX\\FILEX%u"),i); sl@0: if ((c=TheFs.Delete(xName))!=KErrNone) sl@0: Error(_L("Delete 93"),c); sl@0: } sl@0: if ((c=TheFs.RmDir(_L("\\DIRX\\")))!=KErrNone) sl@0: Error(_L("Delete DIRX"),c); sl@0: verifyTestPat1(); sl@0: if ((c=TheFs.Delete(_L("\\TESTPAT1.DAT")))!=KErrNone) sl@0: Error(_L("Delete 80"),c); sl@0: sl@0: test.Printf(_L("Test rename with wild cards\n")); sl@0: if ((c=TheFs.Rename(_L("*.*"),_L("FRED")))!=NameErr) sl@0: Error(_L("Rename 100"),c); sl@0: if ((c=TheFs.Rename(_L("?"),_L("FRED")))!=NameErr) sl@0: Error(_L("Rename 101"),c); sl@0: if ((c=TheFs.Rename(_L(""),_L("FRED")))!=KErrBadName) // NameErr) sl@0: Error(_L("Rename 101.11"),c); sl@0: if ((c=TheFs.Rename(_L("."),_L("FRED")))!=NameErr) sl@0: Error(_L("Rename 101.12"),c); sl@0: if ((c=TheFs.Rename(_L("NOEXIST"),_L("*")))!=NameErr) sl@0: Error(_L("Rename 101.1"),c); sl@0: if ((c=gFile.Create(TheFs,_L("FILE1"),EFileStream))!=KErrNone) sl@0: Error(_L("Create 101.2"),c); sl@0: gFile.Close(); sl@0: if ((c=TheFs.Rename(_L("FILE1"),_L("AAA?")))!=NameErr) sl@0: Error(_L("Rename 101.3"),c); sl@0: if ((c=TheFs.Rename(_L("FILE1"),_L("")))!=KErrBadName) // NameErr) sl@0: Error(_L("Rename 101.41"),c); sl@0: if ((c=TheFs.Rename(_L(""),_L("")))!=KErrBadName) // NameErr) sl@0: Error(_L("Rename 101.42"),c); sl@0: if ((c=TheFs.Delete(_L("FILE1")))!=KErrNone) sl@0: Error(_L("Delete 101.5"),c); sl@0: if ((c=TheFs.Rename(_L("\\"),_L("FRED")))!=NameErr) sl@0: Error(_L("Rename 101.6"),c); sl@0: sl@0: test.Printf(_L("Test rename of directories\n")); sl@0: if ((c=TheFs.MkDir(_L("\\DIR1\\")))!=KErrNone) sl@0: Error(_L("Make dir 102"),c); sl@0: if ((c=TheFs.Rename(_L("\\DIR1"),_L("\\A2345678.123")))!=KErrNone) sl@0: Error(_L("Rename 103.1"),c); sl@0: if ((c=TheFs.Rename(_L("\\A2345678.123"),_L("\\DIR2")))!=KErrNone) sl@0: Error(_L("Rename 103.2"),c); sl@0: if ((c=TheFs.Rename(_L("\\DIR2"),_L("\\A234567.1234")))!=KErrNone) // ****** NameErr) Long filenames are supported sl@0: Error(_L("Rename 103.3"),c); sl@0: if ((c=TheFs.Rename(_L("\\A234567.1234"),_L("\\DIR2")))!=KErrNone) sl@0: Error(_L("Rename 103.3"),c); sl@0: if ((c=TheFs.MkDir(_L("\\DIR1\\")))!=KErrNone) sl@0: Error(_L("Make dir 104"),c); sl@0: sl@0: test.Printf(_L("Test rename of open files\n")); sl@0: if ((c=gFile.Create(TheFs,_L("\\DIR1\\FILE1"),EFileStreamText))!=KErrNone) sl@0: Error(_L("Create 105"),c); sl@0: if ((c=TheFs.Rename(_L("\\DIR1\\FILE1"),_L("\\DIR1\\FILE1")))!=LockedErr) sl@0: Error(_L("Rename 106"),c); sl@0: if ((c=TheFs.Rename(_L("\\DIR1\\FILE1"),_L("\\DIR2\\FILE1")))!=LockedErr) sl@0: Error(_L("Rename 106.1"),c); sl@0: if ((c=gFile2.Open(TheFs,_L("\\DIR2\\FILE1"),EFileStream))!=NotExistsErr) sl@0: Error(_L("Create 105"),c); sl@0: gFile.Close(); sl@0: sl@0: test.Printf(_L("Test rename to same name\n")); sl@0: if ((c=TheFs.Rename(_L("\\DIR1\\FILE1"),_L("\\DIR1\\FILE1")))!=KErrNone) // !=ExistsErr) sl@0: Error(_L("Rename 105.1"),c); sl@0: if ((c=TheFs.Rename(_L("\\DIR1"),_L("\\DIR1")))!=KErrNone) // !=ExistsErr) sl@0: Error(_L("Rename 105.2"),c); sl@0: sl@0: test.Printf(_L("Test rename of read-only files\n")); // IS ALLOWED // sl@0: if ((c=TheFs.SetAtt(_L("\\DIR1\\FILE1"),KEntryAttReadOnly,0))!=KErrNone) sl@0: Error(_L("Att 106"),c); sl@0: if ((c=TheFs.Entry(_L("\\DIR1\\FILE1"),gFileEntry))!=KErrNone) sl@0: Error(_L("File info 106.1"),c); sl@0: test.Printf(_L("STATUS=%04x\n"),gFileEntry.iAtt); sl@0: if (gFileEntry.iAtt!=(TUint32)(P_FAREAD|P_FASTREAM|P_FAMOD)) sl@0: Error(_L("Status check 106.2"),0); sl@0: if ((c=TheFs.Entry(_L("\\DIR1"),gFileEntry))!=KErrNone) sl@0: Error(_L("File info 106.3"),c); sl@0: test.Printf(_L("STATUS=%04x\n"),gFileEntry.iAtt); sl@0: if (gFileEntry.iAtt!=(TUint32)(P_FASTREAM|P_FADIR)) sl@0: Error(_L("Status check 106.4"),0); sl@0: sl@0: if ((c=TheFs.Rename(_L("\\DIR1\\FILE1"),_L("\\DIR1\\FILE1")))!=KErrNone) // !=ExistsErr) sl@0: Error(_L("Rename 107"),c); sl@0: if ((c=TheFs.Rename(_L("\\DIR1\\FILE1"),_L("\\DIR1\\FILE2")))!=KErrNone) sl@0: Error(_L("Rename 108"),c); sl@0: if ((c=TheFs.Rename(_L("\\DIR1\\FILE2"),_L("\\DIR2\\FILE2")))!=KErrNone) sl@0: Error(_L("Rename 109"),c); sl@0: if ((c=gFile2.Open(TheFs,_L("\\DIR2\\FILE2"),EFileStream))!=KErrNone) sl@0: Error(_L("Create 110"),c); sl@0: gFile2.Close(); sl@0: if ((c=TheFs.Rename(_L("\\DIR2\\FILE2"),_L("\\DIR1\\FILE1")))!=KErrNone) sl@0: Error(_L("Rename 110.1"),c); sl@0: if ((c=TheFs.SetAtt(_L("\\DIR1\\FILE1"),0,KEntryAttReadOnly))!=KErrNone) sl@0: Error(_L("Att 111"),c); sl@0: sl@0: test.Printf(_L("Test rename of files across directories\n")); sl@0: if ((c=TheFs.Rename(_L("\\DIR1\\FILE1"),_L("\\DIR2\\FILE1")))!=KErrNone) sl@0: Error(_L("Rename 112"),c); sl@0: if ((c=gFile.Open(TheFs,_L("\\DIR2\\FILE1"),EFileStream))!=KErrNone) sl@0: Error(_L("Exist 113"),c); sl@0: gFile.Close(); sl@0: sl@0: test.Printf(_L("Test rename of directories across directories\n")); sl@0: if ((c=TheFs.Rename(_L("\\DIR1"),_L("\\DIR2\\DIR1")))!=KErrNone) // ******** AccessErr) sl@0: Error(_L("Rename 114"),c); sl@0: if ((c=TheFs.Rename(_L("\\DIR1"),_L("\\")))!=NameErr) sl@0: Error(_L("Rename 114.1"),c); sl@0: sl@0: if ((c=TheFs.Delete(_L("\\DIR2\\FILE1")))!=KErrNone) sl@0: Error(_L("Delete 115"),c); sl@0: if ((c=TheFs.RmDir(_L("\\DIR2\\DIR1\\")))!=KErrNone) sl@0: Error(_L("Delete 115"),c); sl@0: if ((c=TheFs.RmDir(_L("\\DIR2\\")))!=KErrNone) sl@0: Error(_L("Delete 115"),c); sl@0: sl@0: TestINC103141(); // PDEF104017 sl@0: } sl@0: sl@0: LOCAL_C void testDelete() sl@0: // sl@0: // Test RFs::Delete function. sl@0: // sl@0: { sl@0: sl@0: TInt c; sl@0: test.Printf(_L("Test RFs::Delete\n")); sl@0: test.Printf(_L("Test delete non-empty directories\n")); sl@0: if ((c=TheFs.MkDir(_L("\\TESTDIR\\")))!=KErrNone) sl@0: Error(_L("Make dir 500"),c); sl@0: if ((c=gFile.Create(TheFs,_L("\\TESTDIR\\NAME.EXT"),EFileStream))!=KErrNone) sl@0: Error(_L("Create"),c); sl@0: if ((c=TheFs.Delete(_L("\\TESTDIR\\")))!=KErrBadName) // ******* AccessErr) sl@0: Error(_L("Delete 501"),c); sl@0: sl@0: test.Printf(_L("Test delete open file\n")); sl@0: if ((c=TheFs.Delete(_L("\\TESTDIR\\NAME.EXT")))!=LockedErr) sl@0: Error(_L("Delete 502"),c); sl@0: gFile.Close(); sl@0: if ((c=TheFs.Delete(_L("\\TESTDIR\\NAME.EXT")))!=KErrNone) sl@0: Error(_L("Delete 503"),c); sl@0: if ((c=TheFs.RmDir(_L("\\TESTDIR\\")))!=KErrNone) sl@0: Error(_L("Delete 504"),c); sl@0: } sl@0: sl@0: LOCAL_C void testUnique(TUint fileFormat) sl@0: // sl@0: // Test RFile::Temp sl@0: // sl@0: { sl@0: sl@0: TInt pos; sl@0: TInt c; sl@0: test.Printf(_L("Test RFile::Temp\n")); sl@0: gDataBuf.SetLength(1); sl@0: if ((c=gFile.Temp(TheFs,_L(""),gNameBuf,fileFormat))!=KErrNone) sl@0: Error(_L("Directory open 2000"),c); sl@0: if ((c=gFile.Write(gDataBuf,0))!=KErrNone) sl@0: Error(_L("Write 2000"),c); sl@0: if ((c=gFile.Write(gDataBuf,1))!=KErrNone) sl@0: Error(_L("Write 2000"),c); sl@0: pos=0L; sl@0: if ((c=gFile.Seek(ESeekStart,pos))!=KErrNone) // !=E_FILE_INV) Temp file is random access sl@0: Error(_L("Seek 2000"),c); sl@0: gFile.Close(); sl@0: if ((c=TheFs.Delete(gNameBuf))!=KErrNone) sl@0: Error(_L("Delete"),c); sl@0: } sl@0: sl@0: LOCAL_C void testFileName(const TDesC& aFileName,TInt res) sl@0: // sl@0: // sl@0: // sl@0: { sl@0: sl@0: TInt c; sl@0: if ((c=aFileName.Length())>20) sl@0: test.Printf(_L("%u char name\n"),c); sl@0: else sl@0: test.Printf(_L("\"%S\"\n"),&aFileName); sl@0: if ((c=gFile.Create(TheFs,aFileName,EFileStream))!=res) sl@0: Error(_L("Create 200"),c); sl@0: if (res==KErrNone) sl@0: { sl@0: gFile.Close(); sl@0: if ((c=gFile.Open(TheFs,aFileName,EFileStream))!=KErrNone) sl@0: Error(_L("Open 200"),c); sl@0: gFile.Close(); sl@0: if ((c=TheFs.Delete(aFileName))!=KErrNone) sl@0: Error(_L("Delete 200"),c); sl@0: } sl@0: else sl@0: { sl@0: if ((c=gFile.Open(TheFs,aFileName,EFileStream))!=res) // test eg *.* // sl@0: Error(_L("Open 201"),c); sl@0: if ((c=gFile.Replace(TheFs,aFileName,EFileStream))!=res) sl@0: Error(_L("Replace 202"),c); sl@0: } sl@0: } sl@0: sl@0: #if defined(_UNICODE) sl@0: LOCAL_C void testFileName(const TDesC8& aFileName,TInt res) sl@0: // sl@0: // Defined to cope with all the instances of testFileName(gDataBuf,...) sl@0: // sl@0: { sl@0: TPtrC gDataBuf16((TText*)aFileName.Ptr(),gDataBuf.Size()/sizeof(TText8)); sl@0: testFileName(gDataBuf16,res); sl@0: } sl@0: #endif sl@0: sl@0: LOCAL_C void testVolumeName(const TDesC& aVolumeName,TInt aResultExpected) sl@0: // sl@0: // sl@0: // sl@0: { sl@0: sl@0: TInt result; sl@0: test.Printf(_L("\"%S\"\n"),&aVolumeName); sl@0: TInt drive=KDefaultDrive; sl@0: if (aVolumeName.Length()>=2 && aVolumeName[0]=='Z' && aVolumeName[1]==':') sl@0: { sl@0: drive=25; sl@0: TPtr volName((TText*)&aVolumeName[2],(aVolumeName.Length()-2),(aVolumeName.Length()-2)); sl@0: result=TheFs.SetVolumeLabel(volName,drive); sl@0: } sl@0: else sl@0: result=TheFs.SetVolumeLabel(aVolumeName,drive); sl@0: sl@0: if (result==KErrGeneral) sl@0: { sl@0: test.Printf(_L("KErrGeneral: Cannot set volume label on a substed drive!\n")); sl@0: return; sl@0: } sl@0: if (result!=aResultExpected) sl@0: Error(_L("Set volume name returned"),result); sl@0: sl@0: /* if (aResultExpected==FALSE) sl@0: { sl@0: if ((result=TheFs.Volume(volInfo))!=KErrNone) sl@0: Error(_L("Volume Info failed"),result); sl@0: TPtrC vol(aVolumeName); sl@0: if (vol!=volInfo.iName) sl@0: Error(_L("Check volume name failed"),0); sl@0: } sl@0: */ sl@0: } sl@0: sl@0: #define testMakeDir(aDirName, res) TestMakeDirLine(aDirName, res, __LINE__) sl@0: LOCAL_C void TestMakeDirLine(const TDesC& aDirName,TInt res, TInt line) sl@0: // sl@0: // sl@0: // sl@0: { sl@0: sl@0: TInt c; sl@0: TUint l; sl@0: TFileName buf; sl@0: if ((c=aDirName.Length())>20) sl@0: test.Printf(_L("%u char name\n"),c); sl@0: else sl@0: test.Printf(_L("\"%S\"\n"),&aDirName); sl@0: if ((c=TheFs.MkDirAll(aDirName))!=res) sl@0: Error2(_L("Make directory 1"),c, line); sl@0: if (res==FALSE) sl@0: { sl@0: TParse parse; sl@0: c=TheFs.Parse(aDirName,parse); sl@0: test(c==KErrNone); sl@0: buf=parse.Path(); sl@0: buf.Append(_L("*")); sl@0: if (buf.Length()<=64) sl@0: { sl@0: test.Printf(_L("Open dir...\n")); sl@0: if ((c=gDir.Open(TheFs,buf,KEntryAttMaskSupported))!=KErrNone) sl@0: Error2(_L("Directory open 1"),c, line); sl@0: gDataBuf[0]=0; sl@0: if ((c=gDir.Read(gFileEntry))!=EofErr) sl@0: { sl@0: test.Printf(_L("buf=\"%S\"\n"),&gFileEntry.iName); sl@0: Error2(_L("Directory read"),c, line); sl@0: } sl@0: gDir.Close(); sl@0: } sl@0: buf=aDirName; sl@0: l=buf.Length(); sl@0: FOREVER sl@0: { sl@0: test.Printf(_L("Delete \"%S\"\n"),&buf); sl@0: if ((c=TheFs.RmDir(buf))!=KErrNone) sl@0: Error2(_L("Delete directory"),c, line); sl@0: while (--l) sl@0: { sl@0: if (buf[l]=='\\') sl@0: { sl@0: buf.SetLength(l); sl@0: if (buf.LocateReverse('\\')==0) sl@0: return; sl@0: break; sl@0: } sl@0: } sl@0: if (l == 0) sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: sl@0: #if defined(_UNICODE) sl@0: LOCAL_C void TestMakeDirLine(const TDesC8& aDirName, TInt res, TInt line) sl@0: // sl@0: // Defined to cope with all the instances of testMakeDir(gDataBuf,...) sl@0: // sl@0: { sl@0: sl@0: TPtrC gDataBuf16((TText*)aDirName.Ptr(),gDataBuf.Size()/sizeof(TText8)); sl@0: // Not sizeof(TText16) since gDataBuf is a TBuf*! sl@0: TestMakeDirLine(gDataBuf16, res, line); sl@0: } sl@0: #endif sl@0: sl@0: #ifdef TEST_MEDIA sl@0: LOCAL_C void testMedia(const TDesC& instructions,TInt anErr) sl@0: // sl@0: // sl@0: // sl@0: { sl@0: sl@0: TBuf<0x40> errBuf; sl@0: TInt openErr; sl@0: TInt c; sl@0: // p_errs(&errBuf[0],anErr); sl@0: pathBuf=fBuf; sl@0: pathBuf.SetLength(7); sl@0: test.Printf(_L("Test %S\n"),&errBuf); sl@0: test.Printf(_L("%S %S\n"),&instructions,&pathBuf); sl@0: p_getch(); sl@0: openErr=anErr; sl@0: if (anErr==WriteProtectErr) sl@0: openErr=0; sl@0: if ((c=gFile.Open(TheFs,fBuf,P_FDIR))!=openErr) sl@0: Error(_L("Directory open 100"),c); sl@0: if (openErr==KErrNone) sl@0: { sl@0: if (c=gFile.Close()) sl@0: Error(_L("Close 100"),c); sl@0: } sl@0: gNameBuf.SetLength(0); sl@0: if ((c=gFile.Open(TheFs,gNameBuf,P_FUNIQUE|EFileStream))!=anErr) sl@0: Error(_L("Create unique 100"),c); sl@0: if (anErr==0) sl@0: { sl@0: if (c=gFile.Close()) sl@0: Error(_L("Close 100"),c); sl@0: } sl@0: } sl@0: #endif sl@0: sl@0: GLDEF_C void CallTestsL() sl@0: // sl@0: // Do All tests sl@0: // sl@0: { sl@0: TInt c; sl@0: TInt i,count; sl@0: TInt pos; sl@0: TInt64 seed; sl@0: TInt attrib,mask; sl@0: TTime saveTime; sl@0: TInt testSize; sl@0: sl@0: CreateTestDirectory(_L("\\F32-TST\\BGEN\\")); sl@0: // if (p_date() KErrPathNotFound sl@0: // testDir(_L("Z:*")); // Session Path gets added -> KErrPathNotFound sl@0: // testDir(_L("Z:*.*")); // Session Path gets added -> KErrPathNotFound sl@0: testDir(_L("Z:\\")); sl@0: testDir(_L("Z:\\*")); sl@0: testDir(_L("Z:\\*.*")); sl@0: sl@0: test.Printf(_L("Test names containing '\\'\n")); sl@0: if ((c=gFile.Create(TheFs,_L("Q\\ZZZ"),EFileWrite))!=NameErr) sl@0: Error(_L("Create 1"),c); sl@0: sl@0: test.Printf(_L("Test create in non-exist directory\n")); sl@0: if ((c=gFile.Create(TheFs,_L("\\Q1DDX\\ZZZ"),EFileWrite))!=DirErr) sl@0: Error(_L("Create 2"),c); sl@0: sl@0: test.Printf(_L("Test filenames starting with '.'\n")); sl@0: if ((c=gFile.Create(TheFs,_L("\\.ZZZ"),EFileWrite))!=KErrNone) // ****** NameErr) sl@0: Error(_L("Create 3"),c); sl@0: gFile.Close(); sl@0: if ((c=TheFs.Delete(_L("\\.ZZZ")))!=KErrNone) sl@0: Error(_L("Delete 3"),c); sl@0: sl@0: test.Printf(_L("Test filenames starting with 05/E5\n")); sl@0: gNameBuf.SetLength(5); sl@0: gNameBuf[0]=0xE5; sl@0: gNameBuf[1]='X'; sl@0: gNameBuf[2]='X'; sl@0: gNameBuf[3]='X'; sl@0: gNameBuf[4]=0x00; sl@0: gNameBuf.SetLength(4); sl@0: if ((c=gFile.Replace(TheFs,gNameBuf,EFileWrite))!=KErrNone) sl@0: Error(_L("Replace 4"),c); sl@0: gFile.Close(); sl@0: if ((c=gFile.Open(TheFs,gNameBuf,EFileRead))!=KErrNone) sl@0: Error(_L("Open 4"),c); sl@0: gFile.Close(); sl@0: sl@0: // *************** Silly filename stuff rightly disallowed by NT sl@0: // gNameBuf.SetLength(5); sl@0: // gNameBuf[0]=0x05; sl@0: // gNameBuf[1]='Y'; sl@0: // gNameBuf[2]='Y'; sl@0: // gNameBuf[3]='Y'; sl@0: // gNameBuf[4]=0x00; // Zero terminator gets lost by VFAT sl@0: // if ((c=gFile.Replace(TheFs,gNameBuf,EFileWrite))!=KErrNone) sl@0: // Error(_L("Create 5"),c); sl@0: // gFile.Close(); sl@0: // gNameBuf[0]=0xE5; sl@0: // if ((c=gFile.Open(TheFs,gNameBuf,EFileRead))!=KErrNone) sl@0: // Error(_L("Open 5"),c); sl@0: // gFile.Close(); sl@0: // sl@0: sl@0: // sl@0: //#ifdef TEST_MEDIA sl@0: // if (fBuf[5]!='B') sl@0: // goto skipMediaTest; sl@0: // testMedia(_L("OPEN DOOR ON"),NotReadyErr); sl@0: // testMedia(_L("INSERT CORRUPT RAM PACK (WRITE ENABLED) INTO"),CorruptMediaErr); sl@0: // testMedia(_L("INSERT CORRUPT RAM PACK (WRITE PROTECTED) INTO"),CorruptMediaErr); sl@0: // testMedia(_L("INSERT CORRUPT FLASH PACK (WRITE ENABLED) INTO"),CorruptMediaErr); sl@0: // testMedia(_L("INSERT CORRUPT FLASH PACK (WRITE PROTECTED) INTO"),CorruptMediaErr); sl@0: //#ifdef FULL_TEST sl@0: // testMedia(_L("INSERT UNKNOWN MEDIA INTO"),UnknownErr); sl@0: //#endif sl@0: // testMedia(_L("INSERT GOOD RAM PACK (WRITE PROTECTED) INTO"),WriteProtectErr); sl@0: // if ((c=gFile.Open(TheFs,fBuf,P_FFORMAT))!=WriteProtectErr) sl@0: // Error(_L("Format RAM write protect"),c); sl@0: // testMedia(_L("INSERT GOOD FLASH PACK (WRITE PROTECTED) INTO"),WriteProtectErr); sl@0: // if ((c=gFile.Open(TheFs,fBuf,P_FFORMAT))!=WriteProtectErr) sl@0: // Error(_L("Format FLASH write protect"),c); sl@0: // testMedia(_L("INSERT GOOD PACK (WRITE ENABLED) INTO"),0); sl@0: // sl@0: //skipMediaTest: sl@0: //#endif // TEST_MEDIA // sl@0: // sl@0: sl@0: // Test update is assumed for unique // sl@0: sl@0: testUnique(EFileStream); sl@0: testUnique(EFileStreamText); sl@0: testDelete(); sl@0: testRename(); sl@0: test.Printf(_L("Test get file info\n")); sl@0: // testFileInfo(_L("*.*"),NameErr); ********** Allowed (?) sl@0: testFileInfo(_L(""),KErrNone); // NameErr); sl@0: testFileInfo(_L("\\"),NameErr); sl@0: testFileInfo(_L("."),NameErr); sl@0: testFileInfo(_L(".."),NameErr); sl@0: testFileInfo(_L("a.1234"),KErrNotFound); // ********* NameErr); sl@0: testFileInfo(_L("a23456789"),KErrNotFound); // ********* NameErr); sl@0: testFileInfo(_L(".a"),KErrNotFound); // ********** NameErr); sl@0: testFileInfo(_L("?"),NameErr); sl@0: testFileInfo(_L("NOEXIST"),NotExistsErr); sl@0: testFileInfo(_L("\\NODIR\\NAME"),DirErr); sl@0: testFileInfo(_L("L:\\NAME"),DeviceErr); sl@0: gNameBuf.SetLength(0); sl@0: if ((c=gFile.Temp(TheFs,gNameBuf,gNameOut,EFileStream))!=KErrNone) sl@0: Error(_L("Open 1.1"),c); sl@0: testFileInfo(gNameOut,FALSE); // Not locked // sl@0: gFile.Close(); sl@0: testFileInfo(gNameOut,FALSE); sl@0: if ((c=TheFs.Delete(gNameOut))!=KErrNone) sl@0: Error(_L("Delete"),c); sl@0: sl@0: test.Printf(_L("Test get device info\n")); sl@0: testDeviceInfo(_L(""),FALSE); // NULL is current device // sl@0: testDeviceInfo(_L("L:"),DeviceErr); sl@0: testDeviceInfo(_L("Z:"),FALSE); sl@0: testDeviceInfo(fBuf,FALSE); sl@0: sl@0: sl@0: // test.Printf(_L("Test get node info\n")); sl@0: // testNodeInfo(_L("LOC::"),P_FSYSTYPE_HIER,FALSE); sl@0: // testNodeInfo(_L("Z:"),P_FSYSTYPE_FLAT,FALSE); sl@0: // testNodeInfo(_L("LOC:"),P_FSYSTYPE_HIER,FALSE); sl@0: // testNodeInfo(_L("LOC"),P_FSYSTYPE_HIER,FALSE); sl@0: // testNodeInfo(_L("*"),P_FSYSTYPE_HIER,FALSE); sl@0: // testNodeInfo(_L(""),P_FSYSTYPE_HIER,FALSE); sl@0: // testNodeInfo(_L("?"),P_FSYSTYPE_HIER,FALSE); sl@0: // testNodeInfo(_L("FRED"),P_FSYSTYPE_HIER,FALSE); sl@0: // testNodeInfo(_L("FRED::"),P_FSYSTYPE_HIER,FALSE); sl@0: // testNodeInfo(_L("....."),P_FSYSTYPE_HIER,FALSE); sl@0: // testNodeInfo(_L("LOC::zzzzzzzzzzzzzzzzzzzzzzzzz"),P_FSYSTYPE_HIER,FALSE); sl@0: // testNodeInfo(_L("LOC::\\"),P_FSYSTYPE_HIER,FALSE); sl@0: // testNodeInfo(_L("XXX::"),0,E_GEN_FSYS); sl@0: // testNodeInfo(_L("REM::"),0,E_GEN_FSYS); sl@0: // testNodeInfo(_L("...::"),0,E_GEN_FSYS); sl@0: sl@0: // testFileInfo(_L("Z:SYS$WSRV.IMG"),FALSE); sl@0: // testFileInfo(_L("Z:\\SYS$WSRV.IMG"),NameErr); // \ not allowed - no path // sl@0: // testFileInfo(_L("Z:*"),FALSE); // Z: allows *'s ! // sl@0: // testFileInfo(_L("Z:SYS$WSRV."),NotExistsErr); sl@0: // testFileInfo(_L("XXX::"),NoFileSystemErr); sl@0: if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)) sl@0: testFileInfo(_L("Z:\\Sys\\Bin\\ESHELL.EXE"),FALSE); // we now have paths // sl@0: else sl@0: testFileInfo(_L("Z:\\System\\Bin\\ESHELL.EXE"),FALSE); // we now have paths // sl@0: // testFileInfo(_L("Z:*"),KErrPathNotFound); // session path gets inserted ,FALSE); sl@0: // testFileInfo(_L("Z:SYS$WSRV."),NotExistsErr); sl@0: // testFileInfo(_L("H:"),KErrBadName); // ************** NoFileSystemErr); sl@0: sl@0: test.Printf(_L("Test weird filenames\n")); sl@0: // Test SPACES // sl@0: sl@0: testFileName(_L("A B"),KErrNone); // ******* NameErr); sl@0: testFileName(_L(" AB"),KErrNone); // ******* NameErr); sl@0: testFileName(_L(" AB "),KErrNone); // ******* NameErr); sl@0: testFileName(_L(" AB"),KErrNone); sl@0: testFileName(_L(" AB . cdef"),KErrNone); sl@0: testFileName(_L(" AB . cdef "),KErrNone); sl@0: testFileName(_L("A2345678 "),KErrNone); // ******* NameErr); sl@0: testFileName(_L("A2345678.XY "),KErrNone); // ******* NameErr); sl@0: testFileName(_L("A2345678.XYZ "),KErrNone); // ******* NameErr); sl@0: testFileName(_L("A2345678 XYZ"),KErrNone); // ******* NameErr); sl@0: testFileName(_L(" "),NameErr); sl@0: testFileName(_L("\\A B\\NAME"),KErrPathNotFound); // ******* NameErr); sl@0: testFileName(_L("\\ \\NAME"),NameErr); sl@0: testFileName(_L("\\asdf\\qer\\ \\asdf\\NAME"),NameErr); sl@0: testFileName(_L(" "),NameErr); sl@0: testFileName(_L("C:\\asdf\\ "),NameErr); sl@0: // Test short names // sl@0: testFileName(_L(""),NameErr); sl@0: testFileName(_L("\\"),NameErr); sl@0: testFileName(_L("1"),FALSE); sl@0: testFileName(_L(".1"),KErrNone); // ******* NameErr); sl@0: testFileName(_L(".1"),KErrNone); // ******* NameErr); sl@0: testFileName(_L("\\.1"),KErrNone); // ******* NameErr); sl@0: testFileName(_L("1.1"),FALSE); sl@0: // Test long names // sl@0: testFileName(_L("12345678.123"),FALSE); sl@0: testFileName(_L("123456789.123"),KErrNone); // ******* NameErr); sl@0: testFileName(_L("12345678.1234"),KErrNone); // ******* NameErr); sl@0: testFileName(_L("1.1234"),KErrNone); // ******* NameErr); sl@0: testFileName(_L("123456789"),KErrNone); // ******* NameErr); sl@0: gDataBuf.SetLength(256); sl@0: gDataBuf.Fill('A',255); sl@0: testFileName(gDataBuf,NameErr); sl@0: gDataBuf.SetLength(257); sl@0: gDataBuf.Fill('B',256); sl@0: testFileName(gDataBuf,NameErr); sl@0: gDataBuf.SetLength(258); sl@0: gDataBuf.Fill('C',257); sl@0: testFileName(gDataBuf,NameErr); sl@0: gDataBuf.SetLength(4096); sl@0: gDataBuf.Fill('D',4095); sl@0: testFileName(gDataBuf,NameErr); sl@0: // Test DOTS // sl@0: testFileName(_L("A.X"),FALSE); sl@0: testFileName(_L("A..X"),KErrNone); // ******* NameErr); sl@0: testFileName(_L("A.........X"),KErrNone); // ******* NameErr); sl@0: testFileName(_L("A."),FALSE); sl@0: testFileName(_L(".X"),KErrNone); // ******* NameErr); sl@0: testFileName(_L("."),NameErr); sl@0: testFileName(_L(".."),NameErr); sl@0: // testFileName(_L("..."),KErrNone); // NameErr); // !!! ********* NT error KErrAccessDenied (?) sl@0: testFileName(_L("\\a.x\\NAME"),DirErr); // DirErr == KErrPathNotFound sl@0: testFileName(_L("\\a..x\\NAME"),DirErr); // ******** NameErr); sl@0: testFileName(_L("\\.\\NAME"),NameErr); sl@0: testFileName(_L("\\..\\NAME"),NameErr); sl@0: // testFileName(_L("\\...\\NAME"),KErrPathNotFound); // ******** NameErr); // !! NT treats ... as .. ?? sl@0: // Test WILD CARDS // sl@0: testFileName(_L("*.*"),NameErr); sl@0: testFileName(_L("*"),NameErr); sl@0: testFileName(_L("\\*"),NameErr); sl@0: testFileName(_L("?"),NameErr); sl@0: testFileName(_L("\\?"),NameErr); sl@0: testFileName(_L("\\A?B\\NAME"),NameErr); sl@0: testFileName(_L("\\A*B\\NAME"),NameErr); sl@0: testFileName(_L("\\*\\NAME"),NameErr); sl@0: testFileName(_L("\\********.***\\NAME"),NameErr); sl@0: testFileName(_L("A?X"),NameErr); sl@0: sl@0: test.Printf(_L("Test set volume name\n")); sl@0: // New behaviour: SetVolumeName accepts any string < 12 chars sl@0: // No modifications are made on the string. sl@0: #if defined(__WINS__) sl@0: TInt ret=TheFs.SetVolumeLabel(_L("TEST"),KDefaultDrive); sl@0: if(ret==KErrNotSupported||ret==KErrAccessDenied) sl@0: { sl@0: test.Printf(_L("Error: Cannot set volume label on substed drive\n")); sl@0: //test.Getch(); sl@0: } sl@0: else sl@0: #endif sl@0: { sl@0: testVolumeName(_L("TESTNAME.VOL"),KErrBadName); // 12 chars - too long for volume label sl@0: testVolumeName(_L("TESTNAME"),FALSE); // OK for 8 bit - too long for UNICODE sl@0: testVolumeName(_L("PQRSTUVWXYZ"),FALSE); // just uses the first 5 characters sl@0: testVolumeName(_L("ABCDE"),FALSE); sl@0: testVolumeName(_L("FGHIJK"),FALSE); sl@0: testVolumeName(_L(""),FALSE); sl@0: testVolumeName(_L(""),FALSE); sl@0: testVolumeName(_L("\\"),FALSE); sl@0: gNameBuf.SetLength(0); sl@0: if ((c=gFile.Temp(TheFs,gNameBuf,gNameOut,EFileStream))!=KErrNone) sl@0: Error(_L("Open 60"),c); sl@0: testVolumeName(_L("TEST_NAME"),FALSE); // Check not locked sl@0: gFile.Close(); sl@0: if ((c=TheFs.Delete(gNameOut))!=KErrNone) sl@0: Error(_L("Delete"),c); sl@0: testVolumeName(_L("voL1"),FALSE); sl@0: testVolumeName(_L("\\vol1"),FALSE); sl@0: testVolumeName(_L("\\12345678.123"),KErrBadName); sl@0: testVolumeName(_L("\\123456.123"),FALSE); sl@0: testVolumeName(_L("\\vol1\\"),KErrNone); sl@0: testVolumeName(_L("."),KErrBadName); // Bug fix SW1-728 to prevent illegal characters sl@0: testVolumeName(_L(".."),KErrBadName); // in the volume name sl@0: testVolumeName(_L("A."),KErrBadName); sl@0: if (!IsTestingLFFS()) sl@0: { // ??? sl@0: testVolumeName(_L("!\"\x9C$%^&@.(){"),KErrBadName); sl@0: testVolumeName(_L("!\"\x9C$%^&@("),KErrBadName); sl@0: } sl@0: testVolumeName(_L("*.*"),KErrBadName); // Wild cards not allowed sl@0: testVolumeName(_L("?.?"),KErrBadName); sl@0: testVolumeName(_L("????????.???"),KErrBadName); sl@0: testVolumeName(_L("????????.??"),KErrBadName); sl@0: testVolumeName(_L("ABC>DEF"),KErrBadName); sl@0: testVolumeName(_L("ABC