Ejemplo n.º 1
0
//读取存档
void TPlayerInfo::ReadPlayerInfo()
{

    RFs oFs;
    if (oFs.Connect())
    {
        return;
    };
    RFileReadStream oReadStream;
    //如果打开失败 将返回一个非0值,则返回
    if (oReadStream.Open(oFs, *iFileName, EFileRead))
    {
        oFs.Close();
        return;
    }
    //
    oReadStream.PushL();
    TInt32 playerCount;
    oReadStream >> playerCount;
    for (TInt i = 0; i < playerCount; i++)
    {
        if (i < AWARD_PLAYER_COUNT)
        {
            //iPlayerArray[i].InternalizeL(oReadStream);
            iPlayerList[i]->InternalizeL(oReadStream);
        }
    }
    oReadStream.Pop();
    oReadStream.Release();
    oFs.Close();
}
Ejemplo n.º 2
0
void CBtMsgViewerUtils::StoreMessageMimeTypeL(TPtr aMsgPath)
    {
    RFs rfs;
    RFile file;
    
    User::LeaveIfError(rfs.Connect());
    
    User::LeaveIfError(rfs.ShareProtected());
    
    User::LeaveIfError(file.Open(rfs, aMsgPath, EFileShareReadersOrWriters | EFileRead));
    
    TDataRecognitionResult dataType;
    RApaLsSession apaSession;
    
    if(apaSession.Connect() == KErrNone)
        {
        if (apaSession.RecognizeData(file, dataType) == KErrNone)
            {
            if(iMimeType)
                {
                delete iMimeType;
                iMimeType = NULL;
                }
        
            iMimeType = dataType.iDataType.Des8().AllocL();
            
            rfs.Close();
            apaSession.Close();
            }
        }

    rfs.Close();
    }
Ejemplo n.º 3
0
//存档
void TPlayerInfo::WriterPlayerInfo()
{
    RFs oFs;
    if (oFs.Connect())
    {
        return;
    };
    RFileWriteStream oWriteStream;
    if (oWriteStream.Replace(oFs, *iFileName, EFileWrite))
    {
        oFs.Close();
        return;
    };
    oWriteStream.PushL();
    TInt32 playerCount = AWARD_PLAYER_COUNT;
    oWriteStream << playerCount;
    for (TInt i = 0; i < playerCount; i++)
    {
        if (i < AWARD_PLAYER_COUNT)
        {
            //iPlayerArray[i].ExternalizeL(oWriteStream);
            iPlayerList[i]->ExternalizeL(oWriteStream);
        }
    }
    oWriteStream.CommitL();
    oWriteStream.Pop();
    oWriteStream.Release();
    oFs.Close();
}
Ejemplo n.º 4
0
// Very simple logging code. This will thrash the file server by
// creating a new session to it for every line. Create the file
// c:\logs\ct.txt to turn on logging.
EXPORT_C void SLogger::Log(const TDesC& aLogFileName, const TDesC& aString,
                           const TDesC8& aSourceFileName, TInt aLineNumber)
{
    // Open the file server and file
    RFs fs;
    fs.Connect();
    RFile file;
    TInt error = file.Open(fs, aLogFileName, EFileWrite|EFileShareAny);
    // If the file doesn't exist, exit
    if (error != KErrNone)
    {
        fs.Close();
        return;
    }
    // Seek to the end of the file
    TInt tmp = 0;
    file.Seek(ESeekEnd, tmp);

    // And do some logging
    // Name of the file where the Log function was called
    file.Write(aSourceFileName);
    // Number of the line where the Log function was called
    _LIT8(KLineNumber, ",%d:");
    TBuf8<80> buf;
    buf.Format(KLineNumber, aLineNumber);
    file.Write(buf);
    buf.Copy(aString);
    file.Write(buf);
    _LIT8(KEnd, "\r\n");
    file.Write(KEnd());

    // Close and tidy up
    file.Close();
    fs.Close();
}
Ejemplo n.º 5
0
LOCAL_C TInt MakeFileName(TInt aThreadId, TInt aFileNumber, RFs & aFs, TFileName& aName, TBool aMakeDir)
//
// creates a file name and makes all the directory components, if required
//
	{
	
	TFileName path;
	path.Format(KPath, aThreadId);
	
	TChar driveLetter;
	TInt  r;
	r = aFs.DriveToChar(gDriveNumber, driveLetter);
	if (r != KErrNone)
		{
		LogError(r, KDriveToChar, KNullDesC, driveLetter, 0);
		aFs.Close();
		return(r);
		}
		
	path[0] = (TText) driveLetter;
	r = aFs.SetSessionPath(path);
	if (r != KErrNone)
		{
		LogError(r, KSetSessPath, path, 0, 0);
		aFs.Close();
		return(r);
		}
		
	// add additional directories
	TInt fileNumber;
	fileNumber = aFileNumber;
	r = AppendPath(path, fileNumber, 0);
	if(r != KErrNone)
		{
		LogError(r, KAppendPath, path, fileNumber, 0);
		aFs.Close();
		return(r);
		}
		
	if(aMakeDir)
		{
		r = aFs.MkDirAll(path);
		if (r != KErrNone && r != KErrAlreadyExists)
			{
			LogError(r, KMdAll, path, 0, 0);
			aFs.Close();
			return(r);
			}
		}
		
	// and finally add file name
	path.Append(KFilePrefix);
	path.AppendNum(aFileNumber);

	aName = path;
	return(KErrNone);
	}
