void DeleteTestFiles()
	{
	if(TheDbName.Length() > 0)
		{
		(void)TheFs.Delete(TheDbName);
		}
	(void)TheFs.Delete(KTestFile3);
	(void)TheFs.Delete(KTestFile);
	}
/**
@SYMTestCaseID          PDS-SQL-CT-4212
@SYMTestCaseDesc        RFileBuf64::Write() test.
                        The test performs file write operations using RFileBuf64 class.
                        Teh test sumilates the write operation at the conditions:
                        
                        1. There are 8 pages to be writted to the file.
                        2. Each page is 16 bytes
                        3. The size of RFileBuf64 is 4 pages, i.e. 64 bytes.
                        4. The order of write is not sequential.
 
@SYMTestActions         Write database pages.
@SYMTestExpectedResults Test must not fail
@SYMTestPriority        High
*/
void TestSetSizeCounter()
    {
    const TInt KPageSize = 16;
    const TInt KBufSize = 4 * KPageSize;
    RFileBuf64 fbuf(KBufSize);
    (void)TheFs.Delete(KTestFile);
    TInt err = fbuf.Create(TheFs, KTestFile, EFileRead | EFileWrite);
    TEST2(err, KErrNone); 
    const TInt KMaxPage = 8;
    TUint8 fileData[KMaxPage][KPageSize];
    TPtrC8 pageData[KMaxPage];
    for(TInt i = 0;i <KMaxPage;++i)
        {
        Mem::Fill(fileData[i], KPageSize, TChar('a' + i));
        const TUint8* p = fileData[i]; 
        pageData[i].Set(p, KPageSize);
        }
    //
    fbuf.ProfilerReset();
    //Write the first 4 pages
    for (TInt ii = 0; ii < 4; ii++)
        {
        err = fbuf.Write(ii * KPageSize, pageData[ii]);
        TEST2(err, KErrNone);
        }
    //Write page #2
    err = fbuf.Write(2 * KPageSize, pageData[2]);
    TEST2(err, KErrNone);
    //
    TEST2(fbuf.iFileWriteCount, 0);
    TEST2(fbuf.iFileSetSizeCount, 0);
    //Write pages 5, 4, 6, 7
    err = fbuf.Write(5 * KPageSize, pageData[5]);
    TEST2(err, KErrNone);
    //
    TEST2(fbuf.iFileWriteCount, 1);
    TEST2(fbuf.iFileSetSizeCount, 0);
    //
    err = fbuf.Write(4 * KPageSize, pageData[4]);
    TEST2(err, KErrNone);
    err = fbuf.Write(6 * KPageSize, pageData[6]);
    TEST2(err, KErrNone);
    err = fbuf.Write(7 * KPageSize, pageData[7]);
    TEST2(err, KErrNone);
    //
    TEST2(fbuf.iFileWriteCount, 1);
    TEST2(fbuf.iFileSetSizeCount, 0);
    //
    err = fbuf.Flush();
    TEST2(err, KErrNone);
    //
    TEST2(fbuf.iFileWriteCount, 2);
    TEST2(fbuf.iFileSetSizeCount, 0);
    //
    fbuf.Close();
    (void)TheFs.Delete(KTestFile);
    }
