persistentstorage/sql/SRC/Server/SqlSrvMain.cpp
branchRCL_3
changeset 21 28839de615b4
parent 11 211563e4b919
child 23 26645d81f48d
equal deleted inserted replaced
18:3da531bb4329 21:28839de615b4
   312 	TInt sysDrive = static_cast<TInt>(RFs::GetSystemDrive());
   312 	TInt sysDrive = static_cast<TInt>(RFs::GetSystemDrive());
   313 	//Get the server private data path.
   313 	//Get the server private data path.
   314 	RFs& fs = sqlite3SymbianFs();
   314 	RFs& fs = sqlite3SymbianFs();
   315 	TFileName serverPrivatePath;
   315 	TFileName serverPrivatePath;
   316 	__SQLLEAVE_IF_ERROR(fs.PrivatePath(serverPrivatePath));
   316 	__SQLLEAVE_IF_ERROR(fs.PrivatePath(serverPrivatePath));
       
   317 
       
   318 	DeleteTempFilesL(sysDrive, serverPrivatePath);
   317 	//Load config file parameter values (if config file exists) and initialize iFileData.
   319 	//Load config file parameter values (if config file exists) and initialize iFileData.
   318 	TParse parse;
   320 	TParse parse;
   319 	__SQLLEAVE_IF_ERROR(parse.Set(KSqlSrvDefaultConfigFile, &serverPrivatePath, NULL));
   321 	__SQLLEAVE_IF_ERROR(parse.Set(KSqlSrvDefaultConfigFile, &serverPrivatePath, NULL));
   320 	//Store the names of any existing database config files in memory
   322 	//Store the names of any existing database config files in memory
   321 	CacheDbConfigFileNamesL(fs, serverPrivatePath);
   323 	CacheDbConfigFileNamesL(fs, serverPrivatePath);
   356  	char tmp[32]; 
   358  	char tmp[32]; 
   357  	sprintf(tmp, "%04X", KAnyNumber);
   359  	sprintf(tmp, "%04X", KAnyNumber);
   358     const TInt KGreatSize = 1024; 
   360     const TInt KGreatSize = 1024; 
   359  	__SQLLEAVE_IF_ERROR(ReAllocBuf(KGreatSize));
   361  	__SQLLEAVE_IF_ERROR(ReAllocBuf(KGreatSize));
   360     #endif //SQLSRV_STARTUP_TEST 	
   362     #endif //SQLSRV_STARTUP_TEST 	
   361 #endif //_DEBUG 	
   363 #endif //_DEBUG 
   362 	}
   364 	}
       
   365 
       
   366 /**
       
   367 Delete any temp files left the "temp" subdirectory in server's private directory.
       
   368 
       
   369 The SQLite is configured to use shared page cache. When the shared page cache is enabled,
       
   370 those temp files created by SQLite are deleted only when the database gets closed. However,
       
   371 if during power down event the client application does not close the database, 
       
   372 the temp files will never get deleted.
       
   373 This is why the SQL server should deletes all temp files during its start-up.
       
   374 
       
   375 Note that all errors exept KErrNoMemory are ignored in the function body, becasuse
       
   376 the temp files deletion is not a critical operation to prevent the server start up.
       
   377 
       
   378 @param aDriveNumber A drive number.
       
   379 @param aServerPath A server's private path.
       
   380 
       
   381 */
       
   382 void CSqlServer::DeleteTempFilesL(TInt aDriveNumber, const TDesC& aServerPath)const
       
   383     {
       
   384     _LIT(KTempFileDir, "temp");
       
   385     _LIT(KWildCard, "*.*");
       
   386     TDriveUnit drive(aDriveNumber); 
       
   387     TDriveName driveName = drive.Name();
       
   388     TParse parse;
       
   389     (void)parse.Set(aServerPath, &driveName, 0);//this call can't fail
       
   390     (void)parse.AddDir(KTempFileDir);//this call can't fail
       
   391     TFileName tempfileDir(parse.FullName());
       
   392     (void)parse.Set(KWildCard, &tempfileDir, 0);//this call can't fail
       
   393 	RFs& fs = sqlite3SymbianFs();
       
   394 	CFileMan* fm = CFileMan::NewL(fs);
       
   395 	(void)fm->Delete(parse.FullName());
       
   396 	delete fm;
       
   397     }
   363 
   398 
   364 /**
   399 /**
   365 Retrieves in iCollationDllName current(default) collation dll name.
   400 Retrieves in iCollationDllName current(default) collation dll name.
   366 see TExtendedLocale
   401 see TExtendedLocale
   367 */
   402 */