Ejemplo n.º 6
0
static TInt MainL()
{
    RDebug::Print(_L("Main() - Starting!"));

    RFs theFs;

    TInt r = theFs.Connect();
    if (r != KErrNone)
    {
        RDebug::Print(_L("Main() - Failed to connect to the fs. Error = %d"), r);
        return r;
    }

    RDebug::Print(_L("Main() - Connected to file server"));

    r = StartC32();
    if (r!=KErrNone && r !=KErrAlreadyExists)
    {
        RDebug::Print(_L("Main() - Failed to start C32. Error = %d"), r);
        return r;
    }

    RDebug::Print(_L("E32Main: Started c32"));

    RUsb usb;
    TInt err = usb.Connect();
    if (err != KErrNone)
    {
        RDebug::Print(_L("MainL() - Unable to Connect to USB server"));
        theFs.Close();
        return err;
    }
    RDebug::Print(_L("MainL() - Connected to USB server"));

    TUsbServiceState state;

    err = usb.GetCurrentState(state);
    if (err != KErrNone)
    {
        RDebug::Print(_L("MainL() - Failed to fetch service state from usbman, error %d"), err);
    }
    else
    {
        RDebug::Print(_L("MainL() - Usb service state = 0x%x"), state);
    }

    TRequestStatus status;
    usb.Start(status);
    User::WaitForRequest(status);

    RDebug::Print(_L("Start completed with status %d"), status.Int());

    theFs.Close();
    RDebug::Print(_L("MainL() - Exiting normally"));
    return KErrNone;
}
Ejemplo n.º 7
0
TPolicyID RSecMgrSession::UpdatePolicy(TPolicyID aPolicyID,
		const TDesC8& aPolicyBuffer)
	{
	TInt ret(ErrInvalidParameters);
	if(0==aPolicyBuffer.CompareC(KNullDesC8))
		{
		return ret;
		}
		
		TFileName tempDirPath;
		TFileName tempPath;
	
		{
		RFs fileSession;
		if ( KErrNone==fileSession.Connect ())
			{
			fileSession.PrivatePath (tempDirPath);
			BaflUtils::EnsurePathExistsL (fileSession, tempDirPath);

			RFile secPolicyFile;
			secPolicyFile.Temp (fileSession, tempDirPath, tempPath, EFileWrite);
			secPolicyFile.Write(aPolicyBuffer);
			secPolicyFile.Close();			
			}		
		fileSession.Close();
		}
		
	RFs fileSession;
	if ( KErrNone==fileSession.Connect ())
		{
		CleanupClosePushL (fileSession);
		if ( KErrNone==fileSession.ShareProtected ())
			{
			RFile secPolicyFile;
					
			if(KErrNone == secPolicyFile.Open(fileSession,tempPath,EFileRead))
				{
				
				ret = UpdatePolicy (aPolicyID, secPolicyFile);
			
				secPolicyFile.Close();
			
				}

			fileSession.Delete (tempPath);
			}
		
		CleanupStack::PopAndDestroy (&fileSession);//fileSession
		}

	fileSession.Close();
	
	return ret;
	}