/**
@SYMTestCaseID			SYSLIB-SQL-UT-3433
@SYMTestCaseDesc		Test for DEF104744 - RSqlStatement::Next() SQL Server crashes on ORDER BY clause.
						The test creates a database with a table with 30 integer columns, then inserts 100
						records. After that, sets the soft heap limit to be very low - 10K 
						(to get sqlite3_release_memory() called by SQLITE ), creates a statement object 
						and attempts to retrieve the inserted records in descending order.
@SYMTestPriority		High
@SYMTestActions			Test for DEF104744 - RSqlStatement::Next() SQL Server crashes on ORDER BY clause.
@SYMTestExpectedResults Test must not fail
@SYMDEF					DEF104744
*/
void DEF104744()
	{
	(void)TheFs.Delete(KTestDatabase);
	TheSqliteDb = NULL;
	TInt err = sqlite3_open((const char*)KTestDatabaseZ().Ptr(), &TheSqliteDb);
	TEST2(err, SQLITE_OK);
	
	_LIT8(KCreateTblSqlZ, "CREATE TABLE A1(F1 INTEGER,F2 INTEGER,F3 INTEGER,F4 INTEGER,F5 INTEGER,F6 INTEGER,F7 INTEGER,F8 INTEGER,F9 INTEGER,F10 INTEGER,F11 INTEGER,F12 INTEGER,F13 INTEGER,F14 INTEGER,F15 INTEGER,F16 INTEGER,F17 INTEGER,F18 INTEGER,F19 INTEGER,F20 INTEGER,F21 INTEGER,F22 INTEGER,F23 INTEGER,F24 INTEGER,F25 INTEGER,F26 INTEGER,F27 INTEGER,F28 INTEGER,F29 INTEGER,F30 INTEGER)\x0");
	err = sqlite3_exec(TheSqliteDb, (const char*)KCreateTblSqlZ().Ptr(), 0, 0, 0);
	TEST2(err, SQLITE_OK);

	//Insert a 100 records
	const TInt KTestRecCnt = 100;
	_LIT8(KInsertSqlZ, "INSERT INTO A1(F1,F2 ,F3 ,F4 ,F5 ,F6 ,F7 ,F8 ,F9 ,F10,F11,F12,F13,F14,F15,F16,F17,F18,F19,F20,F21,F22,F23,F24,F25,F26,F27,F28,F29,F30) VALUES(:Prm1,:Prm2,4294967296,4294967296,4294967296,4294967296,4294967296,4294967296,4294967296,4294967296,4294967296,4294967296,4294967296,4294967296,4294967296,4294967296,4294967296,4294967296,4294967296,4294967296,4294967296,4294967296,4294967296,4294967296,4294967296,4294967296,4294967296,4294967296,4294967296,4294967296)\x0");
	sqlite3_stmt* stmt1 = NULL;
	err = sqlite3_prepare_v2(TheSqliteDb, (const char*)(KInsertSqlZ().Ptr()), -1, &stmt1, NULL);
	TEST2(err, SQLITE_OK);
	
	_LIT8(KBeginSqlZ, "BEGIN\x0");
	err = sqlite3_exec(TheSqliteDb, (const char*)KBeginSqlZ().Ptr(), 0, 0, 0);
	TEST2(err, SQLITE_OK);
	
	for(TInt i=0;i<KTestRecCnt;++i)
		{ 
		err = sqlite3_bind_int(stmt1, 1, i);
		TEST2(err, SQLITE_OK);
		err = sqlite3_bind_int(stmt1, 2, i + 1);
		TEST2(err, SQLITE_OK);
		err = sqlite3_step(stmt1);
		TEST2(err, SQLITE_DONE);
		err = sqlite3_reset(stmt1);
		TEST2(err, SQLITE_OK);
		TInt cnt = sqlite3_changes(TheSqliteDb);
		TEST2(cnt, 1);
		}
		
	_LIT8(KCommitSqlZ, "COMMIT\x0");
	err = sqlite3_exec(TheSqliteDb, (const char*)KCommitSqlZ().Ptr(), 0, 0, 0);
	TEST2(err, SQLITE_OK);
	sqlite3_finalize(stmt1);

	sqlite3_soft_heap_limit(10 * 1024);//Setting very low soft heap limit - 10K

	// Get the inserted record data in descending order.
	sqlite3_stmt* stmt2 = NULL;
	_LIT8(KSelectSqlZ,"SELECT * FROM A1 ORDER BY F1 DESC");
	err = sqlite3_prepare_v2(TheSqliteDb, (const char*)(KSelectSqlZ().Ptr()), -1, &stmt2, NULL);
	TEST2(err, SQLITE_OK);
	err = sqlite3_step(stmt2);
	TEST2(err, SQLITE_ROW);
	sqlite3_finalize(stmt2);

	sqlite3_close(TheSqliteDb); 
	TheSqliteDb = NULL;
	(void)TheFs.Delete(KTestDatabase);
	}
// ---------------------------------------------------------------------------
// 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.
    }
}
/**
@SYMTestCaseID			PDS-SQL-UT-4197
@SYMTestCaseDesc		RFileBuf64::Temp() file I/O error simulation test.
						The test calls RFileBuf64:Temp() in a file I/O error simulation loop.
@SYMTestActions			RFileBuf64::temp() file I/O error simulation test.
@SYMTestExpectedResults Test must not fail
@SYMTestPriority		High
@SYMDEF					DEF145198
*/
void TempFileIoErrTest()
	{
    TInt err = KErrGeneral;
    TInt cnt = 0;
    for(;err<KErrNone;++cnt)
        {
        TheTest.Printf(_L("===Iteration %d. Simulated error:\r\n"), cnt);       
        for (TInt fsError=KErrNotFound;fsError>=KErrBadName;--fsError)
            {
            TheTest.Printf(_L("%d "), fsError);
        	__UHEAP_MARK;
            (void)TheFs.SetErrorCondition(fsError, cnt);
        	RFileBuf64 fbuf(1024);//buffer capacity = 1024 bytes
        	TFileName tmpFileName;
			err = fbuf.Temp(TheFs, KTestDir, tmpFileName, EFileWrite | EFileRead);
            (void)TheFs.SetErrorCondition(KErrNone);
            fbuf.Close();
            __UHEAP_MARKEND;
			TInt err2 = TheFs.Delete(tmpFileName);
			TInt expectedErr = err == KErrNone ? KErrNone : KErrNotFound;
			TEST2(err2, expectedErr);
            }
        TheTest.Printf(_L("\r\n"));
        }
    TheTest.Printf(_L("\r\n===File I/O error simulation test succeeded on iteration %d===\r\n"), cnt);
	}
