// -----------------------------------------------------------------------------
// CAknFileSelectionModel::ContainsSubfolders
//
//
// -----------------------------------------------------------------------------
//
TBool CAknFileSelectionModel::ContainsSubfolders( const TDesC& aFolder )
    {
    TPath directory( iCurrentPath.DriveAndPath() );
    directory.Append( aFolder );
    AknCFDUtility::AddTrailingBackslash( directory ); // ignore error
    
    // Keep old code for possible roll-back
    /*
    CDir* array = ReadDirectory( directory );
    if( ( !array ) || ( array->Count() == 0 ) || ( !(* array)[ 0 ].IsDir() ) )
        {
        delete array;
        return EFalse;
        }
    delete array;
    return ETrue;
    */
    
    RDir dir;
    TBool ret( EFalse );
    if ( dir.Open(
        iFs, directory, KEntryAttDir | KEntryAttMatchExclusive ) != KErrNone )
        {
        return EFalse;
        }
    TEntry entry;
    if ( dir.Read( entry ) == KErrNone )
        {
        ret = ETrue;
        }
    dir.Close();
    return ret;
    }
LOCAL_C void MainL()
	{
	test.Start(_L("@SYMTESTCaseID:PIM-ALLDAYEVENTS-0001 Getting list of all day events data...."));

	RDir dataDir;
	CleanupClosePushL(dataDir);
	//Open the Data directory and read the file entries
	User::LeaveIfError(dataDir.Open(calTestLibrary->FileSession(), KDataDir, KEntryAttNormal));
	
	TEntryArray* dataArray = new (ELeave) TEntryArray();

	CleanupStack::PushL(dataArray);
	
	dataDir.Read(*dataArray);
	
	TInt count = dataArray->Count();
	test (count != 0);
		
	for (TInt i=0; i < count; ++i)
	    {
	    test.Next(_L("ALLDAYEVENTS-0002"));

	    TBuf<256> name;
	    name = KDataDir;
	    name.Append((*dataArray)[i].iName);
	    
	    RPointerArray<CCalEntry> calEntries;
	    CleanupResetAndDestroyPushL(calEntries);
	    ImportEntriesL(name, calEntries);
	    TInt calEntriesCount = calEntries.Count();
	    if (calEntriesCount)	
	        {
	        //Test entry for the presence of timzone rules and UTC
	        CheckTimezoneRules(*calEntries[0]);
	        }
	    name = KWriteDataDir;
	    name.Append((*dataArray)[i].iName);
	    
	    ExportEntriesL(calEntries, name);
	    
	    TBool result = TestExportedFile(name);
	    
	    if (result)
	        {
	    	calTestLibrary->FileSession().Delete(name);
	        }
	    
	    CleanupStack::PopAndDestroy(&calEntries);
	    }
	
	CleanupStack::PopAndDestroy(dataArray);
	CleanupStack::PopAndDestroy(&dataDir);
	// This will fail if there was a parsing error in one or more of the data files
	// which will still be then present in the directory for inspecting.
	test (calTestLibrary->FileSession().RmDir(KWriteDataDir) == KErrNone);
	
	test.End();
	test.Close();
	}
