Esempio n. 1
0
EXPORT_C void TcLog::Write( const TDesC8& aBuf )
	{
	RFs fs;
	TInt status = fs.Connect();
	if( status == KErrNone )
		{
		// Check that the log folder exists
		TUint ignored;
		status = fs.Att( KLogDir, ignored );
		if( status == KErrNone )
			{
			RFile file;
			// If file exists, open it. Otherwise create a new file
			if( fs.Att( KLogFile, ignored ) == KErrNone )
				{
				status = file.Open( fs, KLogFile, EFileWrite | EFileShareAny );
				}
			else
				{
				status = file.Create( fs, KLogFile, EFileWrite | EFileShareAny );
				}

			if( status == KErrNone )
				{
				// Ignore errors from now on
				TInt pos( 0 );
				file.Seek( ESeekEnd, pos );
				file.Write( aBuf );
				}
			file.Close();
			}
		}
	fs.Close();
	}
Esempio n. 2
0
// -----------------------------------------------------------------------------
// CbsUtils::ExistsL
// Returns ETrue, if the file aFile exists.
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
TBool CbsUtils::ExistsL(
    const RFs& aFs,
    const TDesC& aFile )
{
    TParse filename;
    aFs.Parse( aFile, filename );

    TBool returnCode( EFalse );
    TUint attributes;

    TInt result( aFs.Att( filename.FullName(), attributes ) );
    if ( result == KErrNone )
    {
        returnCode = ETrue;
    }
    else if ( result == KErrNotFound )
    {
        returnCode = EFalse;
    }
    else
    {
        User::Leave( result );
    }
    return returnCode;
}
Esempio n. 3
0
CScsTestServer* CScsTestServer::NewLC()
/**
	Factory function allocates a new, initialized instance of CScsTestServer.

	@return					New instance of CScsTestServer, which is owned by the
							caller and left on the cleanup stack.  On return, the
							server has been started.
 */
	{
	CScsTestServer* self = new(ELeave) CScsTestServer();
	CleanupStack::PushL(self);
	RFs fs;
	User::LeaveIfError(fs.Connect());
	TUint attr;
	TInt r = fs.Att(KDisableScsTestServerTimeout(), attr);
	if(r == KErrNone)
		{
		self->ConstructL(0);
		}
	else
		{
		self->ConstructL(ScsTestImpl::KShutdownPeriodUs);
		}
	return self;
	}
TBool CWinSockProtocolFamily::RealTcpipActiveL() const
	{
	RFs fs;
	User::LeaveIfError(fs.Connect());
	CleanupClosePushL(fs);
	TUint att;
	_LIT(KTcpipEskFileName, "c:\\Private\\101f7989\\esock\\ip.tcpip.esk");
	TBool active = (fs.Att(KTcpipEskFileName, att) == KErrNone);
	CleanupStack::PopAndDestroy(&fs);
	return active;
	}