/**
@SYMTestCaseID			PDS-SQL-UT-4196
@SYMTestCaseDesc		RFileBuf64::Open() file I/O error simulation test.
						The test calls RFileBuf64:Open() in a file I/O error simulation loop.
@SYMTestActions			RFileBuf64::Open() file I/O error simulation test.
@SYMTestExpectedResults Test must not fail
@SYMTestPriority		High
@SYMDEF					DEF145198
*/
void OpenFileIoErrTest()
	{
	RFileBuf64 fbuf(1024);//buffer capacity = 1024 bytes
	TInt err = fbuf.Create(TheFs, KTestFile3, EFileRead | EFileWrite);
	fbuf.Close();
	TEST2(err, KErrNone);
    err = KErrGeneral;
    TInt cnt = 0;
    for(;err<KErrNone;++cnt)
        {
        TheTest.Printf(_L("===Iteration %d. Simulated error:\r\n"), cnt);       
        for (TInt fsError=KErrNotFound;fsError>=KErrBadName;--fsError)
            {
            TheTest.Printf(_L("%d "), fsError);
        	__UHEAP_MARK;
            (void)TheFs.SetErrorCondition(fsError, cnt);
        	err = fbuf.Open(TheFs, KTestFile3, EFileRead | EFileWrite);
            (void)TheFs.SetErrorCondition(KErrNone);
            fbuf.Close();
            __UHEAP_MARKEND;
            }
        TheTest.Printf(_L("\r\n"));
        }
    TheTest.Printf(_L("\r\n===File I/O error simulation test succeeded on iteration %d===\r\n"), cnt);
	(void)TheFs.Delete(KTestFile3);
	}
Beispiel #7
0
void TTestMsBlock::tFileAccess()
    {
    test.Start(_L("tFileAccess\n"));

    test.Next(_L("DriveInfo"));
    PrintDrvInfo(fsSession, msDrive->DriveNumber());

    TVolumeInfo volInfo;
    TInt err = fsSession.Volume(volInfo);
    test(err == KErrNone);

    test.Printf(_L("Memory 'in use' = %lx\n"), (volInfo.iSize - volInfo.iFree));
    test.Printf(_L("volInfo.iSize = %lx\n"), volInfo.iSize);
    test.Printf(_L("volInfo.iFree = %lx\n"), volInfo.iFree);

    //-- 1. create a file
    _LIT(KFile, "\\test_file.file");
    const TUint KFileSz = 54321;

    test.Next(_L("Write file\n"));
    err = CreateCheckableStuffedFile(fsSession, KFile, KFileSz);
    test_KErrNone(err);

    //-- 2. verify the file, just in case.
    test.Next(_L("Verify file\n"));
    err = VerifyCheckableFile(fsSession, KFile);
    test_KErrNone(err);

    //-- 3. delete the file
    test.Next(_L("Delete file\n"));
    fsSession.Delete(KFile);
    test.End();
    }
// -----------------------------------------------------------------------------
// RDRMRightsClient::ExportContentIDList
// Overloaded method: requests all content IDs to be put to a file,
// and then converts the file into RPointerArray.
// -----------------------------------------------------------------------------
//
EXPORT_C TInt RDRMRightsClient::ExportContentIDList( RPointerArray< HBufC8 >& aCIDList )
    {
    DRMLOG( _L( "RDRMRightsClient::ExportContentIDList to array" ) );
    TFileName name;
    aCIDList.ResetAndDestroy();

    TInt error = ExportContentIDList( name );
    if ( !error )
        {
        RFs fs;
        error = fs.Connect();
        if ( !error )
            {
            TRAP( error, URIFileToArrayL( fs, name, aCIDList ) );
            if ( error )
                {
                aCIDList.ResetAndDestroy();
                }

            fs.Delete( name );
            fs.Close();
            }
        }

    DRMLOG2( _L( "RDRMRightsClient::ExportContentIDList: %d" ), error );

    return error;
    }
