433 TParse parseDbConfig; |
441 TParse parseDbConfig; |
434 __SQLLEAVE_IF_ERROR(parseDbConfig.Set(KSqlSrvDbConfigFileFormat, &aServerPrivatePath, NULL)); |
442 __SQLLEAVE_IF_ERROR(parseDbConfig.Set(KSqlSrvDbConfigFileFormat, &aServerPrivatePath, NULL)); |
435 TFileName configFilePath(parseDbConfig.FullName()); // get 'drive:\private path\cfg*' search string |
443 TFileName configFilePath(parseDbConfig.FullName()); // get 'drive:\private path\cfg*' search string |
436 CDir* entryList = 0; // memory will be allocated for this in GetDir() |
444 CDir* entryList = 0; // memory will be allocated for this in GetDir() |
437 TInt err = aFs.GetDir(configFilePath, KEntryAttNormal, ESortByName, entryList); |
445 TInt err = aFs.GetDir(configFilePath, KEntryAttNormal, ESortByName, entryList); |
438 CleanupStack::PushL(entryList); |
446 if(err == KErrNone) |
439 if(!err) |
447 { |
440 { |
448 __ASSERT_DEBUG(entryList != NULL, __SQLPANIC(ESqlPanicInternalError)); |
441 if(entryList && (entryList->Count() > 0)) |
449 CleanupStack::PushL(entryList); |
|
450 if(entryList->Count() > 0) |
442 { |
451 { |
443 iDbConfigFiles = CDbConfigFiles::NewL(*entryList); |
452 iDbConfigFiles = CDbConfigFiles::NewL(*entryList); |
444 } |
453 } |
|
454 CleanupStack::PopAndDestroy(entryList); |
445 } |
455 } |
446 else |
456 else |
447 { |
457 { |
448 SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSERVER_CACHEDDBCONFIGFILENAMESL, "0x%X;CSqlServer::CacheDbConfigFileNamesL;GetDir() failed with error code %d", (TUint)this, err)); |
458 SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSERVER_CACHEDDBCONFIGFILENAMESL, "0x%X;CSqlServer::CacheDbConfigFileNamesL;GetDir() failed with error code %d", (TUint)this, err)); |
449 } |
459 __ASSERT_DEBUG(!entryList, __SQLPANIC(ESqlPanicInternalError)); |
450 CleanupStack::PopAndDestroy(); // entryList |
460 } |
451 } |
461 } |
452 |
462 |
453 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
463 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
454 //////////////////////////////////////// MSqlPolicyInspector implementation /////////////////////////////// |
464 //////////////////////////////////////// MSqlPolicyInspector implementation /////////////////////////////// |
455 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
465 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
484 return iFileData.Fs(); |
494 return iFileData.Fs(); |
485 } |
495 } |
486 |
496 |
487 /** |
497 /** |
488 Implements MSqlSrvBurInterface::GetBackupListL(). |
498 Implements MSqlSrvBurInterface::GetBackupListL(). |
489 Retrieves in aFileList parameter a list of secure database names (full database paths actually) |
499 Retrieves in aFileNameList parameter a list of secure database names (full database names, including path) |
490 which security UID matches aUid parameter. |
500 which security UID matches aUid parameter. |
491 Database files on ROM drive(s) won't be put in aFileList. |
501 No databases will be included into the list, if the drive is read-only. |
492 |
502 |
493 @param aUid Database security UID. |
503 @param aUid Database security UID. |
494 @param aFileList An output parameter. If the function completes successfully, then aFileList will be filled |
504 @param aDrive The drive where the database search will be performed, in the SQL server private data cage. |
495 with all secure database file names which security UID matches aUid parameter. |
505 @param aFileNameList An output parameter. |
496 Database files on ROM drive(s) won't be put in aFileList. |
506 Each array entry represents the full name of a database in SQL server private data cage |
|
507 on the specified drive (aDrive), which uid matches the aUid parameter. |
497 |
508 |
498 @leave KErrNoMemory, an out of memory condition has occured; |
509 @leave KErrNoMemory, an out of memory condition has occured; |
499 Note that the function may leave also with some other database specific or OS specific |
510 Note that the function may leave also with some other database specific or OS specific |
500 error codes. |
511 error codes. |
501 */ |
512 */ |
502 void CSqlServer::GetBackUpListL(TSecureId aUid, RArray<TParse>& aFileList) |
513 void CSqlServer::GetBackUpListL(TSecureId aUid, TDriveNumber aDrive, RArray<HBufC*>& aFileNameList) |
503 { |
514 { |
504 SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSERVER_GETBACKUPLISTL_ENTRY, "Entry;0x%x;CSqlServer::GetBackUpListL;aUid=0x%X", (TUint)this, (TUint)aUid.iId)); |
515 SQL_TRACE_INTERNALS(OstTraceExt3(TRACE_INTERNALS, CSQLSERVER_GETBACKUPLISTL_ENTRY, "Entry;0x%x;CSqlServer::GetBackUpListL;aDrive=%d;aUid=0x%X", (TUint)this, (TInt)aDrive, (TUint)aUid.iId)); |
505 aFileList.Reset(); |
516 __ASSERT_DEBUG(aFileNameList.Count() == 0, __SQLPANIC(ESqlPanicBadArgument)); |
506 TFindFile findFile(iFileData.Fs()); |
517 RFs& fs = iFileData.Fs(); |
507 CDir* fileNameCol = NULL; |
518 //No files in the list if aDrive is a read-only drive |
|
519 TDriveInfo driveInfo; |
|
520 __SQLLEAVE_IF_ERROR(fs.Drive(driveInfo, aDrive)); |
|
521 if(driveInfo.iDriveAtt & KDriveAttRom) |
|
522 { |
|
523 return; |
|
524 } |
|
525 //Compose the search path |
|
526 TDriveUnit driveUnit(aDrive); |
|
527 TDriveName driveName = driveUnit.Name(); |
|
528 TFileName path; |
|
529 path.Copy(driveName); |
|
530 path.Append(iFileData.PrivatePath()); |
|
531 //Include the aUid and the "*" mask |
508 TUidName uidName = (static_cast <TUid> (aUid)).Name(); |
532 TUidName uidName = (static_cast <TUid> (aUid)).Name(); |
509 TBuf<KMaxUidName + sizeof(KMatchAllDbFiles)> fileNameMask(uidName); |
533 TBuf<KMaxUidName + sizeof(KMatchAllDbFiles)> fileNameMask(uidName); |
510 fileNameMask.Append(KMatchAllDbFiles); |
534 fileNameMask.Append(KMatchAllDbFiles); |
511 //Find all files which name is matching "[aUid]*" pattern. |
535 TParse parse; |
512 TInt err = findFile.FindWildByDir(fileNameMask, iFileData.PrivatePath(), fileNameCol); |
536 __SQLLEAVE_IF_ERROR(parse.Set(path, &fileNameMask, NULL)); |
513 if(err == KErrNone) |
537 //Do the search |
514 { |
538 TPtrC fullPath(parse.FullName()); |
515 //The first set of files, which name is matching "[aUid]*" pattern, is ready. |
539 SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSERVER_GETBACKUPLISTL_FULLPATH, "Exit;0x%x;CSqlServer::GetBackUpListL;fullPath=%S", (TUint)this, __SQLPRNSTR(fullPath))); |
516 do |
540 CDir* fileNameCol = NULL; |
517 { |
541 TInt err = fs.GetDir(fullPath, KEntryAttNormal, ESortNone, fileNameCol); |
518 __ASSERT_DEBUG(fileNameCol != NULL, __SQLPANIC(ESqlPanicInternalError)); |
542 if(err == KErrNotFound) |
519 CleanupStack::PushL(fileNameCol); |
543 { |
520 const TDesC& file = findFile.File();//"file" variable contains the drive and the path. the file name in "file" is invalid in this case. |
544 __ASSERT_DEBUG(!fileNameCol, __SQLPANIC(ESqlPanicInternalError)); |
521 //Check that the drive, where the database files are, is not ROM drive |
545 SQL_TRACE_INTERNALS(OstTrace1(TRACE_INTERNALS, CSQLSERVER_GETBACKUPLISTL_EXIT1, "Exit;0x%x;CSqlServer::GetBackUpListL;no files found", (TUint)this)); |
522 TParse parse; |
546 return; |
523 (void)parse.Set(file, NULL, NULL);//this call can't file, the file name comes from findFile call. |
547 } |
524 TPtrC driveName = parse.Drive(); |
548 __SQLLEAVE_IF_ERROR(err); |
525 __ASSERT_DEBUG(driveName.Length() > 0, __SQLPANIC(ESqlPanicInternalError)); |
549 __ASSERT_DEBUG(fileNameCol != NULL, __SQLPANIC(ESqlPanicInternalError)); |
526 TInt driveNumber = -1; |
550 CleanupStack::PushL(fileNameCol); |
527 __SQLLEAVE_IF_ERROR(RFs::CharToDrive(driveName[0], driveNumber)); |
551 TInt fileCount = fileNameCol->Count(); |
528 TDriveInfo driveInfo; |
552 __SQLLEAVE_IF_ERROR(aFileNameList.Reserve(fileCount)); |
529 __SQLLEAVE_IF_ERROR(iFileData.Fs().Drive(driveInfo, static_cast <TDriveNumber> (driveNumber))); |
553 //Append the full database file paths to the file names list. |
530 //If current drive is not ROM drive then process the files |
554 for(TInt i=0;i<fileCount;++i) |
531 if(!(driveInfo.iDriveAtt & KDriveAttRom)) |
555 { |
532 { |
556 const ::TEntry& entry = (*fileNameCol)[i]; |
533 TInt cnt = fileNameCol->Count(); |
557 __ASSERT_DEBUG(!entry.IsDir(), __SQLPANIC(ESqlPanicInternalError));//RFs::GetDir() search attributes exclude directories (see the GetDir() call above). |
534 //For each found database file, which name is matching "[aUid]*" pattern, do: |
558 __SQLLEAVE_IF_ERROR(parse.Set(path, &entry.iName, NULL)); |
535 for(TInt i=0;i<cnt;++i) |
559 TPtrC fname(parse.FullName()); |
536 { |
560 SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSERVER_GETBACKUPLISTL, "0x%x;CSqlServer::GetBackUpListL;fname=%S", (TUint)this, __SQLPRNSTR(fname))); |
537 const ::TEntry& entry = (*fileNameCol)[i]; |
561 HBufC* fnameBuf = fname.AllocL(); |
538 if(!entry.IsDir()) |
562 __SQLDEBUG_EXPR(err = )aFileNameList.Append(fnameBuf); |
539 { |
563 __ASSERT_DEBUG(err == KErrNone, __SQLPANIC(ESqlPanicInternalError)); |
540 (void)parse.Set(entry.iName, &file, NULL);//"parse" variable now contains the full file path |
564 } |
541 __SQLTRACE_INTERNALSVAR(TPtrC fname = parse.FullName()); |
565 CleanupStack::PopAndDestroy(fileNameCol); |
542 SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSERVER_GETBACKUPLISTL, "0x%x;CSqlServer::GetBackUpListL;fname=%S", (TUint)this, __SQLPRNSTR(fname))); |
566 SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSERVER_GETBACKUPLISTL_EXIT2, "Exit;0x%x;CSqlServer::GetBackUpListL;file count=%d", (TUint)this, fileCount)); |
543 __SQLLEAVE_IF_ERROR(aFileList.Append(parse)); |
|
544 } |
|
545 } |
|
546 } |
|
547 CleanupStack::PopAndDestroy(fileNameCol); |
|
548 fileNameCol = NULL; |
|
549 } while((err = findFile.FindWild(fileNameCol)) == KErrNone);//Get the next set of files |
|
550 }//end of "if(err == KErrNone)" |
|
551 __ASSERT_DEBUG(!fileNameCol, __SQLPANIC(ESqlPanicInternalError)); |
|
552 if(err != KErrNotFound && err != KErrNone) |
|
553 { |
|
554 __SQLLEAVE(err); |
|
555 } |
|
556 SQL_TRACE_INTERNALS(OstTraceExt3(TRACE_INTERNALS, CSQLSERVER_GETBACKUPLISTL_EXIT, "Exit;0x%x;CSqlServer::GetBackUpListL;file count=%d;err=%d", (TUint)this, aFileList.Count(), err)); |
|
557 } |
567 } |
558 |
568 |
559 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
569 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
560 //////////////////////////////////////// SQL server startup ////////////////////////////////////////////// |
570 //////////////////////////////////////// SQL server startup ////////////////////////////////////////////// |
561 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
571 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// |