Example #3
0
LOCAL_C void RDirtest()
//
//
//
	{
	//system

	TBuf<30> dirNameBuf(KSystemPath);
	dirNameBuf[0]=(TText)gDriveToTest;
	r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
	test_Value(r, r == KErrPermissionDenied);
	dir.Close();
	r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
	test_Value(r, r == KErrPermissionDenied);
	dirNameBuf.Zero();
	delete dirEntries;
	
	dirNameBuf=KPrivateFalseID;
	dirNameBuf[0]=(TText)gDriveToTest;
	r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
	test_Value(r, r == KErrPermissionDenied);
	dir.Close();
	r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
	test_Value(r, r == KErrPermissionDenied);
	dirNameBuf.Zero();
	delete dirEntries;

	//Private
	dirNameBuf=KPrivatePath;
	dirNameBuf[0]=(TText)gDriveToTest;
	r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
	test_Value(r, r == KErrPermissionDenied);
	dir.Close();
	r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
	test_Value(r, r == KErrPermissionDenied);
	dirNameBuf.Zero();
	delete dirEntries;
	//Private/uid
	TheFs.PrivatePath(dirNameBuf);
	dirNameBuf.Insert(0,_L("?:"));
	dirNameBuf[0]=(TText)gDriveToTest;
	r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
	test_KErrNone(r);
	dir.Close();
	r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
	test_KErrNone(r);
	dirNameBuf.Zero();
	delete dirEntries;
	//Resource
	dirNameBuf=KResourcePath;
	dirNameBuf[0]=(TText)gDriveToTest;
	r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
	test_KErrNone(r);
	r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
	test_KErrNone(r);
	dir.Close();
	delete dirEntries;
	}
Example #4
0
void CheckNonMatch(const TDesC& aFileName)
	{
	TInt r;
	RDir dir;
	TFileName name;
	name = KPath;
	name.Append(aFileName);
	r = dir.Open(TheFs, name, KEntryAttNormal);
	test_KErrNone(r);
	TEntry entry;
	r = dir.Read(entry);
	test_Equal(KErrEof, r);
	dir.Close();
	}
Example #5
0
void TSessionTest::testInitialisation()
//
//	Tests that calls to CheckedClose() are OK, ie, tests bug fix
//
	{
	test.Next(_L("Test calls to CheckedClose are OK"));
	
	RFile file;
	RDir dir;
		
	TInt count;
	RFormat format;
	TInt r=format.Open(iFs,_L("Z:\\"),EFullFormat,count);

	test_Value(r, r==KErrAccessDenied || r==KErrInUse);
	
	r=dir.Open(iFs,_L("\\SESSION_TEST\\ERRORTEST\\"),KEntryAttMatchMask);
	test_Value(r, r==KErrPathNotFound);
	
	r=file.Open(iFs,_L("\\SESSION_TEST\\SessionTest1.txt"),EFileRead);
	test_Value(r, r==KErrNotFound);

	r=dir.Open(iFs,_L("\\SESSION_TEST\\ERRORTEST2\\"),KEntryAttMatchMask);
	test_Value(r, r==KErrPathNotFound);		
	
	r=file.Open(iFs,_L("\\SESSION_TEST\\SessionTest2.txt"),EFileRead);
	test_Value(r, r==KErrNotFound);

	r=dir.Open(iFs,_L("\\SESSION_TEST\\ERRORTEST3\\"),KEntryAttMatchMask);
	test_Value(r, r==KErrPathNotFound);		
	
	r=file.Open(iFs,_L("\\SESSION_TEST\\SessionTest3.txt"),EFileRead);
	test_Value(r, r==KErrNotFound);

	r=file.Open(iFs,_L("\\SESSION_TEST\\SessionTest4.txt"),EFileRead);
	test_Value(r, r==KErrNotFound);
	
	format.Close();
	dir.Close();
	file.Close();
	}
// -----------------------------------------------------------------------------
// CAknFileSelectionModel::ContainsFiles
//
// -----------------------------------------------------------------------------
//
TBool CAknFileSelectionModel::ContainsFiles( const TDesC& aFolder )
    {
    TPath directory( iCurrentPath.DriveAndPath() );
    directory.Append( aFolder );
    AknCFDUtility::AddTrailingBackslash( directory ); // ignore error
    
    RDir dir;
    TBool ret( EFalse );
    if ( dir.Open(
        iFs, directory, KEntryAttNormal ) != KErrNone )
        {
        return EFalse;
        }
    TEntry entry;
    if ( dir.Read( entry ) == KErrNone )
        {
        ret = ETrue;
        }
    dir.Close();
    return ret;
    }