void ThreadTestL(TInt aThread)
	{
	RFs fs;
	User::LeaveIfError(fs.Connect());
	CleanupClosePushL(fs);

	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
	TParse testIniFile;
	testIniFile.Set(drive.Name(), &KTestIniFile, NULL);
	
	TIniData data;
	CDictionaryStore* dict=CDictionaryFileStore::OpenLC(fs,testIniFile.FullName(),KTestUid);
	data.LoadL(*dict);
	CleanupStack::PopAndDestroy(); // dict

	TParse threadTestPath;
	threadTestPath.Set(drive.Name(), &KThreadTestPath, NULL);
	
	TFileName name;
	name.Format(threadTestPath.FullName(),aThread);
	dict=CDictionaryFileStore::OpenLC(fs,name,KTestUid);
	data.SaveL(*dict);
	dict->CommitL();
	CleanupStack::PopAndDestroy();
	TReal x=0.501;
	for (TInt ii=0;ii<1000;++ii)
		x=4.0*x*(1.0-x);
	dict=CDictionaryFileStore::OpenLC(fs,name,KTestUid);
	data.LoadL(*dict);
	CleanupStack::PopAndDestroy();	// dict
	fs.Delete(name);
	CleanupStack::PopAndDestroy();	// fs
	}
LOCAL_C void StartupUninstallL(TBool aIsSetup)
{
	if(aIsSetup)
		{
		RFs fs;
		User::LeaveIfError(fs.Connect());
		CleanupClosePushL(fs);
		CFileMan* fm = CFileMan::NewL(fs);
		CleanupStack::PushL(fm);

		// Copy rev 1 file into install dir & Reset read-only bit
		User::LeaveIfError(fm->Copy(KInstallOnlyFile, KInstallFile));
		User::LeaveIfError(fm->Attribs(KInstallFile,0,KEntryAttReadOnly,TTime(0)));

		// Cause directory listing to be written and file to be installed
		CCentRepSWIWatcher*	swiWatcher = CCentRepSWIWatcher::NewL(TServerResources::iFs);
		delete swiWatcher;

		// Create a persists file that will be deleted
		User::LeaveIfError(fm->Copy(KPersistsFileUpgraded, KInstallPersistsFile));
		User::LeaveIfError(fm->Attribs(KInstallPersistsFile,0,KEntryAttReadOnly,TTime(0)));

		TInt err=fs.Delete(KInstallFile);
		if((err!=KErrNone)&&(err!=KErrNotFound))
			User::Leave(err);

		CleanupStack::PopAndDestroy(2); // fs and fm
		}
	else
		{
		CCentRepSWIWatcher*	swiWatcher = CCentRepSWIWatcher::NewL(TServerResources::iFs);
		delete swiWatcher;
		}
}
LOCAL_C void StartupUpgradeL(TBool aIsSetup)
{
	if(aIsSetup)
		{
		// Set up files for test
		RFs fs;
		User::LeaveIfError(fs.Connect());
		CleanupClosePushL(fs);
		CFileMan* fm = CFileMan::NewL(fs);
		CleanupStack::PushL(fm);

		// Clean out files
		TInt err=fs.Delete(KInstallDirFile);
		if((err!=KErrNone)&&(err!=KErrNotFound))
			User::Leave(err);

		// Cause directory listing with no files to be written
		CCentRepSWIWatcher*	swiWatcher = CCentRepSWIWatcher::NewL(TServerResources::iFs);
		delete swiWatcher;

		User::LeaveIfError(fm->Copy(KPersistsFileNoUpgrade, KPersistsFile));
		User::LeaveIfError(fm->Attribs(KPersistsFile,0,KEntryAttReadOnly,TTime(0)));

		User::LeaveIfError(fm->Copy(KRomUpgradeRev1File, KUpgradeFile));
		User::LeaveIfError(fm->Attribs(KUpgradeFile,0,KEntryAttReadOnly,TTime(0)));

		CleanupStack::PopAndDestroy(2); // fs and fm
		}
	else
		{
		CCentRepSWIWatcher*	swiWatcher = CCentRepSWIWatcher::NewL(TServerResources::iFs);
		delete swiWatcher;
		}
}
/**
@SYMTestCaseID			PDS-SQL-UT-4135
@SYMTestCaseDesc		RFileBuf64 write test 4.
						The test performs file write operations using RFileBuf64 class and verifies that
						that the pending write data will be stored in the file when the buffer is closed.
						The purpose of the test: to verify the logic of RFileBuf64::Write().
@SYMTestActions			RFileBuf64 write test 4.
@SYMTestExpectedResults Test must not fail
@SYMTestPriority		High
@SYMREQ					REQ12106
                        REQ12109
*/
void WriteTest4()
	{
	RFileBuf64 fbuf(1024);
	TInt err = fbuf.Create(TheFs, KTestFile, EFileWrite);
	TEST2(err, KErrNone); 
    fbuf.ProfilerReset();

	// Data length: 10;
	err = fbuf.Write(0, _L8("A123456789"));
	TEST2(err, KErrNone); 
	TEST2(fbuf.iFileWriteCount, 0);
	TEST2(fbuf.iFileWriteAmount, 0);
	TEST2(fbuf.iFileSizeCount, 1);

	// Data length: 0;
	err = fbuf.Write(10, _L8(""));
	TEST2(err, KErrNone); 
	TEST2(fbuf.iFileWriteCount, 0);
	TEST2(fbuf.iFileWriteAmount, 0);
	TEST2(fbuf.iFileSizeCount, 1);

	fbuf.Close();
	
	VerifyFileContent(_L8("A123456789"));
	
	(void)TheFs.Delete(KTestFile);
	}
