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;
	}
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();
	}
// -----------------------------------------------------------------------------
// 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;
    }
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();
	}
Exemple #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;
    }
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();
	}