コード例 #1
0
void SimulateDiskChangeL()
	{
	// Set up for heap leak checking
	__UHEAP_MARK;

	// Make sure the file is not read-only
	TRAPD(err, EComTestUtils::MakeFileWriteableL(KHTI_PluginAtRootOfC));
	TRAP(err, EComTestUtils::MakeFileWriteableL(KHTIr_PluginAtRootOfC));

	// Simulate that the implementation dll is changed - change resouce file timestamp
	RFile file;
	User::LeaveIfError(file.Open(TheFs, KHTIr_PluginAtRootOfC, EFileRead | EFileWrite));
	TTime time;
	User::LeaveIfError(file.Modified(time));
	TTimeIntervalSeconds interval = 100;
	time += interval;
	User::LeaveIfError(file.SetModified(time));
	file.Close();

	// Replace the resource file with the newer version (newer timestamp)
	// The ECOM server will run the discovery process and will unload the old dll
	// and replace it with the newer dll
	TRAP(err, EComTestUtils::FileManCopyFileL(KHTI_PluginAtRootOfC, KHTI_PluginInstalledOnC));
	TEST2(err, KErrNone);
	TRAP(err, EComTestUtils::FileManCopyFileL(KHTIr_PluginAtRootOfC, KHTIr_PluginInstalledOnC));
	TEST2(err, KErrNone);

	WAIT_FOR3s; // wait for copy to complete

	__UHEAP_MARKEND;
	}
コード例 #2
0
/**
Adds a recognition result to the cache. An object is not added, when an up-to-date
version is already in the cache or if it's not possible to check the file's LastModified().
@internalComponent
*/
void CApsRecognitionCache::AddL(const RFile& aFile, const TDesC& aDirectory, const TDesC& aFileName, const TDataRecognitionResult& aRecognitionResult)
	{
	TTime lastModified;
	if(aFile.Modified(lastModified) != KErrNone)
		{
	#if defined(_DEBUG)
		TFileName fullFileName(aDirectory);
		fullFileName.Append(aFileName);
		RDebug::Print(_L("CApsRecognitionCache::AddL(): File '%S' was not added to the cache, cannot get the modified attribute."), &fullFileName);
	#endif
		return;
		}
	DoAddL(aDirectory, aFileName, lastModified, aRecognitionResult);
	}
コード例 #3
0
// ---------------------------------------------------------------------------
// CBCTestLogger::CreateMainLogL
// ---------------------------------------------------------------------------
//
void CBCTestLogger::CreateMainLogL()
    {
    RFile mainFile;
    RFs tempServer = iEikEnv->FsSession();
    TInt err = mainFile.Create( tempServer, KMainLog, 
        EFileWrite | EFileStreamText );
    if ( err != KErrNone )
        {
        if ( err == KErrAlreadyExists )
            {
            TInt errnum = mainFile.Open( tempServer, KMainLog, 
                EFileRead | EFileStreamText );
            if ( errnum != KErrNone )
                {
                return;
                }
            }
        }    
    CleanupClosePushL( mainFile );
    
    if ( err == KErrNone )
        {
        WriteToFileL( mainFile,  iBuf );
        }
    else if ( err == KErrAlreadyExists )
        {
        TTime modifiedTime;
        TTime homeTime;
        homeTime.HomeTime();
        err = mainFile.Modified( modifiedTime );
        if ( err == KErrNone )
            {
            TTimeIntervalDays days = homeTime.DaysFrom( modifiedTime );
            TInt interval = days.Int();
            if ( interval >= KTheMaxInterval || interval <= -KTheMaxInterval )
                {
                mainFile.Close();
                mainFile.Replace( tempServer, KMainLog,
                    EFileWrite | EFileStreamText );                
                WriteToFileL( mainFile,  iBuf );
                }
            }     
        }
    
    CleanupStack::PopAndDestroy( &mainFile );
    }
コード例 #4
0
ファイル: t_fsy2k.cpp プロジェクト: kuailexs/symbiandump-os1
static void testRFileSetModified(TDateTime* aDateTime, TTime* aTime, TBool validDate)
//
// Test RFile::SetModified() and RFile::Modified()
//
	{
	RFile file;
	TInt r=file.Replace(TheFs,_L("Y2KTEST.tst"),0);
	test_Value(r, r == KErrNone || r==KErrPathNotFound);	

	r=file.SetModified(*aTime);
	test_KErrNone(r);
	file.Close();
	
	TTime check;
	file.Open(TheFs,_L("Y2KTEST.tst"),EFileWrite);
	r=file.Modified(check);
	test_KErrNone(r);
	file.Close();
		
	TDateTime checkDateTime=check.DateTime();
	
	test(checkDateTime.Year()==aDateTime->Year());
	if (validDate)
		{
		test(checkDateTime.Month()==aDateTime->Month());
		test(checkDateTime.Day()==aDateTime->Day());
		}
	else
		{
		test(checkDateTime.Month()==aDateTime->Month()+1);
		test(checkDateTime.Day()==0);
		}

	check.FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3"));
	test.Printf(_L("Valid date: %S\n"),&gDateBuf);

	r=TheFs.Delete(_L("Y2KTEST.tst"));
	
	}	