Example #7
0
void TMultipleSessionTest::testInitialisation(RTest& aTest)
//
//	Modified from T_SESSION.  Still tests that calls to CheckedClose() are
//	OK, ie, tests bug fix, but doesn't check returned error values since remote drive
//	doesn't necessarily return them.
//
	{
	RFile file;
	RDir dir;
		
	aTest.Next(_L("Test calls to CheckedClose are OK"));
	
	TInt r=iFs.SetSessionPath(iSessionPath);
	TInt count;
	RFormat format;
	r=format.Open(iFs,_L("Z:\\"),EFullFormat,count);

	aTest((r==KErrAccessDenied)||(r==KErrInUse));
	
	r=dir.Open(iFs,_L("\\MULTIPLE_SESSION_TEST\\ERRORTEST\\"),KEntryAttMatchMask);
//	aTest(r==KErrPathNotFound);		
	if (r==KErrNone)
		dir.Close();
	
	r=file.Open(iFs,_L("\\MULTIPLE_SESSION_TEST\\SessionTest1.txt"),EFileRead);
//	aTest(r==KErrNotFound);
	if (r==KErrNone)
		file.Close();

	r=dir.Open(iFs,_L("\\MULTIPLE_SESSION_TEST\\ERRORTEST2\\"),KEntryAttMatchMask);
//	aTest(r==KErrPathNotFound);		
	if (r==KErrNone)
		dir.Close();

	r=file.Open(iFs,_L("\\MULTIPLE_SESSION_TEST\\SessionTest2.txt"),EFileRead);
//	aTest(r==KErrNotFound);
	if (r==KErrNone)
		file.Close();

	r=dir.Open(iFs,_L("\\MULTIPLE_SESSION_TEST\\ERRORTEST3\\"),KEntryAttMatchMask);
//	aTest(r==KErrPathNotFound);		
	if (r==KErrNone)
		dir.Close();

	r=file.Open(iFs,_L("\\MULTIPLE_SESSION_TEST\\SessionTest3.txt"),EFileRead);
//	aTest(r==KErrNotFound);
	if (r==KErrNone)
		file.Close();

	r=file.Open(iFs,_L("\\MULTIPLE_SESSION_TEST\\SessionTest4.txt"),EFileRead);
//	aTest(r==KErrNotFound);
	if (r==KErrNone)
		file.Close();
	}