Ejemplo n.º 8
0
/**
Implementation of pure virtual function.
@see    MWTCacheInterface::Control()
*/
TInt CDynamicDirCache::Control(TUint32 aFunction, TUint32 aParam1, TAny* aParam2)
    {
    TInt r = KErrNotSupported;
#ifdef _DEBUG
    (void)aParam2;
    switch(aFunction)
        {
        // disable / enable cache, for debug
        // if aParam1 != 0 cache will be disabled, enabled otherwise
        case EDisableCache:
            iCacheDisabled = aParam1 ? 1 : 0;
            r = KErrNone;
        break;

        // dump cache, for debug
        case EDumpCache:
            {
            RFs fs;
            fs.Connect();
            const TUint32 debugRegister = DebugRegister();
            fs.SetDebugRegister(debugRegister|KFSYS);
            Dump();
            fs.SetDebugRegister(debugRegister);
            fs.Close();
            break;
            }
        case ECacheInfo:
            {
            RFs fs;
            fs.Connect();
            const TUint32 debugRegister = DebugRegister();
            fs.SetDebugRegister(debugRegister|KFSYS);
            Info();
            fs.SetDebugRegister(debugRegister);
            fs.Close();
            break;
            }

        default:
            __PRINT1(_L("CDynamicDirCache::Control() invalid function: %d"), aFunction);
            ASSERT(0);
        break;
        }

#else
    (void)aFunction; //-- supress warnings
    (void)aParam1;
    (void)aParam2;
    User::Invariant(); //-- don't call this method in release build
#endif //_DEBUG

    return r;
    }
Ejemplo n.º 9
0
void CWebServerEnv::ReadConfigFileL(const TDesC& aConfigFileName)
//Function which reads and parse the confing file
{

	RFs fs;
#if EPOC_SDK >= 0x06000000
	User::LeaveIfError(fs.Connect());
	HBufC *config = NULL;
	// Need to TRAP leaves, because must close the fs (right).
	// Thus, no point in using the CleanupStack for config either.
	//
	TRAPD(err, config = UnicodeLoad::LoadL(fs, aConfigFileName));
	if (err == KErrNone && config != NULL)
		{
		TLineBuffer buffer(config->Des());
		while (!buffer.EOB())
			{
			TPtrC line = buffer.ReadLine();
			if (line.Length() > 0)
				{
				TRAP(err, ParseConfigLineL(fs, line));
				if (err != KErrNone)
					break;
				}
			}
		}
	delete config;
	fs.Close();
	User::LeaveIfError(err);
#else
	RFile cfg;
	TFileText cfgtxt;
	TBuf<256> buffer;

	User::LeaveIfError(fs.Connect());
	User::LeaveIfError(cfg.Open(fs,aConfigFileName,EFileStreamText));
	
	cfgtxt.Set(cfg);
	User::LeaveIfError(cfgtxt.Seek(ESeekStart));
	cfgtxt.Read(buffer);
	while (buffer.Length() > 0)
	{
		ParseConfigLineL(fs,buffer);
		cfgtxt.Read(buffer);
	}
	
	cfg.Close();

	fs.Close();
#endif
	CheckAndSetDefaultL();

}
/* Get platform info, returned format will be "Series60vX.X" */
unsigned pj_symbianos_get_platform_info(char *buf, unsigned buf_size)
{
    /* OS info */
    _LIT(KS60ProductIDFile, "Series60v*.sis");
    _LIT(KROMInstallDir, "z:\\system\\install\\");

    RFs fs;
    TFindFile ff(fs);
    CDir* result;
    pj_str_t plat_info = {NULL, 0};
    TInt err;

    fs.Connect(1);
    err = ff.FindWildByDir(KS60ProductIDFile, KROMInstallDir, result);
    if (err == KErrNone) {
	err = result->Sort(ESortByName|EDescending);
	if (err == KErrNone) {
	    TPtr8 tmp_ptr8((TUint8*)buf, buf_size);
	    const pj_str_t tmp_ext = {".sis", 4};
	    char *p;
	    
	    tmp_ptr8.Copy((*result)[0].iName);
	    pj_strset(&plat_info, buf, (pj_size_t)tmp_ptr8.Length());
	    p = pj_stristr(&plat_info, &tmp_ext);
	    if (p)
		plat_info.slen -= (p - plat_info.ptr);
	}
	delete result;
    }
    fs.Close();
    buf[plat_info.slen] = '\0';
    
    return plat_info.slen;
}
Ejemplo n.º 11
0
GLDEF_C TInt E32Main()
//
// Test Help file loading
//
    {
	__UHEAP_MARK;

	TheTest.Title();
	TheTest.Start(_L("@SYMTestCaseID PIM-TLOADER-0001"));
	TheTest(TheFs.Connect() == KErrNone);


	TheTrapCleanup = CTrapCleanup::New();
	if	(!TheTrapCleanup)
		return KErrNoMemory;

	TRAPD(r, TestL());
	TheTest(r == KErrNone);

	delete TheTrapCleanup;
	TheFs.Close();
	TheTest.End();
	TheTest.Close();

	__UHEAP_MARKEND;
	return KErrNone;
    }