コード例 #5
0
ファイル: t_fsy2k.cpp プロジェクト: kuailexs/symbiandump-os1
static void testRFileSet(TDateTime* aDateTime, TTime* aTime, TBool validDate)
//
// Test RFile::Set() and RFile::Modified()
//
	{
	RFile file;
	TInt r=file.Replace(TheFs,_L("Y2KTEST.tst"),0);
	test_Value(r, r == KErrNone || r==KErrPathNotFound);	
		
	r=file.Set(*aTime,KEntryAttHidden,KEntryAttNormal);
	test_KErrNone(r);
	file.Close();
	
	TTime check;
	file.Open(TheFs,_L("Y2KTEST.tst"),EFileWrite);
	r=file.Modified(check);
	test_KErrNone(r);
	file.Close();
		
	test.Printf(_L("Date set to "));
	test.Printf(_L("Day %d "),aDateTime->Day());
	test.Printf(_L("Month %d "),aDateTime->Month());
	test.Printf(_L("Year %d \n"),aDateTime->Year());
	
	TDateTime checkDateTime=check.DateTime();
	if (checkDateTime.Year()!=aDateTime->Year())
		{
	//	Failure occurs for F32 releases before 111 - due to a problem
	//	in SFILE/SF_FILE DoFsFileSet() in which the TTime parameter
	//	was being incorrectly obtained.  Not a year 2000 issue.	
		
		test.Printf(_L("ERROR!\n"));
		test.Printf(_L("Actually set to "));
		test.Printf(_L("Day %d "),checkDateTime.Day());
		test.Printf(_L("Month %d "),checkDateTime.Month());
		test.Printf(_L("Year %d \n"),checkDateTime.Year());
	//	test.Printf(_L("Press any key to continue \n"));
	//	test.Getch();
		r=TheFs.Delete(_L("Y2KTEST.tst"));
		return;
		}
	else
		test(checkDateTime.Year()==aDateTime->Year());
	if (validDate)
		{
		test(checkDateTime.Month()==aDateTime->Month());
		test(checkDateTime.Day()==aDateTime->Day());
		}
	else
		{
		test(checkDateTime.Month()==aDateTime->Month()+1);
		test(checkDateTime.Day()==0);
		}

	
	check.FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3"));
	test.Printf(_L("Valid date: %S\n"),&gDateBuf);

	r=TheFs.Delete(_L("Y2KTEST.tst"));
	
	}	
コード例 #6
0
// --------------------------------------------------------------------------
// CUPnPMetaDataUtility::LoadMetaDataL
// Finds correct MMF controller according to give file name
// (other items were commented in a header).
// --------------------------------------------------------------------------
//
EXPORT_C void CUPnPMetaDataUtility::LoadMetaDataL( const TDesC& aFileName )
    {
    // Cleanup existing information
    Reset();
    
    RArray<TMetaDataFieldId> wantedFields;
    CleanupClosePushL( wantedFields );
    wantedFields.AppendL( EMetaDataSongTitle );
    wantedFields.AppendL( EMetaDataArtist );
    wantedFields.AppendL( EMetaDataAlbum );
    wantedFields.AppendL( EMetaDataGenre );
    wantedFields.AppendL( EMetaDataDate );
    
    // Reset to be sure that no allocations are left over
    iMetaDataUtility->ResetL();
    
    // Open the file
    iMetaDataUtility->OpenFileL( aFileName, wantedFields );
    
    // wantedFields is not needed anymore
    CleanupStack::PopAndDestroy( &wantedFields );
    
    // Go through the meta data fields and pick the required ones
    TInt count = iMetaDataUtility->MetaDataCount();
    
    if ( count > 0 )
        {
        const CMetaDataFieldContainer& container = 
                                        iMetaDataUtility->MetaDataFieldsL();
        TMetaDataFieldId fieldId;
        for ( TInt index = 0; index < count; index++ )
            {
            TPtrC content = container.At( index, fieldId );
            switch ( fieldId )
                {
                case EMetaDataSongTitle:
                    {
                    iTitle = content.AllocL();
                    break;
                    }
                case EMetaDataArtist:
                    {
                    iArtist = content.AllocL();
                    break;
                    }
                case EMetaDataAlbum:
                    {
                    iAlbum = content.AllocL();
                    break;
                    }
                case EMetaDataGenre:
                    {
                    iGenre = content.AllocL();
                    break;
                    }
                case EMetaDataDate:
                    {
                    iDate = content.AllocL();
                    break;
                    }
                default:
                    {
                    // Nothing to do
                    break;
                    }
                }
            }
        }
        
    if( !iDate )
        {
        // Date was not found from metadata, so get it from file properties
        RFs fs;
        User::LeaveIfError( fs.Connect() );
        CleanupClosePushL( fs );
        RFile file;
        User::LeaveIfError( file.Open( fs,aFileName, EFileRead |
            EFileShareReadersOrWriters ) );
        CleanupClosePushL( file );
        
        TTime time;
        User::LeaveIfError( file.Modified( time ) );
        

        iDate = UPnPCommonUtils::TTimeToUPnPDateL( time );
                
        CleanupStack::PopAndDestroy( &file );        
        CleanupStack::PopAndDestroy( &fs );        

        }
    // Cleanup
    iMetaDataUtility->ResetL();
    }