persistentstorage/dbms/ustor/US_FILE.CPP
changeset 35 0d6db0a14001
parent 25 63532cdadd44
child 55 44f437012c90
equal deleted inserted replaced
25:63532cdadd44 35:0d6db0a14001
    95 	CFileStore* store;
    95 	CFileStore* store;
    96 	switch (aMode)
    96 	switch (aMode)
    97 		{
    97 		{
    98 	default:
    98 	default:
    99 		__LEAVE(KErrNotSupported);
    99 		__LEAVE(KErrNotSupported);
   100 	case TDbFormat::ECreate:
   100 	case TDbFormat::ECreate:   
   101 //  When the file cache in file server is on, the order of file writing is not guaranteed which could cause data inconsistency in some circumstances, for example, when the power is lost in the middle of data transaction. Therefore, the file write cache is switched off here to maintain the file integrity .	    
   101 		store=CPermanentFileStore::CreateL(iFs,aName,EFileRead|EFileWrite);
   102 		store=CPermanentFileStore::CreateL(iFs,aName,EFileRead|EFileWrite/EFileWriteDirectIO);
       
   103 		break;
   102 		break;
   104 	case TDbFormat::EReplace:
   103 	case TDbFormat::EReplace:
   105 //  When the file cache in file server is on, the order of file writing is not guaranteed which could cause data inconsistency in some circumstances, for example, when the power is lost in the middle of data transaction. Therefore, the file write cache is switched off here to maintain the file integrity .
   104 		store=CPermanentFileStore::ReplaceL(iFs,aName,EFileRead|EFileWrite);
   106 		store=CPermanentFileStore::ReplaceL(iFs,aName,EFileRead|EFileWrite/EFileWriteDirectIO);
       
   107 		break;
   105 		break;
   108 		};
   106 		};
   109 	iStore=store;
   107 	iStore=store;
   110 	iDelete=ETrue;		// cleanup fully in case of failure
   108 	iDelete=ETrue;		// cleanup fully in case of failure
   111 	store->SetTypeL(aType);
   109 	store->SetTypeL(aType);
   144 	{
   142 	{
   145 	__ASSERT(!iName);	// check construction phase
   143 	__ASSERT(!iName);	// check construction phase
   146 //
   144 //
   147 	iName=aName.AllocL();
   145 	iName=aName.AllocL();
   148 	TUint mode=aMode==TDbFormat::EReadOnly ? EFileShareReadersOnly : EFileWrite;
   146 	TUint mode=aMode==TDbFormat::EReadOnly ? EFileShareReadersOnly : EFileWrite;
   149 //	When the file cache in file server is on, the order of file writing is not guaranteed which could cause data inconsistency in some circumstances, for example, when the power is lost in the middle of data transaction. Therefore, the file write cache is switched off here to maintain the file integrity .
       
   150 	mode = mode|EFileWriteDirectIO;
       
   151 	CFileStore* store=CPermanentFileStore::OpenL(iFs,*iName,mode);
   147 	CFileStore* store=CPermanentFileStore::OpenL(iFs,*iName,mode);
   152 	iStore=store;
   148 	iStore=store;
   153 	CDbStoreDatabase::RestoreL(DatabaseIdL(store->Root()));
   149 	CDbStoreDatabase::RestoreL(DatabaseIdL(store->Root()));
   154 	}
   150 	}
   155 
   151