Esempio n. 5
0
/*!
    \property QPluginLoader::fileName
    \brief the file name of the plugin

    To be loadable, the file's suffix must be a valid suffix for a
    loadable library in accordance with the platform, e.g. \c .so on
    Unix, \c .dylib on Mac OS X, and \c .dll on Windows. The suffix
    can be verified with QLibrary::isLibrary().

    If the file name does not exist, it will not be set. This property
    will then contain an empty string.

    By default, this property contains an empty string.

    Note: In Symbian the \a fileName must point to plugin stub file.

    \sa load()
*/
void QPluginLoader::setFileName(const QString &fileName)
{
#if defined(QT_SHARED)
    QLibrary::LoadHints lh;
    if (d) {
        lh = d->loadHints;
        d->release();
        d = 0;
        did_load = false;
    }

#if defined(Q_OS_SYMBIAN)
    // In Symbian we actually look for plugin stub, so modify the filename
    // to make canonicalFilePath find the file, if .dll is specified.
    QFileInfo fi(fileName);

    if (fi.suffix() == QLatin1String("dll")) {
        QString stubName = fileName;
        stubName.chop(3);
        stubName += QLatin1String("qtplugin");
        fi = QFileInfo(stubName);
    }

    QString fn = fi.canonicalFilePath();
    // If not found directly, check also all the available drives
    if (!fn.length()) {
        QString stubPath(fi.fileName().length() ? fi.absoluteFilePath() : QString());
        if (stubPath.length() > 1) {
            if (stubPath.at(1).toAscii() == ':')
                stubPath.remove(0,2);
            QFileInfoList driveList(QDir::drives());
            RFs rfs = qt_s60GetRFs();
            foreach(const QFileInfo& drive, driveList) {
                QString testFilePath(drive.absolutePath() + stubPath);
                testFilePath = QDir::cleanPath(testFilePath);
                // Use native Symbian code to check for file existence, because checking
                // for file from under non-existent protected dir like E:/private/<uid> using
                // QFile::exists causes platform security violations on most apps.
                QString nativePath = QDir::toNativeSeparators(testFilePath);
                TPtrC ptr(qt_QString2TPtrC(nativePath));
                TUint attributes;
                TInt err = rfs.Att(ptr, attributes);
                if (err == KErrNone) {
                    fn = testFilePath;
                    break;
                }
            }
        }
/**
*
* InitSystemPath
* This sets up the default path
* 
*/
void CTestSuite_MMF_SwCodecDevices::InitSystemPath()
	{
	_LIT(KAudioStremOutSourcePathOnC,"c:\\mm\\mmf\\testfiles\\SwCodecDevices\\");

	RFs fs;
	TUint att;
	TInt ret = fs.Connect();
	__ASSERT_ALWAYS(ret == KErrNone,User::Panic(_L("Sys path not setup"),ret));

	if (fs.Att(KAudioStremOutSourcePathOnC, att) == KErrNone)
		iDefaultPath = KAudioStremOutSourcePathOnC;
	else
		User::Panic(_L("Test files not found"),KErrNotFound);

	fs.Close();
	}
Esempio n. 7
0
int PosixFilesystem::unlink (RFs& aFs, const wchar_t* name, int& anErrno)
{
    TFullName fullName;
    TInt err=GetFullFile(fullName, (TText16*)name, aFs);
    if (!err)
    {
        TUint att=0;
        err=aFs.Att(fullName, att);
        if (!err)
            if (att&KEntryAttDir)
                err=EPERM;
            else
                err=aFs.Delete(fullName);
    }
    return MapError(err, anErrno);
}
bool DirChecker::checkDir(const QDir& dir)
{
    bool pathFound = false;
    // In Symbian, going cdUp() in a c:/private/<uid3>/ will result in *platsec* error at fileserver (requires AllFiles capability)
    // Also, trying to cd() to a nonexistent directory causes *platsec* error. This does not cause functional harm, but should
    // nevertheless be changed to use native Symbian methods to avoid unnecessary platsec warnings (as per qpluginloader.cpp).
    // Use native Symbian code to check for directory existence, because checking
    // for files from under non-existent protected dir like E:/private/<uid> using
    // QDir::exists causes platform security violations on most apps.
    QString nativePath = QDir::toNativeSeparators(dir.absolutePath());
    TPtrC ptr = TPtrC16(static_cast<const TUint16*>(nativePath.utf16()), nativePath.length());
    TUint attributes;
    TInt err = rfs.Att(ptr, attributes);
    if (err == KErrNone) {
        // yes, the directory exists.
        pathFound = true;
    }
    return pathFound;
}
Esempio n. 9
0
int PosixFilesystem::chdir (RFs& aFs, const wchar_t* aPath, int& anErrno)
{
    TParse name;
    TInt err=GetFullPath(name, (const TText16 *)aPath, aFs, NULL);
    if (!err)
    {
        TPtrC path=name.DriveAndPath();
        TUint att=0;
        if (path.Length()==3)	// Problem in F32 - the root directory has no attributes
            att=KEntryAttDir;
        else
            err=aFs.Att(path, att);
        if (!err)
            if (att&KEntryAttDir)
                err=aFs.SetSessionPath(path);
            else
                err=ENOTDIR;
    }
    return MapError(err,anErrno);
}
Esempio n. 10
0
int PosixFilesystem::rmdir (RFs& aFs, const wchar_t* aPath, int& anErrno)
{
    TParse name;
    TInt err=GetFullPath(name,(const TText16 *)aPath,aFs,NULL);
    if (!err)
    {
        TPtrC path=name.DriveAndPath();
        TUint att=0;
        if (path.Length()==3)
            err=EPERM;	// no, you may not remove the root directory
        else
            err=aFs.Att(path, att);
        if (!err)
            if (att&KEntryAttDir)
            {
                err=aFs.RmDir(path);
                if (err==KErrInUse)
                    err=EEXIST;	// i.e. directory not empty
            }
            else
                err=ENOTDIR;
    }
    return MapError(err,anErrno);
}
//
// Set the Default CommDb Combination
//
void CreateCommDbL()
/**
 * This method creates a special Communications Database to be used with the regression test
 * harness.  The user is given a chance to cancel this operation.  This method uses the file
 * server and timer services.  It also calls other methods to actually populate the
 * special communications database.  Note that the communications database created is tailored
 * to the needs of the ETel Regression Test harness.
 *
 * @leave	This method leaves if the user cancels the overwrite of the communications
 *			database or if the NewL method called in this method fails.  Also, the database
 *			functions can also leave.
 */
	{
	RFs fs;
	_LIT(KSvDbFileName,"C:\\System\\Data\\Cdbv3.dat");

	TESTL(fs.Connect()==KErrNone);

	RTimer timer;
	timer.CreateLocal();
	TUint dummy;
	if(fs.Att(KSvDbFileName,dummy)==KErrNone)
		{
		INFO_PRINTF1(_L("\nThis test requires a special CommDb Database.\nExisting Database File detected\nPress any key to STOP Overwrite\n\n"));

		TBool keyPressed=ETrue;
		ShortWaitForKey(5,keyPressed);
		if(keyPressed)
		User::Leave(KErrAlreadyExists);

		INFO_PRINTF1(_L("\n"));
		TESTL(fs.Delete(KSvDbFileName)==KErrNone);
		}
	fs.Close();

	TheDb=CCommsDatabase::NewL(EDatabaseTypeIAP);
	CleanupStack::PushL(TheDb);
	TESTL(TheDb->BeginTransaction()==KErrNone);

//
// Write the database tables
//
	TUint32 ispId=CreateISPTableL();
	CreateModemTablesL();
	CreateLocationTablesL();
	PopulateModemTemplateL();

	CCommsDbTableView* table=TheDb->OpenTableLC(TPtrC(IAP));

	TUint32 id;
	TESTL(table->InsertRecord(id)==KErrNone);
	table->WriteTextL(TPtrC(COMMDB_NAME),_L("Test Configuration: MM Loopback"));
	table->WriteUintL(TPtrC(IAP_SERVICE),ispId);
	table->WriteTextL(TPtrC(IAP_SERVICE_TYPE),TPtrC(DIAL_OUT_ISP));
	TESTL(table->PutRecordChanges()==KErrNone);
//
// Set the Default
//
	CCommsDbConnectionPrefTableView* cpTable=TheDb->OpenConnectionPrefTableViewOnRankLC(ECommDbConnectionDirectionOutgoing,1);
	cpTable->GotoFirstRecord();
	CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref;
	cpTable->ReadConnectionPreferenceL(pref);
	pref.iBearer.iIapId=id;
	pref.iBearer.iBearerSet = KCommDbBearerCSD;
	cpTable->UpdateBearerL(pref.iBearer);

	CleanupStack::PopAndDestroy();
	TESTL(TheDb->CommitTransaction()==KErrNone);
	CleanupStack::PopAndDestroy();
	CleanupStack::PopAndDestroy();
	}
/* Read in quality profile information from the given .ini file.

The file will likely have multiple quality profiles in it, so
each one must be read in and stored in the given array

@param aFile File to parse for quality profile information
@param aQualityArray Array in which to store the parsed quality profile info.
*/
void CQualityProfileApi_ProfileReadStep::GetQualityProfileInfoL(RFs& aFs, 
		    							RArray<TQualityProfile>& aQualityArray,
		    							const TDesC& aFileName)
	{
  
    // Check the file is present.
	TUint att;
	TInt err = aFs.Att(aFileName, att);
	if(err != KErrNone)
		{
		User::Leave(err);
		}

	// Open the .ini file reader
    CLbsIniFileReader* fileReader = CLbsIniFileReader::NewL(aFs, aFileName);
	CleanupStack::PushL(fileReader);

	_LIT(KKeyProfileID, "ProfileID");
	_LIT(KKeyMaxTime, "MaxTime");
	_LIT(KKeyHorizontalAccuracy, "HorizontalAccuracy");
	_LIT(KKeyVerticalAccuracy, "VerticalAccuracy");
	_LIT(KKeyMeasurementInitialTime, "MeasurementInitialTime");
	_LIT(KKeyMeasurementIntermediateTime, "MeasurementIntermediateTime");
	_LIT(KFinalNetPositionLag, "FinalNetPositionLag");
	
	// Read in all the quality profile info, section by section.
	while (fileReader->FindNextSection())
		{
		TInt result;
		TBool foundVar = fileReader->FindVar(KKeyProfileID, result);
		if (foundVar)
			{
			TQualityProfile qualityProfile;
			
			// Set the profile Id
			qualityProfile.SetQualityProfileId(result);
			
			// Set the request quality
			foundVar = fileReader->FindVar(KKeyMaxTime, result);
			if (foundVar)
				{
				TTimeIntervalMicroSeconds microseconds = static_cast<TInt64>(result) * KSecToMicroSecTransfer;
				qualityProfile.SetMaxFixTime(microseconds);
				}

			TReal32 resultReal32;
			foundVar = fileReader->FindVar(KKeyHorizontalAccuracy, resultReal32);
			if (foundVar)
				{
				qualityProfile.SetMinHorizontalAccuracy(resultReal32);
				}

			foundVar = fileReader->FindVar(KKeyVerticalAccuracy, resultReal32);
			if (foundVar)
				{
				qualityProfile.SetMinVerticalAccuracy(resultReal32);
				}

			foundVar = fileReader->FindVar(KKeyMeasurementInitialTime, result);
			if (foundVar)
				{
				TTimeIntervalMicroSeconds microseconds = static_cast<TInt64>(result) * KSecToMicroSecTransfer;
				qualityProfile.SetMeasurementInitialFixTime(microseconds);
				}

			foundVar = fileReader->FindVar(KKeyMeasurementIntermediateTime, result);
			if (foundVar)
				{
				TTimeIntervalMicroSeconds microseconds = static_cast<TInt64>(result) * KSecToMicroSecTransfer;
				qualityProfile.SetMeasurementIntermediateFixTime(microseconds);
				}
			
 			foundVar = fileReader->FindVar(KFinalNetPositionLag, result);
 			if (foundVar)
 				{
				TTimeIntervalMicroSeconds microseconds = static_cast<TInt64>(result) * KSecToMicroSecTransfer;
				qualityProfile.SetFinalNetPositionLag(microseconds);
 				}
			
			// Add the quality profile to the list
			User::LeaveIfError(aQualityArray.Append(qualityProfile));
			}
		}

	CleanupStack::PopAndDestroy(fileReader);	
	}
Esempio n. 13
0
//-----------------------------------------------------------------------------
//Function Name : void* __dlopen_r(const char* filename, int flag)
//Description   : To open the given dll filename.
//Return Value  : Valid handle value if no error, Null if dll couldn't be loaded 
//-----------------------------------------------------------------------------
void* __dlopen_r(const char* filename,const int flag)
	{
	//convert filename to TFileName
	TPtrC8 ptr8( (unsigned char*)filename);
	TFileName fileNameBuf;
	CnvUtfConverter::ConvertToUnicodeFromUtf8(fileNameBuf, ptr8);
	TParsePtr filePathName(fileNameBuf);
	
	//if file name contains wild character
	if ( filePathName.IsWild() )
		{
		SetError(KDlOpenErrNoSupport);
		return NULL;
		}
	//to load dll	
	RLibrary library;	
	TInt err;
	TBool isLibraryLoaded = EFalse;
	RFs fs;
	err = fs.Connect();
	if ( KErrNone == err )
		{
		TUint tempAtt;
		//if path is there load from this path
		if ( filePathName.PathPresent() )
			{
			err = fs.Att(filePathName.FullName(), tempAtt);
			fs.Close();	
			if ( KErrNotFound != err && KErrPathNotFound != err)
				{
				err = library.Load(filePathName.FullName());
				if ( KErrNone != err )
					{
					SetError(KDlOpenErrLoading);
					return NULL;
					}
				isLibraryLoaded = ETrue;	
				}
			}
		else//if there is no path its only file name
			{
			TPtrC fileName(filePathName.NameAndExt());
			char* envPathName = getenv("LD_LIBRARY_PATH");
			if ( envPathName )
				{
				TPtrC8 tempPtr8((unsigned char*)envPathName);
				TFileName envPathBuf;
				CnvUtfConverter::ConvertToUnicodeFromUtf8(envPathBuf, tempPtr8);
				TPtrC envPath(envPathBuf);
				TChar delim(';');
				TFileName fileToLoad;
				TInt pos = envPath.Locate(delim);
				//if delim does not found and still envPath contains value
				//i.e. this one is last path without delim(';') so take 
				//this also, for this length is checked
				while ( KErrNotFound != pos || envPath.Length())
					{
					//if there is no delim
					if (KErrNotFound == pos )
						{// so last path without delim
						pos = envPath.Length();
						}
					TPtrC thisPath(envPath.Left(pos));
					fileToLoad = thisPath;
					fileToLoad.Trim();
					//to check ";;" and ";   ;"
					if (fileToLoad.Length())
						{
						//if path does not conatin trailing \ add one
						if ( L'\\' != fileToLoad[fileToLoad.Length()-1] )
							{
							fileToLoad.Append(TChar(L'\\'));					
							}
						fileToLoad.Append(fileName);
					
						err = fs.Att(fileToLoad, tempAtt);
						if ( KErrNotFound != err && KErrPathNotFound != err)
							{
							//load file from this path
							err = library.Load(fileToLoad);
							if ( KErrNone == err )
								{
								// dll loaded successfully from thispath
								isLibraryLoaded = ETrue;	
								break;
								}	
							}
						}
					if ( pos == envPath.Length())		
						{
						break;
						}
					else
						{
						envPath.Set(envPath.Mid(pos + 1));
						}
					pos = envPath.Locate(delim);
					}
				fs.Close();	
				}
			else//load dll if only name is there and LD_LIBRARY_PATH path not set
				{
				fs.Close();	
				TInt err = library.Load(filePathName.NameAndExt());
				if ( KErrNone != err )
					{
					SetError(KDlOpenErrLoading);
					return NULL;
					}
				isLibraryLoaded = ETrue;		
				}
			}
	
		//if library is loaded	
		if ( isLibraryLoaded )	
			{
			//handle value to return 
			void* handle  = NULL;
			//lock list before any operation
			LoadedDlls()->Lock();
			//is this dll already there
			TInt listIdx = LoadedDlls()->Find(library);
			//if not already open
			if ( KErrNotFound == listIdx )
				{				
				TDllEntry dllEntry(library, flag);
				dllEntry.iSymbolHeader = (TE32ExpSymInfoHdr*)library.Lookup(0);
				
				err = dllEntry.iLibrary.Duplicate(RThread());	
				//Close the library irrespective of the result of duplicate
				library.Close();
				if ( KErrNone != err )
					{
					SetError(KDlOpenErrLoading);
					LoadedDlls()->UnLock();
					return NULL;
					}
				//add to list	
				err = LoadedDlls()->Add(dllEntry);
				handle = (void*) dllEntry.iLibrary.Handle();
				LoadedDlls()->UnLock();
				if ( KErrNone != err )
					{
					SetError(KDlOpenErrNoMemory);
					dllEntry.iLibrary.Close();
					return NULL;
					}
				}
			else//if this dll is already in list.
				{
				//close library we already have loaded
				library.Close();
				TDllEntry& dllEntry = LoadedDlls()->At(listIdx);
				//if flag is RTLD_GLOBAL store it otherwise ignore
				//as RTLD_LAZY and RTLD_NOW both means RTLD_NOW
				//so can be ignored. RTLD_LOCAL does not change previous flag
				if ( flag & RTLD_GLOBAL )
					{
					dllEntry.iFlags |= RTLD_GLOBAL;
					}
				dllEntry.iRefCount++;	
				handle = (void*) dllEntry.iLibrary.Handle();
				LoadedDlls()->UnLock();	
				}	
			return handle;			
			}
		}
	SetError(KDlOpenErrLoading);
	return NULL;		
	}