// --------------------------------------------------------- // CPosTp16::UseContactDbL // // (other items were commented in a header). // --------------------------------------------------------- // CPosLandmarkDatabase* CPosTp16::UseContactDbL() { RemoveDefaultDbL(); #ifdef __WINS__ _LIT(KCorruptDbFile, "z:\\system\\test\\testdata\\SRVeposcontact.ldb"); #else _LIT(KCorruptDbFile, "c:\\system\\test\\testdata\\SRVeposcontact.ldb"); #endif _LIT(KCorruptDbFileOld, "c:\\system\\data\\SRVeposcontact.ldb"); RFs fs; User::LeaveIfError(fs.Connect()); CleanupClosePushL(fs); CFileMan* fileMan = CFileMan::NewL(fs); CleanupStack::PushL(fileMan); User::LeaveIfError(fileMan->Copy(KCorruptDbFile, KDefaultDbPath, CFileMan::EOverWrite)); User::LeaveIfError(fileMan->Rename(KCorruptDbFileOld, KDefaultDb, CFileMan::EOverWrite)); CleanupStack::PopAndDestroy(2, &fs); return CPosLandmarkDatabase::OpenL(); }
// --------------------------------------------------------- // CPosTp29::CopyResourceFileL // // (other items were commented in a header). // --------------------------------------------------------- // void CPosTp29::CopyResourceFileL(const TDesC& aResourceFile) { // Release all landmark references to make DLLs be unloaded. delete iLandmarksDb; iLandmarksDb = NULL; CFileMan* fileMan = CFileMan::NewL(iFileServer); CleanupStack::PushL(fileMan); // Check if landmark is flashed if (!BaflUtils::FileExists(iFileServer, KInternalServicesResFileRom)) { iLog->Put(_L("Landmark is NOT flashed, backing up eposlmintservices.rsc by renaming it bofore copying rsc-file.")); // Landmark FW is not flashed. Rename the file before copying an own defiend file. // Since landmark FW is not flashed the file should exist hence leaving if it is not found! User::LeaveIfError(fileMan->Rename(KInternalServicesResFileCdrive, KInternalServicesResFileBackup, CFileMan::EOverWrite)); } else { iLog->Put(_L("Landmark framework is flashed, copying global categories to c:")); } User::LeaveIfError(fileMan->Copy(aResourceFile, KInternalServicesResFileCdrive, CFileMan::EOverWrite)); CleanupStack::PopAndDestroy(fileMan); }
void CTestRControlChannel::SavePreviousLogFileL() { _LIT(KInfoLogFile, "Saving Previous logs If any.... \n"); INFO_PRINTF1(KInfoLogFile); RFs fileserv; TInt error = fileserv.Connect(); if(!error) { _LIT(KlogFile, "C:\\logs\\log.txt"); _LIT(KPrefixLog, "C:\\logs\\"); _LIT(KSuffix, "_UDEB"); _LIT(KExtn, ".txt"); CFileMan* fMan = NULL; TRAP_IGNORE(fMan = CFileMan::NewL(fileserv)); if(fMan != NULL) { CleanupStack::PushL(fMan); RBuf newFileName; const TInt KTwenty = 20; newFileName.Create(ConfigSection().Length() + KTwenty ); newFileName.Copy(KPrefixLog); //Script file name iScriptName.Copy(ConfigSection()); newFileName.Append(iScriptName); newFileName.Append(KSuffix); newFileName.Append(KExtn); TInt error = fMan->Rename(KlogFile, newFileName); if (error != KErrNone) { _LIT(KErrInfo, "Unable to Save Previous logs...May be NO Previous logs exist \n"); ERR_PRINTF1(KErrInfo); } else { _LIT(KSavingInfo, "Saved Previous logs with File Name: %S \n"); INFO_PRINTF2(KSavingInfo, &newFileName); } CleanupStack::PopAndDestroy(fMan); newFileName.Close(); } } fileserv.Close(); _LIT(KInfoLogFile1, "Saving Previous logs End.... \n"); INFO_PRINTF1(KInfoLogFile1); }
void IntegrityDeleteFileL(const TDesC& aPath, CIntegrityTreeLeaf* aLeaf, RFs& aFs, RLoader& aLoader, CFileMan& aFileMan) { _LIT(KSysBin, "\\sys\\bin"); RBuf name; name.CreateL(aPath, KMaxFileName); CleanupClosePushL(name); name.Append(aLeaf->Name()); TEntry entry; TInt err = aFs.Entry(name, entry); if (err == KErrNone) { aFs.SetAtt(name, 0, KEntryAttReadOnly); if(entry.IsDir()) { // Make sure to append slash before calling RmDir - otherwise it deletes the parent directory if (name[name.Length()-1] != KPathDelimiter) { name.Append(KPathDelimiter); } User::LeaveIfError(aFileMan.RmDir(name)); } else { if ( aLeaf->Type() == EBackupFile ) // Implies a commit operation is in progress { if ( IsBinary(entry) ) { // Forming the file name so the renamed file can be under sys/bin // for special delete mechanism using RLoader::Delete RBuf tmpName; TParsePtrC fileName(name); tmpName.CreateL(name.Length() + KSysBin.iTypeLength); CleanupClosePushL(tmpName); tmpName.Append(fileName.Drive()); tmpName.Append(KSysBin); tmpName.Append(fileName.Path()); tmpName.Append(fileName.NameAndExt()); DEBUG_PRINTF3(_L("Integrity Services - Renaming %S to %S"), &name, &tmpName); aFileMan.Rename(name,tmpName,CFileMan::EOverWrite); User::LeaveIfError(aLoader.Delete(tmpName)); // Using RLoader delete for paged binaries DEBUG_PRINTF2(_L("Integrity Services - Deleted renamed file %S"), &tmpName); // prune the directory tree if possible RemoveDirectoryTreeL(aFs, tmpName); CleanupStack::PopAndDestroy(&tmpName); } else { User::LeaveIfError(aFileMan.Delete(name)); } } else { // Need to use RLoader Delete which can be used during deletion of Added files during Rollback User::LeaveIfError(aLoader.Delete(name)); } } // prune the directory tree if possible RemoveDirectoryTreeL(aFs, name); } else if(err != KErrNotFound && err != KErrPathNotFound) { DEBUG_PRINTF3(_L("Integrity Services - error %d removing %S"), err, &name); User::Leave(err); } else { DEBUG_PRINTF3(_L("Integrity Services - error %d removing %S"), err, &name); // Check for any renamed files to move it to sys/bin for special delete mechanism RBuf tmpName; TParsePtrC fileName(name); tmpName.CreateL(name.Length() + KSysBin.iTypeLength); CleanupClosePushL(tmpName); tmpName.Append(fileName.Drive()); tmpName.Append(KSysBin); tmpName.Append(fileName.Path()); tmpName.Append(fileName.NameAndExt()); DEBUG_PRINTF2(_L("Integrity Services - Removing %S renamed binary files if any"), &tmpName); aLoader.Delete(tmpName); // prune the directory tree if possible RemoveDirectoryTreeL(aFs, tmpName); CleanupStack::PopAndDestroy(&tmpName); } CleanupStack::PopAndDestroy(&name); }
TUid CDeploymentComponentData::SetDataL(const TFileName &aData, const TDesC8& aMimeType) { RDEBUG_2("CDeploymentComponentData::SetDataL() TFileName: (%S)", &aData); _LIT(KNewPath, "c:\\private\\200267FB\\"); TUid ret(TUid::Null()); iMimeType = aMimeType.Left(KMaxMimeLength) ; RFs fs; User::LeaveIfError(fs.Connect() ); CleanupClosePushL(fs); CFileMan *fm = CFileMan::NewL(fs); CleanupStack::PushL(fm); TFileName fn; fn.Copy(iDataFileName); RDEBUG("App Mgmt before copy start"); TInt maxLength = iDataFileName.Length(); TChar charvaldot = '.'; TChar charvalslash = '\\'; TInt pos = iDataFileName.LocateReverse(charvaldot); TInt lengthDeleted = maxLength-pos; iDataFileName.Delete(pos, lengthDeleted); TInt srcpos = aData.LocateReverse(charvaldot); TBuf<15> extn(aData.Mid(srcpos)); iDataFileName.Append(extn); TFileName newfilepath; newfilepath.Copy(iDataFileName); User::LeaveIfError(fm->Move(aData,KNewPath())); TFileName oldfilepath(KNewPath()); oldfilepath.Append(aData.Mid(aData.LocateReverse(charvalslash))); User::LeaveIfError(fm->Rename(oldfilepath, newfilepath)); //User::LeaveIfError(fm->Copy(aData, fn) ); RDEBUG("App Mgmt before copy End"); if (IsSISInstallFile(aMimeType) ) { ret = ResolveUidL(fs); } CleanupStack::PopAndDestroy(fm); CleanupStack::PopAndDestroy( &fs); RDEBUG_2("CDeploymentComponentData::SetDataL() (%d)", ret.iUid); return ret; }
TUid CDeploymentComponentData::SetDataL(const TDesC8& aMimeType) { RDEBUG8_2("CDeploymentComponentData::SetDataL() aMimeType: (%S)", &aMimeType); TUid ret(TUid::Null()); iMimeType = aMimeType.Left(KMaxMimeLength); if (aMimeType.Length()!=NULL) { TUid ret(TUid::Null()); RFs fs; User::LeaveIfError(fs.Connect()); CleanupClosePushL(fs); CFileMan *fm = CFileMan::NewL(fs); CleanupStack::PushL(fm); TFileName oldfilepath; oldfilepath.Copy(iDataFileName); RDEBUG("App Mgmt before copy start"); TInt maxLength = iDataFileName.Length(); TChar charvaldot = '.'; TChar charvalslash = '\\'; //TFileName oldfilepath; TInt pos = iDataFileName.LocateReverse(charvaldot); TInt lengthDeleted = maxLength - pos; iDataFileName.Delete(pos, lengthDeleted); if (iMimeType == KSisxMimeType) { _LIT16(KExt,".sisx"); iExtn.Append(KExt); } if(iMimeType==KSisMimeType) { _LIT16(KExt,".sis"); iExtn.Append(KExt); } if(iMimeType==KPipMimeType) { _LIT16(KExt,".pip"); iExtn.Append(KExt); } if(iMimeType==KJadMIMEType) { _LIT16(KExt,".jad"); iExtn.Append(KExt); } if(iMimeType==KJarMIMEType) { _LIT16(KExt,".jar"); iExtn.Append(KExt); } if(iMimeType==KJavaMIMEType) { _LIT16(KExt,".jar"); iExtn.Append(KExt); } iDataFileName.Append(iExtn);//file name with sisx extension TFileName newfilepath; newfilepath.Copy(iDataFileName); User::LeaveIfError(fm->Rename(oldfilepath, newfilepath)); CleanupStack::PopAndDestroy(fm); CleanupStack::PopAndDestroy( &fs); //RDEBUG_2(" filename: %S", iDataFileName ); } if (IsSISInstallFile(aMimeType) ) { RFs fs; User::LeaveIfError(fs.Connect() ); CleanupClosePushL(fs); ret = ResolveUidL(fs); CleanupStack::PopAndDestroy( &fs); } RDEBUG8_2("CDeploymentComponentData::SetDataL() UID: (0x%x)", ret.iUid); return ret; }