Beispiel #13
0
/**  Delete a big file, in a different thread

	@return ETrue
*/
TInt DeleteBigFile(TAny* )
	{
	RTest test(_L("T_FSCHED"));
	RFs fs;
	TInt r = fs.Connect();
	TESTERROR(r);

	r = fs.SetSessionPath(gSessionPath);
	TESTERROR(r);
	
	gSync.Wait(); 
	
	r = fs.Delete(gBigFile);
#if defined(__WINS__)
	TEST(r == KErrInUse || r == KErrNone);
#else
	test_Equal(KErrInUse, r);
#endif
		
	client.Signal();
	
	fs.Close();
	test.Close();
	
	return ETrue;
	}
void CenrepSwiOOMTest::UninstallROMUpgradeL(TBool aIsSetup)
	{
	if(aIsSetup)
		{
		// Install rev 2
		UpgradeROMRev2L(ETrue);
		UpgradeROMRev2L(EFalse);

		RFs fs;
		User::LeaveIfError(fs.Connect());
		CleanupClosePushL(fs);
		CFileMan* fm = CFileMan::NewL(fs);
		CleanupStack::PushL(fm);

		// Delete file from install dir
		User::LeaveIfError(fm->Attribs(KUpgradeFile,0,KEntryAttReadOnly,TTime(0)));
		TInt err=fs.Delete(KUpgradeFile);
		if((err!=KErrNone)&&(err!=KErrNotFound))
			User::Leave(err);

		CleanupStack::PopAndDestroy(2); // fs and fm
		}
	else
		{
		iSwiWatcher->HandleSWIEventL(ESASwisUninstall | ESASwisStatusSuccess);
		}
	}
// -----------------------------------------------------------------------------
// 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;
    }
void CTestPostDeleteIni::deleteFileL(const TDesC& aFileName) 
	{
	// create a fileserver
	RFs  fileSystem;
	CTestExecuteLogger log = Logger();

	User::LeaveIfError(fileSystem.Connect());
	CleanupClosePushL(fileSystem);

	// Remove read only flag
	TInt ret = fileSystem.SetAtt(aFileName, 0, KEntryAttReadOnly);
	if (ret == KErrNotFound)
		{
		// If file already removed then no need to delete it
		log.Write(_L("File not found"));
		CleanupStack::PopAndDestroy(&fileSystem);
		return;
		}
	User::LeaveIfError(ret);

	log.Write(_L("Set file to read only"));

	// Delete file
	User::LeaveIfError(fileSystem.Delete(aFileName));
	log.Write(_L("deleted file"));

	// clean up
	CleanupStack::PopAndDestroy(&fileSystem);
	}
LOCAL_C void Test2()
	{
// Invalid clamp requests
	test.Next(_L("T_DENYCLAMP - Test2()"));
	
	// Test attempt to clamp empty file is rejected
	RFileClamp handle2;
	TBuf<256> file2Name;	
	file2Name = _L("clampFile2.tst");
	RFile testFile2;
	TInt r=testFile2.Replace(TheFs,file2Name,EFileWrite);
	test(r==KErrNone);
	r=handle2.Clamp(testFile2);
	test(r==KErrPermissionDenied);


	// Try to unclamp non-existant file
	// Using a invalid-content cookie is OK - the request should
	// be rejected before the content is examined
	handle2.iCookie[0] = MAKE_TINT64(-1,-1); // iCookie[0] holds the unique ID
	handle2.iCookie[1] = MAKE_TINT64(-1,-1);
	r=handle2.Close(TheFs);
	test (r==KErrPermissionDenied);

	// Tidy up
	testFile2.Close();
	r=TheFs.Delete(_L("clampFile2.tst"));
	test (r==KErrNone);
	}
/**
Copies ineturilist.xml from z:\ineturilist\testdata\ineturilist.xml to c:\private\20009D70\ineturilist.xml
@internalTechnology
@test
*/
void CTestRemoveDBStep::RemoveDBL()
	{
	RFs fs;
	User::LeaveIfError ( fs.Connect () );		
	fs.Delete(KOldDB);
	fs.Close ();		
	}