TInt CUptULogger::GetDataL(TUint8*& aData, TUint& aSize)
	{
	RFs fsSession;
	CleanupClosePushL(fsSession);
	User::LeaveIfError(fsSession.Connect()); 
	
	RFile file;
	TInt error = file.Open(fsSession, KTextvalue, EFileRead);
	if(error == KErrNone)
		{
		TInt size = 0;
		file.Size(size);
		aSize = size;
		aData = new TUint8[aSize];
		if(!aData)
			error = KErrNoMemory;
		if(!error)
			{
			TPtr8 ptr(aData, aSize);
			error = file.Read(ptr);
			}
		file.Close();//is really called at fsSession.Close(); 
		fsSession.Close();
		}
	CleanupStack::PopAndDestroy();//fsSession
	return error;
	}
Ejemplo n.º 13
0
void CPlaylist::ScanDirectory(const char *dir)
{
	ResetView();

	if (!dir || !strlen(dir)) {
		RFs iFs;
		TDriveList aList;
		iFs.Connect();
		iFs.DriveList(aList);
		for (TInt i=0; i<KMaxDrives; i++) {
			if (aList[i]) {
				TChar aDrive;
				iFs.DriveToChar(i, aDrive);
				sprintf(szCurrentDir, "%c:", (TUint)aDrive);
				AddItem(szCurrentDir, 0);
			}
		}
		iFs.Close();
		FlushItemList();
		strcpy(szCurrentDir, "");
		return;
	} else {
		strcpy(szCurrentDir, dir);
		AddItem("..", 1);
	}

#ifndef GPAC_GUI_ONLY
	gf_enum_directory((const char *) szCurrentDir, 1, enum_dirs, this, NULL);
	gf_enum_directory((char *) szCurrentDir, 0, enum_files, this, view_all_files ? NULL : ext_list);
#endif
	FlushItemList();

	((COsmo4AppUi *) CEikonEnv::Static()->AppUi())->SetTitle(szCurrentDir, 0);

}
// -----------------------------------------------------------------------------
// Destructor
// -----------------------------------------------------------------------------
CHttpCacheManager::~CHttpCacheManager()
    {
#ifdef __CACHELOG__
    HttpCacheUtil::WriteLog( 0, _L("-----------------------------------------"));
    HttpCacheUtil::WriteLog( 0, _L("| Destroying CHttpCacheManager Instance | "), (TInt)this);
    HttpCacheUtil::WriteLog( 0, _L("-----------------------------------------"));
#endif
    
    if( IsBrowser() )    // only enabled in browser
        {
        // delete crashcheck.dat file
        RFs rfs;
        rfs.Connect();
        rfs.SetSessionPath( iCacheFolder );
        rfs.Delete(KCrashCheck());
        rfs.Close();
        }
    
    delete iOfflineNotifyHandler;
    delete iOfflineRepository;
    delete iCache;
    delete iOperatorCache;
    delete iOpDomain;
    delete iphoneSpecificCache;
    delete iVSSWhiteList;
    delete iFileWriteHandler;
    }
