persistentstorage/store/UFILE/UF_DICT.CPP
changeset 35 0d6db0a14001
parent 0 08ec8eefde2f
child 55 44f437012c90
equal deleted inserted replaced
25:63532cdadd44 35:0d6db0a14001
   152 	TInt64 seed;
   152 	TInt64 seed;
   153 	const TUidType type(KPermanentFileStoreLayoutUid,KUidDictionaryFile,aFileId);
   153 	const TUidType type(KPermanentFileStoreLayoutUid,KUidDictionaryFile,aFileId);
   154 	for (TInt wait=KLockoutLimit;;)
   154 	for (TInt wait=KLockoutLimit;;)
   155 		{
   155 		{
   156 		RFile file;
   156 		RFile file;
   157 		TInt r=file.Open(aFs,aName,EFileShareExclusive|EFileWrite);
   157         //  When the file server write caching is enabled, the order of file write operations is not guaranteed.
       
   158         // This could cause data inconsistency in some circumstances,for example, when the power is lost in the 
       
   159         // middle of a database transaction.Therefore, the file write caching is disabled for this file to maintain integrity.
       
   160 
       
   161 		TInt r=file.Open(aFs,aName,EFileShareExclusive|EFileWrite|EFileWriteDirectIO);
   158 		switch (r)
   162 		switch (r)
   159 			{
   163 			{
   160 		case KErrNone:
   164 		case KErrNone:
   161 			{
   165 			{
   162 			TInt size;
   166 			TInt size;
   173 					store = NULL;
   177 					store = NULL;
   174 					r=KErrCorrupt;
   178 					r=KErrCorrupt;
   175 					}
   179 					}
   176 				if (r==KErrCorrupt)
   180 				if (r==KErrCorrupt)
   177 					{
   181 					{
   178 					// silently replace the entire file if it is corrupt
   182 				// silently replace the entire file if it is corrupt
   179 					r=file.Replace(aFs,aName,EFileShareExclusive|EFileWrite);
   183 				//  When the file server write caching is enabled, the order of file write operations is not guaranteed.
       
   184 				// This could cause data inconsistency in some circumstances,for example, when the power is lost in the 
       
   185 				// middle of a database transaction.Therefore, the file write caching is disabled for this file to maintain integrity.
       
   186 				//   
       
   187 					r=file.Replace(aFs,aName,EFileShareExclusive|EFileWrite|EFileWriteDirectIO);
   180 					if (r==KErrInUse)
   188 					if (r==KErrInUse)
   181 						break;  // try again later...
   189 						break;  // try again later...
   182 					if (r==KErrNone)
   190 					if (r==KErrNone)
   183 						{
   191 						{
   184 						CreateStoreL(file,type);
   192 						CreateStoreL(file,type);
   195 			else
   203 			else
   196 				CreateStoreL(file,type);
   204 				CreateStoreL(file,type);
   197 			return;
   205 			return;
   198 			}
   206 			}
   199 		case KErrNotFound:
   207 		case KErrNotFound:
   200 			r=file.Create(aFs,aName,EFileShareExclusive|EFileWrite);
   208             //  When the file server write caching is enabled, the order of file write operations is not guaranteed.
       
   209             // This could cause data inconsistency in some circumstances,for example, when the power is lost in the 
       
   210             // middle of a database transaction.Therefore, the file write caching is disabled for this file to maintain integrity.
       
   211 			r=file.Create(aFs,aName,EFileShareExclusive|EFileWrite|EFileWriteDirectIO);
   201 			if (r==KErrNone)
   212 			if (r==KErrNone)
   202 				{
   213 				{
   203 				CreateStoreL(file,type);
   214 				CreateStoreL(file,type);
   204 				return;
   215 				return;
   205 				}
   216 				}