LOCAL_C void Test1()
	{
// Basic clamp operation
	test.Next(_L("T_DENYCLAMP - Test1()"));

	TBuf<256> fileName;	
	TBuf<256> buf(_L("buffer for file used"));

	fileName = _L("clampFile.tst");
	RFile testFile;
	TInt r=testFile.Replace(TheFs,fileName,EFileWrite);
	test(r==KErrNone);
	TPtrC8 pBuf((TUint8*)&buf);
	testFile.Write(pBuf);
	testFile.Flush();

	// Attempt to clamp file should be rejected
	RFileClamp handle;
	r=handle.Clamp(testFile);
	test(r==KErrPermissionDenied);

	// Attempt to unclamp a file should be rejected
	// Using an invalid-content cookie is OK - the request should
	// be rejected before the content is examined
	handle.iCookie[0]=MAKE_TINT64(-1,-1);
	handle.iCookie[1]=0;
	r=handle.Close(TheFs);
	test (r==KErrPermissionDenied);

	// Tidy up
	testFile.Close();
	r=TheFs.Delete(_L("clampFile.tst"));
	test (r==KErrNone);
	}
void CJavaDebugAgentSettings::SaveL(const TDesC& aPrefsFile) const
{
    RFs fs;
    User::LeaveIfError(fs.Connect());
    CleanupClosePushL(fs);

    RFileWriteStream out;
    out.PushL();
    TInt err = out.Create(fs, aPrefsFile, EFileWrite);
    if (err != KErrNone) {
        // Try to eliminate the problem if we can
        switch (err) {
        case KErrAlreadyExists:
            fs.Delete(aPrefsFile);
            break;
        case KErrPathNotFound:
            fs.MkDirAll(aPrefsFile);
            break;
        default:
            User::Leave(err);
            break;
        }
        User::LeaveIfError(out.Create(fs, aPrefsFile, EFileWrite));
    }

    SaveL(&out);
    out.Close();
    out.Pop();
    CleanupStack::PopAndDestroy(&fs);
}
// ----------------------------------------------------------------------------------------
// CTerminalControlServer::DeleteFileL
// ----------------------------------------------------------------------------------------
void CTerminalControlServer::DeleteFileL( const TDesC8 &aFileName )
{
    RDEBUG("CTerminalControlServer::DeleteFileL");

    RFs fs;
    User::LeaveIfError(fs.Connect());
    CleanupClosePushL( fs );

    HBufC *fileName = HBufC::NewLC( aFileName.Length()+1 );
    TPtr fnptr( fileName->Des() );

    fnptr.Copy(aFileName);
    TEntry entry;

    User::LeaveIfError( fs.Entry( fnptr, entry ) );

    if( entry.IsDir() )
    {
        if(fnptr.Right(1) != _L("\\"))
        {
            fnptr.Append(_L("\\"));
        }
        User::LeaveIfError(fs.RmDir( fnptr ) );
    }
    else
    {
        User::LeaveIfError(fs.Delete( fnptr ) );
    }

    CleanupStack::PopAndDestroy( fileName );

    CleanupStack::PopAndDestroy( &fs );
}
//Delete "aFullName" file.
static void DeleteDataFile(const TDesC& aFullName)
	{
	RFs fsSession;
	TInt err = fsSession.Connect();
	if(err == KErrNone)
		{
		TEntry entry;
		if(fsSession.Entry(aFullName, entry) == KErrNone)
			{
			RDebug::Print(_L("Deleting \"%S\" file.\n"), &aFullName);
			err = fsSession.SetAtt(aFullName, 0, KEntryAttReadOnly);
			if(err != KErrNone)
				{
				RDebug::Print(_L("Error %d changing \"%S\" file attributes.\n"), err, &aFullName);
				}
			err = fsSession.Delete(aFullName);
			if(err != KErrNone)
				{
				RDebug::Print(_L("Error %d deleting \"%S\" file.\n"), err, &aFullName);
				}
			}
		fsSession.Close();
		}
	else
		{
		RDebug::Print(_L("Error %d connecting file session. File: %S.\n"), err, &aFullName);
		}
	}
void CenrepSwiOOMTest::UninstallL(TBool aIsSetup)
	{
	if(aIsSetup)
		{
		// Install upgrade
		UpgradeInstallL(ETrue);
		UpgradeInstallL(EFalse);

		RFs fs;
		User::LeaveIfError(fs.Connect());
		CleanupClosePushL(fs);
		CFileMan* fm = CFileMan::NewL(fs);
		CleanupStack::PushL(fm);

		// Delete file from install dir
		User::LeaveIfError(fm->Attribs(KInstallFile,0,KEntryAttReadOnly,TTime(0)));
		TInt err=fs.Delete(KInstallFile);
		if((err!=KErrNone)&&(err!=KErrNotFound))
			User::Leave(err);

		// Create a cre persists file, doesn't matter what's in it, it should be deleted
		User::LeaveIfError(fm->Copy(KPersistsFileUpgraded, KInstallPersistsFile));
		User::LeaveIfError(fm->Attribs(KInstallPersistsFile,0,KEntryAttReadOnly,TTime(0)));

		CleanupStack::PopAndDestroy(2); // fs and fm
		}
	else
		{
		iSwiWatcher->HandleSWIEventL(ESASwisUninstall | ESASwisStatusSuccess);
		}
	}