Ejemplo n.º 15
0
void CTErrorStep::FindRemovableMediaL(TDriveUnit& aDriveUnit)
	{
#ifdef __WINS__
 	aDriveUnit = EDriveX;
#else
	// The removable media is expected at D: on NAND ROM and at E: on normal ROMs.
	// The following code works on techview but not guaranteed to work on all platforms. 
	RFs fs;
	User::LeaveIfError(fs.Connect());

	TDriveInfo driveInfo;
	TInt error = fs.Drive(driveInfo, EDriveD);
	if(error == KErrNone && ((driveInfo.iDriveAtt & KDriveAttRemovable) != 0))
		{
	 	aDriveUnit = EDriveD; 	 	// Use drive D
	 	}
	 else
	 	{
		error = fs.Drive(driveInfo, EDriveE);
		if(error == KErrNone && ((driveInfo.iDriveAtt & KDriveAttRemovable) != 0))
			{
		 	aDriveUnit = EDriveE;	// Use drive E
		 	}
		}
	fs.Close();		
#endif
	}
TVerdict CSysUtilsCheckDriveLetterMMCStep::doTestStepL()
	{
	TInt drive_letter = -1;
	
//Get drive number from ini file
#ifdef __WINSCW__
	TInt expected_drive_letter;
	TESTL( GetIntFromConfig(ConfigSection(),_L("WINSMMC")  , expected_drive_letter) );	
#else	
	TInt expected_drive_letter;
	TESTL( GetIntFromConfig(ConfigSection(),_L("OTHERMMC")  , expected_drive_letter) );
#endif

	RFs session;	// This is not NULL
	session.Connect();

	drive_letter = SysUtil::GetMMCDriveLetter( session );

	if( expected_drive_letter == drive_letter )
		{
		INFO_PRINTF1(_L("GetMMCDriveLetter passed when checking against known value"));
		SetTestStepResult( EPass );
		}
	else
		{
		INFO_PRINTF2(_L("GetMMCDriveLetter failed when checking against known value %d"), drive_letter);
		SetTestStepResult( EFail );
		}

	session.Close();
	return TestStepResult();
	}
void CTestImpExvCardSuiteStepBase::OpenBDAYVCFAndImportItemL(TBuf<80> aPath,TInt aIndex)
	{
	// Format buf to hold relevant vcf file
	TFileName fileName;
#ifdef __WINS__
	fileName.Append(_L("c:"));
#else
	TFileName processFileName = RProcess().FileName();
	TParsePtrC parse(processFileName);
	fileName.Append(parse.Drive());
#endif
	fileName.Append(aPath);
	fileName.AppendNum(aIndex);
	fileName.Append(_L(".vcf"));
	
	RFs fs; 
	User::LeaveIfError(fs.Connect());  // push fs
	CleanupClosePushL(fs);
	RFileReadStream readVCFStream;
	User::LeaveIfError(readVCFStream.Open(fs, fileName, EFileRead)); // opens vcf file
	
	TBuf<MAX_TEXT_MESSAGE> message;
	message.Format(KOpenVCFFile, &fileName);
	INFO_PRINTF1(message);
	
	CleanupClosePushL(readVCFStream);   // readVCFStream

	ImportBDAYCardL(readVCFStream);
		
	CleanupStack::PopAndDestroy(); // pop readVCFStream
	fs.Close();
	CleanupStack::PopAndDestroy(); // pop fs
	}
