void CSettingsClient::StoreSettingL(const TDesC& aCategory,const TDesC& aName,const TFileName& aValue)
{
  TFileName old;
  TInt err=iSettings.Get(aCategory,aName,old);
  if(err!=KErrNotFound) User::LeaveIfError(err);
  if(err==KErrNotFound||old.CompareF(aValue)) User::LeaveIfError(iSettings.Set(aCategory,aName,aValue));
}
/**
 Check if a Utility Plugin is already loaded.

 @param 	A RLibrary based on the DLL file which we want to investigate if its already
 			included in iLoadedPlugins.
 @return 	The index of any CSusPluginFrame in iLoadedPlugins which is based on the same DLL file
 			as given in parameter aLibrary.
 @internalComponent
 @released
 */
TInt CSusUtilServer::IndexOf(const RLibrary& aLibrary, TInt aNewLOrdinal) const
	{
	const TFileName nameToLookFor = aLibrary.FileName();
	const TInt count = iLoadedPlugins.Count();
	for(TInt i=0; i<count; i++)
		{
		if(0 == nameToLookFor.CompareF(iLoadedPlugins[i]->FileName()) && aNewLOrdinal == iLoadedPlugins[i]->NewLOrdinal())
			{
			return i;
			}
		}
	return KErrNotFound;
	}
示例#3
0
void CCntItemMsgHandler::SetCurrentDbL(const RMessage2& aMessage)
	{
	CheckForManagerL();
	// Slot 0 in aMessage contains the new current database.
	TFileName newCurrentDb;
	ReadL(aMessage, KSlot0, newCurrentDb);
	// Is this database already open for this session? We make it a
	// pre-condition that you cannot set the current database to be one
	// that isn't already open by this client.  This prevents errors
	// whereby a client updates the current database, but then fails to
	// open it.
	if	(newCurrentDb.CompareF(iManager->CntFile()) == 0)
		{
		Server().Controller().SetCurrentDbL(newCurrentDb, iSessionId);				
		}
	aMessage.Complete(KErrNone);
	}
/*
-------------------------------------------------------------------------------

    Class: CStifFileParser

    Method: PopFromFileStack

    Description: Pops RFile handle from file stack and sets correct current file handle

    Parameters: None

    Return Values: None

    Errors/Exceptions:  None

    Status: Proposal

-------------------------------------------------------------------------------
*/
void CStifFileParser::PopFromFileStack(void)
	{
	if(!iFileStack->IsEmpty())
		{
		//Pop from stack
		iCurrentFile = iFileStack->Pop();

		TFileName fn;
		iCurrentFile->FullName(fn);

		//And remove from file names array
		for(TInt i = iFileNames.Count() - 1; i >= 0; i--)
			{
			if(fn.CompareF(iFileNames[i]->Des()) == KErrNone)
				{
				delete iFileNames[i];
				iFileNames.Remove(i);
				break;
				}
			}
		__TRACE(KInfo, (_L("Closing file [%S]"), &fn));

		//Close file
		iCurrentFile->Close();
		delete iCurrentFile;

		//Set correct current file
		if(iFileStack->IsEmpty())
			{
			iCurrentFile = &iBaseFile; //base file, because stack is empty
			}
		else
			{
			iCurrentFile = iFileStack->Last();
			}
		}
	}