void DeleteTestFiles()
{
    (void)TheFs.Delete(KTestFile);
    (void)RSqlDatabase::Delete(KTestDbName4);
    (void)RSqlDatabase::Delete(KTestDbName3);
    (void)RSqlDatabase::Delete(KTestDbName2);
    (void)RSqlDatabase::Delete(KTestDbName);
}
Beispiel #25
0
void DestroyDatabase()
	{
	TheRowSet.Close();
	TheDatabase.Close();
	TheDbs.Close();
	TInt err = TheFs.Delete(TheDatabaseFileName);
	TEST2(err, KErrNone);
	}
// ---------------------------------------------------------
// CPosTp50::ExportAllLandmarksL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//	
void CPosTp50::ExportLandmarksL() 
    {
    RFs fs;
    User::LeaveIfError(fs.Connect());
    CleanupClosePushL(fs);
    
    fs.Delete(KAllLandmarks);
    
    CPosLmItemIterator* iter = iDatabase->LandmarkIteratorL();
    CleanupStack::PushL(iter);

    RArray<TPosLmItemId> arrayOfIds;
    CleanupClosePushL(arrayOfIds);
    
    TInt numberOfElements = iter->NumOfItemsL();    
    iter->GetItemIdsL(arrayOfIds, 0, (numberOfElements));
    
    CPosLandmarkEncoder* encoder = CPosLandmarkEncoder::NewL(KMimeType);
    CleanupStack::PushL(encoder);

    encoder->SetOutputFileL(KAllLandmarks);
   
    CPosLmOperation* op = iDatabase->ExportLandmarksL(*encoder, arrayOfIds,  CPosLandmarkDatabase::EDefaultOptions); 
    CleanupStack::PushL(op);
    op->ExecuteL();
    CleanupStack::PopAndDestroy(op);
    
    op = encoder->FinalizeEncodingL(); 
    CleanupStack::PushL(op);
    op->ExecuteL();
    
    // Create a file to be used from each thread
    CFileMan* fileMan = CFileMan::NewL(fs);
    CleanupStack::PushL(fileMan);
   
    for (TInt i=0; i<KNoMultipleClients; i++)
        {
        TBuf<100> fileName;
        fileName.Format(KAllLandmarksIndex, i+1);
        fs.Delete(fileName);
        
        User::LeaveIfError(fileMan->Copy(KAllLandmarks, fileName, CFileMan::EOverWrite));     
        }
        
    CleanupStack::PopAndDestroy(6, &fs); 
    }