Ejemplo n.º 18
0
TInt CRecordBySize::GetFileSize(const TFileName &aFileName, TInt & size)
{
	TInt FileError, SoundSize=0;
	RFile file;
	RFs FsSession;

	logger->Log(_L("Connecting to File Server Session") );
	FileError = FsSession.Connect();
	if (FileError)
	{
		logger->Log(_L("File error (%d)") , FileError);
		return KErrFileSize;
	}

	FileError = file.Open(FsSession, aFileName, EFileStream);
	if (FileError)
	{
		logger->Log(_L("File error (%d)") , FileError);
		return KErrFileSize;
	}

	FileError = file.Size(SoundSize);
	if (FileError)
	{
		logger->Log(_L("Error getting size") );
		return KErrFileSize;
	}

	size = SoundSize;
	file.Close();
	FsSession.Close();
	return KErrNone;
}
Ejemplo n.º 19
0
void CScrEMMCComponentStep::ImplTestStepL()
    {
    TInt noOfComponents(0);
    GetIntFromConfig(ConfigSection(), KNoOfComponents, noOfComponents);
    
    TPtrC formatDrive;
    GetStringFromConfig(ConfigSection(), KFormatDrive, formatDrive);
    TInt drive;
    RFs fs;
    User::LeaveIfError(fs.Connect());
    User::LeaveIfError(fs.CharToDrive(formatDrive[0], drive));
    fs.Close();
    TDriveList filterFormatDrive;
    filterFormatDrive.FillZ(KMaxDrives);
    filterFormatDrive[drive] = 1;
        
    CComponentFilter* componentFilter = CComponentFilter::NewLC();
    componentFilter->SetInstalledDrivesL(filterFormatDrive);
            
    RArray<TComponentId> foundComponentIds;
    CleanupClosePushL(foundComponentIds);
        
    iScrSession.GetComponentIdsL(foundComponentIds, componentFilter);
    
    if (foundComponentIds.Count() != noOfComponents)
        {
        ERR_PRINTF1(_L("Mismatch for number of components found."));
        SetTestStepResult(EFail);
        }
    CleanupStack::PopAndDestroy(2);
    }
Ejemplo n.º 20
0
// -----------------------------------------------------------------------------
// CDRMNotifierServer::ConstructL
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CDRMNotifierServer::ConstructL() 
    {
    RFs fs;

    // Ignore errors
    User::RenameThread( KNotifierThread );
    
    User::LeaveIfError( fs.Connect() );
    
    fs.Close();

#ifdef _DRM_TESTING
    _LIT( KLogFile, "notifier.txt" );
    TFileName logFile( KLogFile );
    TTime time;
    time.UniversalTime();
    
    time.FormatL( logFile, KDateTimeFormat );
    logFile.Append( KLogFile );

    iLog = CLogFile::NewL( logFile, ETrue );
    iLog->SetAutoFlush( ETrue );
    iLog->SetAutoNewline( ETrue );
    
    LOG( _L8( "DRM Server starting..." ) );
#endif
    iStorage = CDRMMessageStorage::NewL();
    
    LOG( _L8( "Notification Server started." ) );
    
    // Add the server to the scheduler.
    StartL( DRMNotifier::KServerName );
    }
Ejemplo n.º 21
0
TInt E32Main()
	{
	__UHEAP_MARK;

	CTrapCleanup* tc = CTrapCleanup::New();
	TEST(tc != NULL);
	
	TEST2(TheFileSess.Connect(), KErrNone);

	TheTest.Title();
	TRAPD(err, ::MainL());
	TEST2(err, KErrNone);
	
	TheTest.End();
	TheTest.Close();

	TheFileSess.Close();
	
	delete tc;

	__UHEAP_MARKEND;

	User::Heap().Check();
	return KErrNone;
	}
void CMtfTestActionDeleteMessageStore::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionDeleteMessageStore);
	HBufC* paramStorePath = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(0));

	TPtrC Store = paramStorePath->Des();
	RFs fs;
	fs.Connect();
	CDictionaryFileStore* store = CDictionaryFileStore::SystemLC(fs);
	const TUid KUidMsvMessageDriveStream = {0x1000163E};
	if (store->IsPresentL(KUidMsvMessageDriveStream))
		{
		store->RemoveL(KUidMsvMessageDriveStream); 
		store->CommitL();
		}
	CleanupStack::PopAndDestroy(store); 

	CFileMan* fileMan = CFileMan::NewL(fs); 
	CleanupStack::PushL(fileMan);
	TInt error;
	error = fileMan->RmDir(Store); 
	error = fs.RmDir(Store); 
	if (!(error==KErrNotFound||error==KErrNone))
		{
		User::Leave(KErrAccessDenied);
		}
	CleanupStack::PopAndDestroy(fileMan);
	fs.Close();
	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionDeleteMessageStore);
	TestCase().ActionCompletedL(*this);
	}
