// ----------------------------------------------------------------------------- // CreatePrivatePathL // Create private path // ----------------------------------------------------------------------------- // LOCAL_C void CreatePrivatePathL(RFs& aFs) { #ifdef _DRM_TESTING TRAPD( r , WriteL(_L8("CreatePrivatePathL")) ); #endif #ifndef RD_MULTIPLE_DRIVE TInt err = aFs.CreatePrivatePath(EDriveC); #else //RD_MULTIPLE_DRIVE TInt driveNumber( -1 ); DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber ); TInt err = aFs.CreatePrivatePath(driveNumber); #endif if (err == KErrAlreadyExists) { err = KErrNone; } User::LeaveIfError(err); #ifdef _DRM_TESTING TRAP( r , WriteL(_L8("CreatePrivatePathL->End")) ); #endif return; }
void CheckAndInitializeFileL( RFs& aFs, TBuf<KMaxFileName>& aFile, const TDesC16& aFilePath, RFileReadStream& aTempFile, CFileMan* aFileMan ) { __LOG1( ELogAlways, "CheckAndInitializeFileL() - handling file %S", &aFilePath ); const TInt err = aTempFile.Open( aFs, aFile, EFileRead | EFileShareAny ); __LOG1( ELogAlways, "CheckAndInitializeFileL() - open file error %d", err ); aTempFile.Close(); if ( err != KErrNone ) { if ( err == KErrNotFound ) { // Path found but not schema.mde, copy schema.m const TInt error = aFileMan->Copy( aFilePath, aFile, CFileMan::EOverWrite ); __LOG1( ELogAlways, "CheckAndInitializeFileL() - copy file error %d", error ); } else if ( err == KErrPathNotFound) { // Create private dir User::LeaveIfError( aFs.CreatePrivatePath( EDriveC ) ); // Copy schema.mde const TInt error = aFileMan->Copy( aFilePath, aFile, CFileMan::EOverWrite ); __LOG1( ELogAlways, "CheckAndInitializeFileL() - copy file error %d", error ); } } }
TInt CSenBaseIdentityManager::WriteConfigurationToL( const TDesC& aFile ) { // First, collect everything into MEMORY CBufFlat *pBuf = CBufFlat::NewL(KFLATBUF_SIZE); CleanupStack::PushL(pBuf); RBufWriteStream bufWs(*pBuf); CleanupClosePushL(bufWs); bufWs.WriteL(KUsersStart); if(iIdentity) { iIdentity->WriteAsXMLToL(bufWs); } bufWs.WriteL(KUsersEnd); TPtrC8 p8 = pBuf->Ptr(0); CleanupStack::PopAndDestroy(1); // bufWs // Everything in MEMORY ok, prepare to write into file RFs fss; User::LeaveIfError(fss.Connect()); CleanupClosePushL(fss); RFileWriteStream fileOutStream; CleanupClosePushL(fileOutStream); if(!SysUtil::FFSSpaceBelowCriticalLevelL(&fss, p8.Length()) ) { // note, this will zero-length the file(!) // it is better to require that 2xfilesize is available and not to // dangerously zero the old file and find out // that there is no space left.. //Data caging 2 implementation #if defined( EKA2 ) || defined( RD_SECURE_PRIV_DATA ) TBuf<KMaxPath> file; fss.CreatePrivatePath(EDriveC); fss.PrivatePath(file); file.Append(aFile); fileOutStream.Replace(fss, file, EFileWrite); #else fileOutStream.Replace(fss, aFile, EFileWrite); #endif // finally write the UTF-8 into the file. fileOutStream.WriteL(p8); } CleanupStack::PopAndDestroy(3); // fileOutStream, fss, pBuf return KErrNone; }
void CreateTestEnv() { TInt err = TheFs.Connect(); TEST2(err, KErrNone); err = TheFs.MkDir(KTestDir); TEST(err == KErrNone || err == KErrAlreadyExists); err = TheFs.CreatePrivatePath(EDriveC); TEST(err == KErrNone || err == KErrAlreadyExists); }
void CSqlSrvTestBurInterface::Construct() { TInt err = iFs.Connect(); TEST2(err, KErrNone); err = iFs.MkDir(KTestDir); TEST(err == KErrNone || err == KErrAlreadyExists); err = iFs.CreatePrivatePath(KTestDrive); TEST(err == KErrNone || err == KErrAlreadyExists); }
//Connects the file session argument. //Creates application's private datacage on drive C: (if does not exist). //Copies the private path as string to the aPrivatePath argument (without the drive name). //aPrivatePath must point to a big enough place (ideally TFileName object). static void GetFsAndPrivatePathL(RFs& aFs, TDes& aPrivatePath) { User::LeaveIfError(aFs.Connect()); TInt err = aFs.CreatePrivatePath(EDriveC); if(!(err == KErrNone || err == KErrAlreadyExists)) { User::Leave(err); } User::LeaveIfError(aFs.PrivatePath(aPrivatePath)); }
/** Creates SQL server private data path on the specified drive. The idea for calling it is to make sure that the server's private data path exists before making any other operation - attempting to create a database file there for example. @param aFs File session instance @param aDriveNumber Drive number on which the private path has to be created @internalComponent */ static void CreatePrivateDataPathL(RFs& aFs, TDriveNumber aDriveNumber) { TDriveInfo driveInfo; __SQLLEAVE_IF_ERROR2(aFs.Drive(driveInfo, aDriveNumber)); if(!(driveInfo.iDriveAtt & KDriveAttRom)) { TInt err = aFs.CreatePrivatePath(aDriveNumber); if(err != KErrNone && err != KErrAlreadyExists) { __SQLLEAVE2(err); } } }
static void CreateTestDir() { RFs fs; TInt err = fs.Connect(); TEST2(err, KErrNone); err = fs.MkDir(KTestDir); TEST(err == KErrNone || err == KErrAlreadyExists); err = fs.CreatePrivatePath(EDriveC); TEST(err == KErrNone || err == KErrAlreadyExists); fs.Close(); }
void CreateTestEnv() { RFs fs; TInt err = fs.Connect(); TEST2(err, KErrNone); err = fs.MkDir(KTestDir); TEST(err == KErrNone || err == KErrAlreadyExists); err = fs.CreatePrivatePath(EDriveC); TEST(err == KErrNone || err == KErrAlreadyExists); fs.Close(); sqlite3SymbianLibInit(); }
void SetupTestEnv() { TInt err = TheFs.Connect(); TEST2(err, KErrNone); err = TheFs.MkDir(KTestDir); TEST(err == KErrNone || err == KErrAlreadyExists); err = TheFs.CreatePrivatePath(EDriveC); TEST(err == KErrNone || err == KErrAlreadyExists); (void)RSqlDatabase::Delete(KTestDbName3); (void)RSqlDatabase::Delete(KTestDbName2); (void)RSqlDatabase::Delete(KTestDbName); (void)TheFs.Delete(KSqlSrvConfigFile);//The test does not work if there is a test config file. }
void CSenBaseIdentityManager::LoadFromL(TDesC& aFile, CSenXmlReader& aReader) { RFs fss; User::LeaveIfError(fss.Connect()); CleanupClosePushL(fss); aReader.SetContentHandler(*this); SetReader(aReader); TInt leaveCode(KErrNone); #if defined( EKA2 ) || defined( RD_SECURE_PRIV_DATA ) TBuf<KMaxPath> file; fss.CreatePrivatePath(EDriveC); fss.PrivatePath(file); file.Append(aFile); TRAP(leaveCode, aReader.ParseL(fss, file)); #else TRAP(leaveCode, aReader.ParseL(fss, aFile)); #endif #ifdef _SENDEBUG if(leaveCode == KErrNotFound) { TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"- The senidentities.xml does not exist!"); TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"- New file will be generated."); } else if(leaveCode != KErrNone) { TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase , KMinLogLevel, _L8("- Parsing of senidentities.xml leaved: %d"), leaveCode)); } else { TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"- Identity database (senidentities.xml) successfully read."); } #else leaveCode=0; // this is a decision: we are not interested // of invalid input in read/parse phase #endif WriteDatabase(); // Always validate by saving CleanupStack::PopAndDestroy(); // fss }
void getcontentstatus ( TPtrC aContent , TInt& aBLstatus ,TInt& aINstatus) { RSqlDatabase sqlDB; RFs fssession; User::LeaveIfError( fssession.Connect() ); TFileName privatePath; TFileName datafile; fssession.CreatePrivatePath(EDriveC); fssession.PrivatePath(privatePath);//data caged path of loading process fssession.Close(); datafile.Copy(KDriveC); datafile.Append(privatePath); datafile.Append( KContentInfoFileName ); TInt err = sqlDB.Open( datafile ); if ( err ==KErrNone ) { TSqlScalarFullSelectQuery fullSelectQuery(sqlDB); TBuf<100> sql; // Query with INS column _LIT(KgetINstatusSqlFormat, "SELECT INS FROM table1 WHERE NAME = '"); _LIT(Kendtag, "'"); sql.Copy( KgetINstatusSqlFormat); sql.Append( aContent); sql.Append( Kendtag ); //sql.Format( KgetINstatusSqlFormat , aContent ); // Read INS as integer. aINstatus = fullSelectQuery.SelectIntL(sql); _LIT(KgetBLstatusSqlFormat, "SELECT BLS FROM table1 WHERE NAME = '"); sql.FillZ(); sql.Copy( KgetBLstatusSqlFormat); sql.Append( aContent); sql.Append( Kendtag ); //sql.Format( KgetBLstatusSqlFormat , aContent ); // Read BLS as integer. aBLstatus = fullSelectQuery.SelectIntL(sql); } sqlDB.Close(); }