示例#5
0
void TSessionTest::testSubst()
//
// Test the substitute functions.
//
	{

	test.Printf(_L("Test subst"));
	TVolumeInfo v;
	TInt r=iFs.Volume(v);
	test_KErrNone(r);
	TDriveInfo origDI;
	r=iFs.Drive(origDI);
	test_KErrNone(r);
	
	TDriveInfo driveInfo;
	r=iFs.Drive(driveInfo,EDriveO);
	test_KErrNone(r);

	testSetVolume();
	
	if (driveInfo.iDriveAtt==KDriveAttLocal)
		{	
		return;	//	Subst local drives fails
		}
	
	TFileName n;
	r=iFs.Subst(n,EDriveO);
	test_KErrNone(r);
	test(n.Length()==0);
	r=iFs.SetSubst(gTestSessionPath,EDriveO);
	test_KErrNone(r);
	r=iFs.Subst(n,EDriveO);
	test_KErrNone(r);
	test(n==gTestSessionPath);
	TVolumeInfo w;
	r=iFs.Volume(w,EDriveO);
	test_KErrNone(r);
	test(w.iDrive.iType==v.iDrive.iType);
	test(w.iDrive.iConnectionBusType==v.iDrive.iConnectionBusType);
	test(w.iDrive.iDriveAtt==KDriveAttSubsted);
	test(w.iDrive.iMediaAtt==v.iDrive.iMediaAtt);
	test(w.iUniqueID==v.iUniqueID);

    if(v.iDrive.iType != EMediaRam) // We can't assume that RAM disk will be the same size since last recorded...
    {
	    test(w.iSize==v.iSize);

    // If this test is being run under windows using drive C then skip free space comparison
    // as it is likely to fail as the windows file system is unlike to have static freespace
#ifdef __WINS__
	    if(User::UpperCase(gTestSessionPath[0]) != 'C')
		    {
#endif
		    test(w.iFree==v.iFree);

#ifdef __WINS__
		    }
#endif
    }

	test(w.iName==v.iName);
	TDriveList driveList;
	r=iFs.DriveList(driveList);
	test_KErrNone(r);
	test(driveList[EDriveO]==KDriveAttSubsted);
	TDriveInfo d;
	r=iFs.Drive(d,EDriveO);
	test_KErrNone(r);
	test(d.iDriveAtt==KDriveAttSubsted);
	test(d.iMediaAtt==origDI.iMediaAtt);
	test(d.iType==origDI.iType);
	test(d.iConnectionBusType==origDI.iConnectionBusType);


	test.Next(_L("Test real name"));
	r=iFs.RealName(_L("O:\\FILE.XXX"),n);
	test_KErrNone(r);
	TFileName substedPath=gTestSessionPath;
	substedPath.Append(_L("FILE.XXX"));
	test(n.CompareF(substedPath)==KErrNone);
//
	test.Next(_L("Test MkDir, Rename and RmDir on Substed drive"));
	_LIT(KTurgid,"turgid\\");
	TFileName dir=gTestSessionPath;
	dir+=KTurgid;
	r=iFs.MkDirAll(dir);
	test_KErrNone(r);
	dir+=_L("subdir\\");
	r=iFs.MkDir(dir);
	test_KErrNone(r);
	r=iFs.RmDir(_L("O:\\turgid\\subdir\\"));
	test_KErrNone(r);
	r=iFs.Rename(_L("O:\\turgid"), _L("O:\\facile"));
	test_KErrNone(r);
	r=iFs.MkDir(_L("O:\\insipid\\"));
	test_KErrNone(r);
	r=iFs.Rename(_L("O:\\insipid"), _L("O:\\glib"));
	test_KErrNone(r);
	r=iFs.RmDir(_L("O:\\facile\\"));
	test_KErrNone(r);
	_LIT(KGlib,"glib\\");
	dir=gTestSessionPath;
	dir+=KGlib;
	r=iFs.RmDir(dir);
	test_KErrNone(r);
	test.Next(_L("Test file operations on Substed drive"));
	_LIT(File1,"File1.txt");
	_LIT(File2,"File2.txt");
	_LIT(SubstRoot,"O:\\");
	_LIT(Subdir,"subdir\\");
	TFileName name1,name2;
	name1=gTestSessionPath;
	name1+=File1;
	RFile f1;
	r=f1.Create(iFs,name1,EFileShareExclusive|EFileWrite);
	test_KErrNone(r);
	name2=SubstRoot;
	name2+=File2;
	TBool isValid=iFs.IsValidName(name2);
	test(isValid);
	r=f1.Rename(name2);
	test_KErrNone(r);
	f1.Close();
	r=f1.Create(iFs,name1,EFileShareExclusive|EFileWrite);
	test_KErrNone(r);
	f1.Close();
	r=iFs.Replace(name2,name1);
	test_KErrNone(r);
	r=iFs.Delete(name1);
	test_KErrNone(r);
	test.Next(_L("Test notifications on Substed drive"));
	name1=gTestSessionPath;
	name1+=Subdir;
	name2=SubstRoot;
	name2+=Subdir;
	// set up some extended notifications
	TRequestStatus status1;
	TRequestStatus status2;
	TRequestStatus status3;
	iFs.NotifyChange(ENotifyDir,status1,name1);
	test(status1==KRequestPending);
	iFs.NotifyChange(ENotifyDir,status2,name2);
	test(status2==KRequestPending);
	r=iFs.MkDirAll(name1);
	test_KErrNone(r);
	User::WaitForRequest(status1);
	User::WaitForRequest(status2);
	test(status1==KErrNone && status2==KErrNone);
	iFs.NotifyChange(ENotifyDir,status1,name1);
	test(status1==KRequestPending);
	iFs.NotifyChange(ENotifyDir,status2,name2);
	test(status2==KRequestPending);
	iFs.NotifyChange(ENotifyAll,status3,name2);
	test(status3==KRequestPending);
	r=f1.Temp(iFs,name2,n,EFileShareAny|EFileWrite);
	test_KErrNone(r);
	User::WaitForRequest(status3);
	test(status3==KErrNone && status1==KRequestPending && status2==KRequestPending);
	f1.Close();
	iFs.NotifyChangeCancel();
	test(status1==KErrCancel && status2==KErrCancel);
	User::WaitForRequest(status1);
	User::WaitForRequest(status2);
	r=iFs.Delete(n);
	test_KErrNone(r);
	r=iFs.RmDir(name1);
	test_KErrNone(r);
//
	test.Next(_L("Test file systems on Substed drive"));
	// test cannot mount file system on substituted drive
	TInt sessionDrv;
	r=iFs.CharToDrive(gTestSessionPath[0],sessionDrv);
	test_KErrNone(r);
	r=iFs.FileSystemName(n,sessionDrv);
	test_Value(r, r==KErrNone || r==KErrNotFound);
	r=iFs.MountFileSystem(n,EDriveO);
	test_Value(r, r==KErrAccessDenied);
	// test file system name on substitued drive is null
	r=iFs.FileSystemName(n,EDriveO);
	test_Value(r, r==KErrNotFound && n==KNullDesC);
	// test cannot format a substitued drive
	RFormat format;
	TInt count;
	r=format.Open(iFs,SubstRoot,EHighDensity,count);
	test_Value(r, r==KErrAccessDenied);
	
	r=iFs.SetSubst(_L(""),EDriveO);
	test_KErrNone(r);
	r=iFs.Subst(n,EDriveO);
	test_KErrNone(r);
	test(n==_L(""));
	r=iFs.Drive(d,EDriveO);
	test_KErrNone(r);
	test(d.iDriveAtt==0);
	}