Ejemplo n.º 23
0
TInt CopyDataFile::CopyToPublicL(TDesC& aFileName)
{
	TInt ret=KErrNone;
	RFs iRFs;
	
	User::LeaveIfError(iRFs.Connect());	
	CFileMan* fileMan=CFileMan::NewL(iRFs);	
	
	//get the sid and convert it to hex
	TSecureId sid = RProcess().SecureId();
	TBuf<20> hex;	
	hex.Num(sid, EHex);
	hex.Append(_L("\\"));
	
	//generate the target path - C:\\ShellPublic\\$SID
	TBuf<128> path(_L("C:\\ShellPub\\"));
	path.Append(hex);
	
	//create the target directory
	TBuf<128> file (path);			
	ret=iRFs.MkDir(path);
	
	if(ret==KErrNone || ret==KErrAlreadyExists)
		{		
		//generate the absolute path of the target file
		file.Append(aFileName);
		//copy the file 
		ret=fileMan->Copy(aFileName, file);	
		}		
	
	iRFs.Close();
	delete fileMan;
	
	return ret;
}
//***********************************************************************************
GLDEF_C TInt E32Main()
//	
// TheTest the scheduler
//
    {
	__UHEAP_MARK;
	TheTest.Start(_L("OOM testing - UTC"));
	TheTest.Title();
	TheCleanup = CTrapCleanup::New();
	
	//If the previous test fails, SCHSVR.exe may stay in memory.
	TRAPD(error,CleanupHelpers::TestCleanupL());
	TEST2(error, KErrNone);

	TheTest(TheFsSession.Connect() == KErrNone);;
	TRAP(error, RunTestsL());	
	TEST2(error,KErrNone);
	TRAP(error,CleanupHelpers::TestCleanupL());
	TEST2(error, KErrNone);
	delete TheCleanup;
	
	TheFsSession.Close();
	TheTest.End();
	TheTest.Close();
	__UHEAP_MARKEND;
	return KErrNone;
	}
Ejemplo n.º 25
0
TInt E32Main()
	{
	test.SetLogged(EFalse);
	test.Title();

// For some reason, you have to do the following to
// ensure that the file server behaves properly.
	RFs fs;
	fs.Connect();
	fs.Close();

	LoadLDD_PDD();

	__UHEAP_MARK;
	CTrapCleanup* cleanupStack=CTrapCleanup::New();	// Get CleanupStack

	CActiveScheduler* activescheduler=new CActiveScheduler;
	CActiveScheduler::Install(activescheduler);

	TRAPD(err, StartL());
	if (err)
		{
		test.Printf(_L("StartL failed with error: %d!\n"), err);
		}
		
	delete activescheduler;
	delete cleanupStack;

	__UHEAP_MARKEND;

	return 0; // and return
	}
Ejemplo n.º 26
0
// ---------------------------------------------------------------------------
// From base class CRFSPlugin
// ---------------------------------------------------------------------------
//
void CIRRfsPlugin::RestoreFactorySettingsL( const TRfsReason aType )
{
    if ( aType == ENormalRfs || aType == EDeepRfs )
    {
        RFs fsSession;
        User::LeaveIfError( fsSession.Connect() );

        fsSession.Delete( KIRSettingscreFile );

		if ( aType == EDeepRfs )
		{
		    fsSession.Delete( KIRLastPlayedFile );
		    fsSession.Delete( KIRCacheDatabaseFile );
		    fsSession.Delete( KIRSdsResponseFile );
		    fsSession.Delete( KIRSessionFile );
		    fsSession.Delete( KIRNmsLog );
		    fsSession.Delete( KIRRadioReportFile );
		    fsSession.Delete( KIRLogUsageFile );
			fsSession.Delete(KSongHistoryDbFile);
		}
				
		fsSession.Close();
   	}
    else
    {
    	// RFS type not supported.
    }
}
// Return false on error load.
static bool loadDevices()
{
    TInt r = KErrNone;
#ifdef __WINS__
    RFs fileServer;
    r = User::LeaveIfError(fileServer.Connect());
    if (r != KErrNone)
        return false;
    fileServer.Close ();
#endif

    r = User::LoadPhysicalDevice(KPddName);
    if (r != KErrNone && r != KErrAlreadyExists)
        return false; //User::Leave(r);

    r = User::LoadLogicalDevice(KLddName);
    if (r != KErrNone && r != KErrAlreadyExists)
        return false; //User::Leave(r);

#ifndef __WINS__
    r = StartC32();
    if (r != KErrNone && r != KErrAlreadyExists)
        return false; //User::Leave(r);
#endif

    return true;
}
Ejemplo n.º 28
0
/**
   @SYMTestCaseID T-FileStep-testFindAllAppsRegL
  
   @SYMPREQ
  
   @SYMTestCaseDesc Test CApaAppRegFinder::FindAllAppsL() API. 
   
   @SYMTestPriority High 
  
   @SYMTestStatus Implemented
   
   @SYMTestActions The method creates an Application Finder object and calls
   CApaAppRegFinder::FindAllAppsL() to perform a complete scan of all
   available applications. It traverses through the application list by calling
   CApaAppRegFinder::NextL() to confirm that the list contains entries.\n
   API Calls:\n	
   CApaAppRegFinder::FindAllAppsL()\n
  
   @SYMTestExpectedResults Test checks the number of applications present in the list.
    
 */
