persistentstorage/store/UFILE/UF_DICT.CPP
branchRCL_3
changeset 24 cc28652e0254
parent 23 26645d81f48d
equal deleted inserted replaced
23:26645d81f48d 24:cc28652e0254
   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         //  When the file server write caching is enabled, the order of file write operations is not guaranteed.
   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 
   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.
   159         // middle of a database transaction.Therefore, the file write caching is disabled for this file to maintain integrity.
   160 
   160 
   161 		TInt r=file.Open(aFs,aName,EFileShareExclusive|EFileWrite|EFileWriteDirectIO);
   161 		TInt r=file.Open(aFs,aName,EFileShareExclusive|EFileWrite|EFileWriteDirectIO);
   162 		switch (r)
   162 		switch (r)
   177 					store = NULL;
   177 					store = NULL;
   178 					r=KErrCorrupt;
   178 					r=KErrCorrupt;
   179 					}
   179 					}
   180 				if (r==KErrCorrupt)
   180 				if (r==KErrCorrupt)
   181 					{
   181 					{
   182 				// silently replace the entire file if it is corrupt
   182 					// silently replace the entire file if it is corrupt
   183 				//  When the file server write caching is enabled, the order of file write operations is not guaranteed.
   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 
   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.
   185 					// middle of a database transaction.Therefore, the file write caching is disabled for this file to maintain integrity.
   186 				//   
   186 
   187 					r=file.Replace(aFs,aName,EFileShareExclusive|EFileWrite|EFileWriteDirectIO);
   187 					r=file.Replace(aFs,aName,EFileShareExclusive|EFileWrite|EFileWriteDirectIO);
   188 					if (r==KErrInUse)
   188 					if (r==KErrInUse)
   189 						break;  // try again later...
   189 						break;  // try again later...
   190 					if (r==KErrNone)
   190 					if (r==KErrNone)
   191 						{
   191 						{
   203 			else
   203 			else
   204 				CreateStoreL(file,type);
   204 				CreateStoreL(file,type);
   205 			return;
   205 			return;
   206 			}
   206 			}
   207 		case KErrNotFound:
   207 		case KErrNotFound:
   208             //  When the file server write caching is enabled, the order of file write operations is not guaranteed.
   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 
   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.
   210 			// middle of a database transaction.Therefore, the file write caching is disabled for this file to maintain integrity.
       
   211 
   211 			r=file.Create(aFs,aName,EFileShareExclusive|EFileWrite|EFileWriteDirectIO);
   212 			r=file.Create(aFs,aName,EFileShareExclusive|EFileWrite|EFileWriteDirectIO);
   212 			if (r==KErrNone)
   213 			if (r==KErrNone)
   213 				{
   214 				{
   214 				CreateStoreL(file,type);
   215 				CreateStoreL(file,type);
   215 				return;
   216 				return;