Example #8
0
/**
    Testing the case when the full length of the directory name is shorter than KMaxFileName but 
    on the emulator because of the conversion epoc "c:\something" to e.g. "d:\epoc32\release\winscw\c\something"
    it gets exactly KMaxFileName lengths, which causes +-1 syndrom problems.
*/
LOCAL_C void DoTestLongDirName1(void)
{
    RFs         rfs;
    RDir        rDir;

    CleanupClosePushL(rfs);    
    CleanupClosePushL(rDir);    
    
    test(rfs.Connect() == KErrNone);
    
    TPtrC dirName(_L("c:\\mainTestDir\\test000\\1a34567890123456789012345678901234567890 1234567890123456789012345678901234567890 1234567890123456789012345678901234567890 1234567890123456789012345678901234567890 1234567890123456789012345678901234567890 1234567890\\"));
    
    //-- TParse shall work correctly
    TParse parse;
    TInt err = parse.Set(dirName,NULL,NULL);
    test_KErrNone(err);
    
    //-- try to access a directory with a long name. This just shall not panic.
    //-- The return code can be any, on the emulator it's very likely to be KErrBadname
    err = rDir.Open(rfs,dirName,EFileStream|EFileWrite|EFileShareExclusive);

    CleanupStack::PopAndDestroy(2); // rfs, rDir
}
Example #9
0
LOCAL_C void DoTestName(const TDesC& aName,TInt anError)
//
// Check errors returned
//
	{

	TBuf<32> goodName=_L("\\GOODNAME.TXT");
	TBuf<32> badName=_L("\\< > : \" / |");
	TParse parser;
	TInt r=parser.Set(aName,NULL,NULL);
	test_Value(r, r == KErrNone || r==anError);
	goodName.Insert(0,parser.Drive());
	badName.Insert(0,parser.Drive());
	
	
	TBuf<KMaxFileName> name;	//	We need an 8-bit name to test RFs::GetLongName() in 
	name.Copy(aName);			//	both builds

	TFileName dummy;			//	To use as an argument to RFs::GetLongName() will store the 
	TBuf<12> dummyShortName;	//	To use as an argument to RFs::GetShortName()
	TUint dumVal;
	TTime dumTime;
	TBool dumAnswer;
	TEntry dumEntry;
	CDir* dumDir;
	TUidType dumUid;
	TInt dumInt=0;
	TFileName badPath=aName;
	badPath.Append(_L("\\"));

//	Test MKDIR with filename containing \000
	TBuf<32> emptyName;
	emptyName.Format(_L("\\%c\\"),0);
	emptyName.Insert(0,parser.Drive());
	r=TheFs.MkDir(emptyName);
	TestReturnValue(r, anError);
	emptyName.Format(_L("\\Big%cGreen\\"),0);
	emptyName.Insert(0,parser.Drive());
	r=TheFs.MkDir(emptyName);
	TestReturnValue(r, anError);
	r=TheFs.SetSessionPath(badPath);
	TestReturnValue(r,KErrBadName); // Do not check drives
	r=TheFs.MkDir(badPath);
	TestReturnValue(r,anError);
	r=TheFs.MkDirAll(badPath);
	TestReturnValue(r,anError);
	r=TheFs.RmDir(badPath);
	TestReturnValue(r,anError);
	r=TheFs.GetDir(aName,dumInt,dumInt,dumDir);
	TestReturnValue(r,anError);
	r=TheFs.GetDir(aName,dumInt,dumInt,dumDir,dumDir);
	TestReturnValue(r,anError);
	r=TheFs.GetDir(aName,dumUid,dumInt,dumDir);
	TestReturnValue(r,anError);
	r=TheFs.Delete(aName);
	TestReturnValue(r,anError);

	r=TheFs.Rename(aName,goodName);
	TestReturnValue(r,anError);
	r=TheFs.Rename(aName,badName);
	TestReturnValue(r,anError);
	r=TheFs.Rename(goodName,aName);
	TestReturnValue(r,anError);
	r=TheFs.Rename(badName,aName);
	TestReturnValue(r,anError);

	r=TheFs.Replace(aName,goodName);
	TestReturnValue(r,anError);
	r=TheFs.Replace(aName,badName);
	TestReturnValue(r,anError);
	r=TheFs.Replace(goodName,aName);
	TestReturnValue(r,anError);
	r=TheFs.Replace(badName,aName);
	TestReturnValue(r,anError);

	r=TheFs.Att(aName,dumVal);
	TestReturnValue(r,anError);
	r=TheFs.SetAtt(aName,dumInt,dumInt);
	TestReturnValue(r,anError);
	r=TheFs.Modified(aName,dumTime);
	TestReturnValue(r,anError);
	r=TheFs.SetModified(aName,dumTime);
	TestReturnValue(r,anError);
	r=TheFs.Entry(aName,dumEntry);
	TestReturnValue(r,anError);
	r=TheFs.SetEntry(aName,dumTime,dumInt,dumInt);
	TestReturnValue(r,anError);
	r=TheFs.IsFileOpen(aName,dumAnswer);
	TestReturnValue(r,anError);

	r=TheFs.GetShortName(aName,dummyShortName);
	TestReturnValue(r,anError);
	r=TheFs.GetLongName(name,dummy);
	TestReturnValue(r,anError);
	
	RFile f;
	r=f.Open(TheFs,aName,EFileWrite);
	TestReturnValue(r,anError);
	r=f.Create(TheFs,aName,EFileWrite);
	TestReturnValue(r,anError);
	r=f.Replace(TheFs,aName,EFileWrite);
	TestReturnValue(r,anError);
	RDir d;
	r=d.Open(TheFs,aName,KEntryAttNormal);
	TestReturnValue(r,anError);
	r=d.Open(TheFs,aName,dumUid);
	TestReturnValue(r,anError);
	}