void CT_File2Step::testFindAllAppsRegL()
	{
	INFO_PRINTF1(_L("Testing CApaAppRegFinder::FindAllAppsL()"));
	RFs fSession;
	fSession.Connect();
	CApaAppRegFinder* regFinder=CApaAppRegFinder::NewL(fSession);
	//
	TRAPD(ret, regFinder->FindAllAppsL(CApaAppRegFinder::EScanAllDrives) );
	TEST(ret==KErrNone);
	//
	CDesCArray* dummyArray = new (ELeave) CDesCArraySeg(1);
	CleanupStack::PushL(dummyArray);
	TBool more=ETrue;
	TInt count=0;
	while (more) 
		{
		TApaAppEntry entry;
		TRAPD(ret, more=regFinder->NextL(entry, *dummyArray) );
		TEST(ret==KErrNone);
		if (more)
			count++;
		}
	TEST(count>0);
	INFO_PRINTF2(_L("     Apps found: %D"),count);
	//
	CleanupStack::PopAndDestroy(dummyArray);
	delete regFinder;
	fSession.Close();
	}
Ejemplo n.º 29
0
/**
@SYMTestCaseID          PDS-SQL-UT-4161
@SYMTestCaseDesc        SQL server startup file I/O error simulation test
@SYMTestPriority        High
@SYMTestActions         Runs the SQL server startup code in a file I/O error simulation loop.
@SYMTestExpectedResults Test must not fail
@SYMDEF                 DEF144096
*/  
void SqlServerStartupFileIoErrorTest()
    {
    RFs fs;
    TInt err = fs.Connect();
    TEST2(err, KErrNone);
    
    for(TInt fsError=KErrNotFound;fsError>=KErrBadName;--fsError)
        {
        TheTest.Printf(_L("===Simulated error: %d\r\nIteration: "), fsError);
        err = KErrNotFound;
        TInt cnt=0;
        while(err<KErrNone)
            {
            TheTest.Printf(_L("%d "), cnt);
            (void)fs.SetErrorCondition(fsError, cnt);
            TRAP(err, CreateAndDestroySqlServerL());
            (void)fs.SetErrorCondition(KErrNone);
            if(err != KErrNone)
                {
                ++cnt;
                }
            }
        TEST2(err, KErrNone);
        TheTest.Printf(_L("\r\n===File I/O error simulation test succeeded on iteration %d===\r\n"), cnt);
        }

    fs.Close();
    }
Ejemplo n.º 30
0
GLDEF_C TInt E32Main()
	{
    // Init
	__UHEAP_MARK;
	RProcess().SetPriority(EPriorityBackground);
    CTrapCleanup* cleanupStack = CTrapCleanup::New();
    if (!cleanupStack)
        {
        return KErrNoMemory;
        }

    CActiveScheduler* activeScheduler = new CActiveScheduler;
    if (!activeScheduler)
        {
        return KErrNoMemory;
        }
    CActiveScheduler::Install(activeScheduler);

	//Get rid of the warnings.
	//T_utils2 uses efsrv.dll, but we don't use this functions in this test code.
	//So we pretend to use efsrv to keep T_utils2.obj and linker happy
	RFs fs;
	fs.Connect();
	fs.Close();

    // Run the tests
    TRAPD(err, DoTestsL());

    // Cleanup
    delete activeScheduler;
    delete cleanupStack;
	test.Close();
	__UHEAP_MARKEND;
	return err;
    }