void CTmsTestStep::CleanUpAndWriteResults()
{
    RFs fs;
    fs.Connect();
    CleanupClosePushL(fs);

    iTestStepPositions.Close();
    if (iTestStepNames != NULL)
    {
        iTestStepNames->Reset();
        delete iTestStepNames;
        iTestStepNames = NULL;

        if (BaflUtils::FolderExists(fs, KLogLocation))
        {
            RFile file;
            if (BaflUtils::FileExists( fs, KLogLocation ))
            {
                // open the temporary tms log
                TInt err = file.Open( fs, KLogLocation, EFileRead|EFileShareAny);
                if(err == KErrInUse)
                {
                    CleanupStack::PopAndDestroy();
                    return;
                }
                if (err == KErrNone)
                {
                    CleanupClosePushL(file);
                    TBuf8<256> line;
                    TBuf<250> testID;
                    TBuf<6> testResult;
                    // get a line from the temporary tms log
                    while (CTmsTestStep::ReadNextLineL(file,line))
                    {
                        TInt blankPos = line.Find(KBlankSpace);

                        // get the ID from the line
                        testID.Copy(line.Left(blankPos));

                        //get the pass or fail result from the line
                        testResult.Copy(line.Mid(blankPos+1,4));

                        // print into the standard tef log the id and the result in the correct format
                        // so that they are correctly parsed into the TMS csv file
                        INFO_PRINTF2(_L("START_TESTCASE %S"),&testID);
                        INFO_PRINTF2(_L("Line = 1 Command = START_TESTCASE %S"),&testID);
                        INFO_PRINTF2(_L("END_TESTCASE %S"),&testID);
                        INFO_PRINTF3(_L("Line = 1 Command = END_TESTCASE %S ***TestCaseResult = %S"),&testID,&testResult);
                    }
                    CleanupStack::PopAndDestroy();
                }
                // remove the temporary tms log
                fs.Delete(KLogLocation);
            }
        }
    }
    CleanupStack::PopAndDestroy();
}
Beispiel #28
0
void doNSmlDebugInitL()
	{
	TInt pushed(0);
	RFs fileSession;
	User::LeaveIfError(fileSession.Connect());
	CleanupClosePushL(fileSession);
	pushed++;

	TDriveInfo driveInfo;
	for ( TUint driveNumber = EDriveA; driveNumber <= EDriveZ; driveNumber++ ) 
		{
		fileSession.Drive( driveInfo, driveNumber );
		if ( KDriveAttRemovable & driveInfo.iDriveAtt ) 
			{
			RFile file;
			HBufC* outputName = HBufC::NewLC( KNSmlDebugOutputName().Length()+1 );
			pushed++;
			TPtr namePtr = outputName->Des();
			namePtr.Insert( 0, KNSmlDebugDriveLetters().Mid( driveNumber, 1 ));
			namePtr.Insert( 1, KNSmlDebugOutputName() );
			
			HBufC* outputDumpName = HBufC::NewLC( KNSmlDebugDumpName().Length()+1 );
			pushed++;
			TPtr nameDumpPtr = outputDumpName->Des();
			nameDumpPtr.Insert( 0, KNSmlDebugDriveLetters().Mid( driveNumber, 1 ));
			nameDumpPtr.Insert( 1, KNSmlDebugDumpName() );
			
			fileSession.Delete(*outputName);
			fileSession.Delete(*outputDumpName);	

#if !defined(__SML_DEVELOPER_DEBUG__)
				{
				User::LeaveIfError(file.Create(fileSession, *outputName, EFileShareAny));
				file.Close();
				}
#endif
				{
				User::LeaveIfError(file.Create(fileSession, *outputDumpName, EFileShareAny));
				file.Close();
				break;
				}
			}
		}
	CleanupStack::PopAndDestroy( pushed ); // fileSession
	}
Beispiel #29
0
LOCAL_C void TestStoreDeletedL()
	{
	RFs fs;
	REPORT_IF_ERROR(fs.Connect());
	_LIT(KStoreDeleted,"c:\\private\\1000484b\\StoreInit.tmp");
	TInt delErr = fs.Delete(KStoreDeleted);
	test((delErr == KErrNone) || (delErr ==KErrNotFound));
	fs.Close();
	}
void CContextContactsDocument::ConstructL()
{
	auto_ptr<CErrorUI> eui(CErrorUI::NewL());
	
#ifdef __WINS__
	RFs fs; User::LeaveIfError(fs.Connect());
	fs.Delete(_L("e:\\fill.txt"));
	fs.Close();
#endif
	TRAPD(err, MContextDocument::ConstructL(Application(),
		iDefaultSettings, KCLSettingsTuple,
		_L("contextcontacts.txt"), _L("contacts")));

	//iContext->SetDebugCallstack(ETrue);


	if (err!=KErrNone) {
		eui->ShowGlobalErrorNoteL(err);
		User::Leave(err);
	}
	
#ifdef __JAIKU__
	TBool run_welcome=EFalse;
	TInt accepted_privacy_stmt_version=0;
	iContext->Settings().GetSettingL(SETTING_ACCEPTED_PRIVACY_STMT_VERSION, accepted_privacy_stmt_version);
	TInt text_resource=0;
	if ( accepted_privacy_stmt_version < KJaikuPrivacyStatementVersion ) {
		text_resource=R_TXT_PRIVACYSTATEMENT_NOT_ACCEPTED;
		run_welcome=ETrue;
	} else {
		TBool allowed_network_access=EFalse;
		iContext->Settings().GetSettingL(SETTING_ACCEPTED_NETWORK_ACCESS, allowed_network_access);
		if (!allowed_network_access) {
			text_resource=R_TXT_WELCOME_NOT_COMPLETED;
			run_welcome=ETrue;
		}
	}
	
	if (run_welcome) {
		auto_ptr<HBufC> message( StringLoader::LoadL( text_resource ) );

		auto_ptr<CAknGlobalNote> note( CAknGlobalNote::NewL() );
		note->ShowNoteL(EAknGlobalInformationNote, *message);
		
		iContext->CallStackMgr().SetIsExiting(ETrue);
		ProcessManagement::StartApplicationL( KUidContextWelcome );
		
		User::After(3*1000*1000); // give starter a chance to run
		
		User::Leave(KLeaveExit); 
	}
#endif

#ifdef __WINS__
	iContext->SetAppDir(_L("c:\\system\\apps\\contextcontacts\\"));
#endif
}