void CallTestsL()
	{
    TInt drive;
	TInt err=RFs::CharToDrive(gDriveToTest,drive);
	test.Start(_L("Starting Test - T_PROXYDRIVE1"));
	test(err==KErrNone);

    PrintDrvInfo(TheFs, drive);


	_LIT(KBitProxyDriveName, "t_bitproxydrive.pxy");
	_LIT(KBitProxyDrive, "bitproxydrive");

	TInt r;

	TInt localDriveNumber = GetRemovableDrive(drive); //-- local _physical_ drive number
	if (localDriveNumber < 0)
		{
		test.Printf(_L("Not a removable drive, skipping test\n"));
		return;
		}


	test.Next(_L("Adding and then removing a proxy drive with an open subsession"));
	r = TheFs.AddProxyDrive(KBitProxyDriveName);
	test.Printf(_L("AddProxyDrive(%S) r %d\n"), &KBitProxyDriveName, r);
	test(r == KErrNone || r == KErrAlreadyExists);

	TPckgBuf<TInt> p1; p1() = localDriveNumber;
	TBuf<1> p2;
	TInt driveNumber = EDriveM;

    //-- this is a hack - mount the proxy drive to the existing one with alive file system just to check
    //-- that it works.

	r = TheFs.MountProxyDrive(driveNumber, KBitProxyDrive, &p1, &p2);
	test.Printf(_L("MountProxyDrive(%d, %S) r %d\n"), driveNumber, &KBitProxyDrive, r);
	test (r >= 0);

    //-- query existing file system name on the drive that we are be parasiting on.
    TFSName fsName;
    r = TheFs.FileSystemName(fsName, drive);
    test(r == KErrNone);


	r = TheFs.MountFileSystem(fsName, driveNumber);
	test.Printf(_L("MountFileSystem(%S) r %d\n"), &fsName, r);
	test(r == KErrNone);



	RFs fs;
	r = fs.Connect();
	test(r == KErrNone);


	TPath dirPath = _L("?:\\*");
	dirPath[0] = (TUint8) ('A' + driveNumber);
	RDir dir;
	r = dir.Open(fs, dirPath, KEntryAttNormal);
	test.Printf(_L("RDir::Open(%S) r %d\n"), &dirPath, r);


	r = TheFs.DismountFileSystem(fsName, driveNumber);
	test.Printf(_L("DismountFileSystem(%S) r %d\n"), &fsName, r);
	test (r == KErrInUse);

	// dismount failed - attempt a forced dismount
	TRequestStatus stat;
	TheFs.NotifyDismount(driveNumber, stat, EFsDismountForceDismount);
	User::WaitForRequest(stat);
	r = stat.Int();
	test.Printf(_L("DismountFileSystem(%S, EFsDismountForceDismount) r %d\n"), &fsName, r);
	test (r == KErrNone);

	r = TheFs.DismountProxyDrive(driveNumber);
	test.Printf(_L("DismountProxyDrive(%d) r %d\n"), driveNumber, r);
	test (r == KErrNone);

	test.Printf(_L("Calling RemoveProxyDrive()...\n"));
	r = TheFs.RemoveProxyDrive(KBitProxyDrive);
	test.Printf(_L("RemoveProxyDrive() r %d\n"), r);
	test (r == KErrNone);
	User::After(1000000);

	test.Printf(_L("closing dir (%S)....\n"), &dirPath, r);
	dir.Close();

	test.Printf(_L("closing file session()....\n"));
	fs.Close();


	test.End();
	test.Close();
	}