void Ide::SaveConfig() { SaveChangedFile(ConfigFile(), StoreAsString(*this)); if(GetIniKey("DebugClipboard") == "1") { SaveChangedFile(ConfigFile() + ".bak", StoreAsString(*this)); StoreToFile(*this, ConfigFile() + ".bak1"); } SaveChangedFile(ConfigFile("ide.key"), StoreKeys()); SaveChangedFile(ConfigFile("ide.colors"), editor.StoreHlStyles()); config_time = ConfigTime(); }
void Ide::LoadLastMain() { bool editor = IsEditorMode(); LoadFromFile(THISBACK(SerializeLastMain), ConfigFile("lastmain.cfg")); if(editor) main <<= Null; }
void ADynamicWeather::LoadWeatherDescriptionsFromFile( const FString &MapName, TArray<FWeatherDescription> &Descriptions) { // Try to load config file. FString DefaultFilePath; if (GetWeatherIniFilePath(GetIniFileName(), DefaultFilePath)) { UE_LOG(LogCarla, Log, TEXT("Loading weather description from %s"), *DefaultFilePath); FIniFile ConfigFile(DefaultFilePath); { // Override map specific presets. FString MapOverridesFilePath; if (GetWeatherIniFilePath(GetIniFileName(MapName), MapOverridesFilePath)) { UE_LOG(LogCarla, Log, TEXT("Loading weather description from %s"), *MapOverridesFilePath); ConfigFile.Combine(MapOverridesFilePath); } } // For every section in the config file add a weather description. for (auto &Item : ConfigFile.GetFConfigFile()) { Descriptions.AddDefaulted(1u); Descriptions.Last().ReadFromConfigFile(ConfigFile, Item.Key); } } // If no description was found, append a defaulted one. if (Descriptions.Num() == 0) { UE_LOG(LogCarla, Warning, TEXT("No weather description found")); Descriptions.AddDefaulted(1u); Descriptions.Last().Name = TEXT("Default"); } }
void WorkspaceWork::PackageCursor() { InvalidatePackageCache(); filelist.WhenBar.Clear(); actualpackage = GetActivePackage(); svn_dirs = false; if(actualpackage.IsEmpty()) return; if(actualpackage == METAPACKAGE) { actual.file.Clear(); actual.file.AddPick(Package::File(String(HELPNAME))); Vector<String> d = GetUppDirs(); for(int i = 0; i < d.GetCount(); i++) actual.file.AddPick(Package::File(AppendFileName(d[i], "$.tpp"))); actual.file.AddPick(Package::File(ConfigFile("global.defs"))); } else { String pp = PackagePathA(actualpackage); RealizePath(pp); actual.Load(pp); } LoadActualPackage(); filelist.Enable(); if(actualpackage != METAPACKAGE) filelist.WhenBar = THISBACK(FileMenu); svn_dirs = SvnDirs(true).GetCount(); }
void Folder::slotNewBigFolderDiscovered(const QString &newF) { auto newFolder = newF; if (!newFolder.endsWith(QLatin1Char('/'))) { newFolder += QLatin1Char('/'); } auto journal = journalDb(); // Add the entry to the blacklist if it is neither in the blacklist or whitelist already auto blacklist = journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList); auto whitelist = journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList); if (!blacklist.contains(newFolder) && !whitelist.contains(newFolder)) { blacklist.append(newFolder); journal->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, blacklist); } // And add the entry to the undecided list and signal the UI auto undecidedList = journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList); if (!undecidedList.contains(newFolder)) { undecidedList.append(newFolder); journal->setSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, undecidedList); emit newBigFolderDiscovered(newFolder); } QString message = tr("A new folder larger than %1 MB has been added: %2.\n" "Please go in the settings to select it if you wish to download it.") .arg(ConfigFile().newBigFolderSizeLimit().second).arg(newF); auto logger = Logger::instance(); logger->postOptionalGuiLog(Theme::instance()->appNameGUI(), message); }
void Ide::Preprocess(bool asmout) { if(editfile.IsEmpty()) return; int pi = GetPackageIndex(); if(pi < 0) return; SwitchHeader(); String pfn = ConfigFile(GetFileTitle(editfile) + ".i.tmp"); DeleteFile(pfn); const Workspace& wspc = IdeWorkspace(); if(pi >= wspc.GetCount()) return; One<Host> host = CreateHost(true); One<Builder> b = CreateBuilder(~host); Vector<String> linkfile; String linkopt; b->config = PackageConfig(wspc, pi, GetMethodVars(method), mainconfigparam, *host, *b); console.Clear(); PutConsole((asmout ? "Compiling " : "Preprocessing ") + editfile); b->Preprocess(wspc[pi], editfile, pfn, asmout); HideBottom(); if(FileExists(pfn)) { EditFile(pfn); if(!editor.IsReadOnly()) ToggleReadOnly(); } }
void defList::Save() { if (path.IsEmpty()) { path = ConfigFile(name + ".list") ; } else if ( name != GetFileTitle(path)) { path = GetFileDirectory(path) + name + ".list" ; } String s ; s << "name=" << name << "\r\n" << "fields=" ; for (int i = 0; i < fields.GetCount(); i++) s << fields[i] << "," ; s << "\r\n" ; for (int i = 0; i < data.GetCount(); i++) { s << "data_" << i << "=" ; Vector<String>&line = data[i] ; for (int j = 0; j < line.GetCount(); j++) { if (j > 0) s << "," ; s << "\"" << line[j] << "\"" ; } s << "\r\n" ; } for (int i = 0; i < errors.GetCount(); i++) s << "error_" << i << "=" << errors[i] << "\r\n" ; SaveFile(path, s) ; }
/*! Parse a configuration file for each of the possible parameters, assigning default values for parameters that are not explicitly specified. */ void VCParams::read_params(const std::string ¶m_file_name) { params = ConfigFile(param_file_name); // Call each of the parameter checks to set the default value if it's not already set params.readSet<string>("sim.version", ""); params.readSet<double>("sim.time.start_year", 0.0); params.readSet<double>("sim.time.end_year", 1000.0); // in terms of # of events between state saves params.readSet<int>("sim.system.checkpoint_period", 0); params.readSet<string>("sim.system.checkpoint_prefix", "sim_state_"); params.readSet<unsigned int>("sim.system.progress_period", 0); params.readSet<double>("sim.friction.dynamic", INFINITY); params.readSet<double>("sim.greens.kill_distance", 0.0); double dist = params.readSet<double>("sim.greens.sample_distance", 1000.0); if (dist <= 0) params.add("sim.greens.sample_distance", "1000.0"); std::string greens_method = params.readSet<string>("sim.greens.method", "standard"); // Parse the Greens calculation method string if (greens_method.compare("file") && greens_method.compare("bh") && greens_method.compare("standard")) { params.add("sim.greens.method", "undefined"); } // controls how much smoothing occurs in Barnes-Hut approximation params.readSet<double>("sim.greens.bh_theta", 0.0); params.readSet<string>("sim.greens.input", ""); params.readSet<unsigned int>("sim.bass.max_generations", 0); params.readSet<double>("sim.bass.mm", 4.0); params.readSet<double>("sim.bass.dm", 1.25); params.readSet<double>("sim.bass.b", 1.0); params.readSet<double>("sim.bass.c", 0.1); params.readSet<double>("sim.bass.p", 1.25); params.readSet<double>("sim.bass.d", 300); params.readSet<double>("sim.bass.q", 1.35); params.readSet<bool>("sim.system.sanity_check", false); params.readSet<bool>("sim.greens.use_normal", true); params.readSet<bool>("sim.system.transpose_matrix", true); params.readSet<string>("sim.file.input", ""); params.readSet<string>("sim.file.input_type", ""); params.readSet<string>("sim.greens.output", ""); params.readSet<string>("sim.file.output_event", ""); params.readSet<string>("sim.file.output_sweep", ""); params.readSet<string>("sim.file.output_event_type", ""); params.readSet<string>("sim.file.output_stress", ""); params.readSet<string>("sim.file.output_stress_index", ""); params.readSet<string>("sim.file.output_stress_type", ""); }
void Folder::slotRunEtagJob() { qDebug() << "* Trying to check" << alias() << "for changes via ETag check. (time since last sync:" << (_timeSinceLastSyncDone.elapsed() / 1000) << "s)"; Q_ASSERT(_accountState ); AccountPtr account = _accountState->account(); if (!_requestEtagJob.isNull()) { qDebug() << Q_FUNC_INFO << alias() << "has ETag job queued, not trying to sync"; return; } if (_definition.paused || !_accountState->isConnected()) { qDebug() << "Not syncing. :" << alias() << _definition.paused << AccountState::stateString(_accountState->state()); return; } bool forceSyncIntervalExpired = quint64(_timeSinceLastSyncDone.elapsed()) > ConfigFile().forceSyncInterval(); bool syncAgainAfterFail = _consecutiveFailingSyncs > 0 && _consecutiveFailingSyncs < 3; // There are several conditions under which we trigger a full-discovery sync: // * When a suitably long time has passed since the last sync finished // * When the last sync failed (only a couple of times) // * When the last sync requested another sync to be done (only a couple of times) // // Note that the etag check (see below) and the file watcher may also trigger // syncs. if (forceSyncIntervalExpired || _forceSyncOnPollTimeout || syncAgainAfterFail) { if (forceSyncIntervalExpired) { qDebug() << "** Force Sync, because it has been " << _timeSinceLastSyncDone.elapsed() << "ms " << "since the last sync"; } if (_forceSyncOnPollTimeout) { qDebug() << "** Force Sync, because it was requested"; } if (syncAgainAfterFail) { qDebug() << "** Force Sync, because the last" << _consecutiveFailingSyncs << "syncs failed, last status:" << _syncResult.statusString(); } _forceSyncOnPollTimeout = false; emit scheduleToSync(this); } else { // Do the ordinary etag check for the root folder and only schedule a real // sync if it's different. _requestEtagJob = new RequestEtagJob(account, remotePath(), this); // check if the etag is different QObject::connect(_requestEtagJob, SIGNAL(etagRetreived(QString)), this, SLOT(etagRetreived(QString))); FolderMan::instance()->slotScheduleETagJob(alias(), _requestEtagJob); // The _requestEtagJob is auto deleting itself on finish. Our guard pointer _requestEtagJob will then be null. } }
String Ide::WorkspaceFile() { String nm; for(const char *s = main; *s; s++) nm.Cat(*s == '\\' || *s == '/' ? '$' : *s); String cfg = ConfigFile("cfg"); RealizeDirectory(cfg); return AppendFileName(cfg, ForceExt(nm + '@' + GetVarsName(), ".cfg")); }
void UppList::Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const { FileList::File file = ValueTo<FileList::File>(q); if(GetFileName(file.name) == "$.tpp" && IsFolder(file.name)) file.name = GetFileName(GetFileFolder(file.name)) + " templates"; if(file.name == ConfigFile("global.defs")) file.name = "Fixed macros"; FileList::Paint(w, r, RawToValue(file), ink, paper, style); }
void FormEdit::LoadGUILayouts(bool first) { LoadFromFile(*this, ConfigFile("Layouts.bin")); const ArrayMap<String, String>& p = GetLayouts(); _GUILayouts.Clear(); for (int i = 0; i < p.GetCount(); i++) _GUILayouts.Add(p.GetKey(i)); if (first) _GUILayouts <<= t_(" Default"); }
bool ADynamicWeather::SaveToConfigFile() const { FString FilePath; if (GetWeatherIniFilePath(FileName, FilePath) && CheckWeatherValidity(Weather)) { FIniFile ConfigFile(FilePath); Weather.WriteToConfigFile(ConfigFile); return ConfigFile.Write(FilePath); } else { return false; } }
void Ide::LoadConfig() { if(!LoadFromFile(*this) && GetIniKey("DebugClipboard") == "1") { Exclamation("LoadConfig has failed!"); if(!LoadFromFile(*this, ConfigFile() + ".bak")) { Exclamation("LoadConfig .bak has failed!"); if(!LoadFromFile(*this, ConfigFile() + ".bak1")) Exclamation("LoadConfig .bak1 has failed!"); } } RestoreKeys(LoadFile(ConfigFile("ide.key"))); editor.LoadHlStyles(LoadFile(ConfigFile("ide.colors"))); config_time = FileGetTime(ConfigFile()); UpdateFormat(); if(filelist.IsCursor()) { FlushFile(); FileCursor(); } SaveLoadPackage(); SyncCh(); }
void WorkspaceWork::LoadActualPackage() { Time utime = FileGetTime(ConfigFile("version")); filelist.Clear(); fileindex.Clear(); bool open = true; Time tm = GetSysTime(); for(int i = 0; i < actual.file.GetCount(); i++) { Package::File& f = actual.file[i]; if(f.separator) { open = closed.Find(Sepfo(actualpackage, f)) < 0; filelist.Add(f, open ? IdeImg::SeparatorClose() : IdeImg::SeparatorOpen(), ListFont().Bold(), open ? SColorMark : SColorText, true, 0, Null); fileindex.Add(i); } else if(open) { Color uln = Null; String p = SourcePath(GetActivePackage(), f); if(showtime) { FindFile ff(p); if(ff) { Time ftm = Time(ff.GetLastWriteTime()); if(ftm > utime) { int64 t = tm - ftm; if(t < 24 * 3600) uln = SColorMark; else if(t < 32 * 24 * 3600) uln = SColorDisabled; } } } Image m = IdeFileImage(f, f.optimize_speed, false, f.pch); if(GetFileExt(p) == ".tpp" && IsFolder(p)) { if(FileExists(AppendFileName(p, "all.i"))) m = TopicImg::IGroup(); else m = TopicImg::Group(); } #ifdef PLATFORM_WIN32 p = ToLower(p); #endif if(errorfiles.Find(p) >= 0) { m = ImageOverRed(m); uln = LtRed; } filelist.Add(f, m, ListFont(), SColorText, false, 0, Null, SColorMark, Null, Null, Null, uln); fileindex.Add(i); } } }
Speller *sGetSpeller(int lang) { static ArrayMap<int, Speller> speller; int q = speller.Find(lang); if(q < 0) { String pp = spell_path; DoSpellerPath(pp, GetExeDirFile("scd")); DoSpellerPath(pp, ConfigFile("scd")); pp << spell_path << ';' << getenv("LIB") << ';' << getenv("PATH") << ';'; String path = GetFileOnPath(ToLower(LNGAsText(lang)) + ".udc", pp); if(IsNull(path)) path = GetFileOnPath(ToLower(LNGAsText(lang)) + ".scd", pp); if(IsNull(path)) return NULL; FileIn in(path); if(!in) return NULL; q = speller.GetCount(); Speller& f = speller.Add(lang); FileIn user(sUserFile(lang)); while(!user.IsEof()) { String s = user.GetLine(); if(!s.IsEmpty()) f.user.Add(FromUtf8(s)); } if(in.Get() != 255) f.SetOld(LoadFile(path)); else { f.path = path; int n = in.GetL(); LLOG("Found scd file " << path << " blocks " << n); if(n > 0 && n < 100000) { for(int i = 0; i < n; i++) { SpellBlock& b = f.block.Add(); b.first = in.Get(in.Get()); b.ctrl_len = in.GetL(); b.text_len = in.GetL(); } if(in.IsEof()) f.block.Clear(); else { int off = (int)in.GetPos(); for(int i = 0; i < n; i++) { SpellBlock& b = f.block[i]; b.offset = off; off += b.ctrl_len + b.text_len; } } } } } return &speller[q]; }
void FormEdit::DockInit() { WindowButtons(false, false, true); DockLeft(Dockable(_LayoutList, t_("Layouts")).SizeHint(Size(200, 200))); DockRight(Dockable(_ItemList, t_("Items")).SizeHint(Size(250, 200))); DockRight(Dockable(_ItemProperties, t_("Item properties")).SizeHint(Size(250, 300))); if (!FileExists(ConfigFile("Layouts.bin"))) SaveLayout(t_(" Default")); LoadGUILayouts(true); UpdateTools(); UpdateGUILayout(); }
void bigmailer::onOpenList() { FileSel fs; fs.ActiveDir(ConfigFile("")) ; fs.Type("list files", "*.list") ; if ( ! fs.ExecuteOpen(t_("select a list file") ) ) return; onCloseList() ; theDefList.Load(fs.Get()) ; SetTitle() ; }
void SelectPackageDlg::SyncBase(String initvars) { Vector<String> varlist; for(FindFile ff(ConfigFile("*.var")); ff; ff.Next()) if(ff.IsFile()) varlist.Add(GetFileTitle(ff.GetName())); Sort(varlist, &PackageLess); base.Clear(); Append(base, varlist); if(!base.FindSetCursor(initvars)) if(base.GetCount() > 0) base.SetCursor(0); else OnBase(); }
bool ADynamicWeather::LoadFromConfigFile() { FString FilePath; if (GetWeatherIniFilePath(FileName, FilePath) && CheckWeatherValidity(Weather)) { FIniFile ConfigFile(FilePath); if (!ConfigFile.HasSection(Weather.Name)) { UE_LOG(LogCarla, Error, TEXT("Weather \"%s\" is not present in config file"), *Weather.Name); return false; } Weather.ReadFromConfigFile(ConfigFile, Weather.Name); return true; } else { return false; } }
String WorkspaceWork::PackagePathA(const String& pn) { if(pn == prjaux) { String nm; String cfg = ConfigFile("cfg"); for(const char *s = main; *s; s++) nm.Cat(*s == '\\' || *s == '/' ? '$' : *s); RealizeDirectory(cfg); return AppendFileName(cfg, ForceExt(nm + '@' + GetVarsName(), ".aux")); } if(pn == ideaux) return ConfigFile("ide.aux"); if(pn == tempaux) return ConfigFile(Sprintf("aux%x.tmp", #ifdef PLATFORM_WIN32 GetCurrentProcessId() #endif #ifdef PLATFORM_POSIX getpid() #endif )); if(pn == METAPACKAGE) return Null; return PackagePath(pn); }
void bigMailerCfg::Save() { const String enter = "\r\n" ; String s = "lastList=" + lastList + enter + "lastMsg=" + lastMsg + enter + "smtpServer=" + smtpServer + enter + "user="******"pass="******"blacklist_" << i << "=" << blackList[i] << enter ; SaveFile(ConfigFile("bigmailer.ini"), s ) ; }
void FormEdit::TestLayout() { String preview = (_File.IsEmpty()) ? ConfigFile("FormEditor.view") : GetFileDirectory(_File) + "\\" + "FormEditor.view"; _View.SaveAll(preview, false); Form form; form.Load(preview); form.Layout(_View.GetCurrentLayout()->Get("Form.Name"), _View.GetFont()); form.ExecuteForm(); DeleteFile(preview); }
void Ide::PreprocessInternal() { if(editor.GetLength() >= 1000000) // Sanity... return; int l = editor.GetCurrentLine(); PPSync(GetIncludePath()); String pfn = ConfigFile(GetFileTitle(editfile) + ".i.tmp"); Cpp cpp; StringStream in(editor.Get()); String p = NormalizeSourcePath(editfile); cpp.Preprocess(p, in, GetMasterFile(p)); Upp::SaveFile(pfn, cpp.output); HideBottom(); EditFile(pfn); EditAsText(); if(!editor.IsReadOnly()) ToggleReadOnly(); editor.SetCursor(editor.GetPos(l)); }
void TemplateDlg::Load(const Vector<String>& p, bool main) { pt.Clear(); for(int i = 0; i < p.GetCount(); i++) { LoadNest(p[i], main); nest.Add(p[i]); } LoadNest(GetLocalDir(), main); LoadNest(GetFileFolder(ConfigFile("x")), main, false); Sort(pt, FieldRelation(&PackageTemplate::name, StdLess<String>())); templist.Clear(); templist.Add("<empty>"); for(int i = 0; i < pt.GetCount(); i++) templist.Add(pt[i].name); if(nest.GetCount()) nest.SetIndex(0); templist.GoBegin(); ActiveFocus(package); }
void Ide::SyncBuildMode() { SetupDefaultMethod(); Vector<String> bmlist; for(FindFile ff(ConfigFile("*.bm")); ff; ff.Next()) bmlist.Add(GetFileTitle(ff.GetName())); Sort(bmlist); methodlist.Clear(); Append(methodlist, bmlist); String h = method + ' '; switch(targetmode) { case 1: h << "Optimal"; break; case 2: h << "Speed"; break; case 3: h << "Size"; break; default: h << "Debug"; } buildmode <<= h; }
void Ide::SetupDefaultMethod() { if(IsNull(method)) { SetMethod(GetDefaultMethod()); if(IsNull(method)) { FindFile ff(ConfigFile("*.bm")); if(!ff) return; SetMethod(GetFileTitle(ff.GetName())); } VectorMap<String, String> map = GetMethodVars(method); debug.linkmode = atoi(map.Get("DEBUG_LINKMODE", "0")); debug.def.debug = atoi(map.Get("DEBUG_INFO", "0")); debug.def.blitz = MapFlag(map, "DEBUG_BLITZ"); release.linkmode = atoi(map.Get("RELEASE_LINKMODE", "0")); release.def.debug <<= 0; release.def.blitz = MapFlag(map, "RELEASE_BLITZ"); } }
void Ide::SyncUsc() { CleanUsc(); if(IsNull(main)) return; ::Workspace wspc; wspc.Scan(main); int i; for(i = 0; i < wspc.GetCount(); i++) { const Package& p = wspc.GetPackage(i); for(int j = 0; j < p.file.GetCount(); j++) { String file = SourcePath(wspc[i], p.file[j]); if(ToLower(GetFileExt(file)) == ".usc") UscFile(file); } } UscProcessDir(GetLocalDir()); UscProcessDir(GetFileFolder(ConfigFile("x"))); }
int MatchNameWithConfigFile(char* compare, string file_name){ string config_name, config_value; ifstream ConfigFile (file_name.c_str()); if (!ConfigFile.fail()){ DebugPrint("%s Loading...", file_name.c_str()); if (ConfigFile.is_open()){ while ( !ConfigFile.eof()){ ConfigFile >> config_name; DebugPrint("\nGet %s", config_name.c_str()); if (compare == config_name){ DebugPrint(" Matched\n", config_name.c_str()); return 1; } } } DebugPrint("%s is not matched\n", config_name); return 0; }else{
void defMsg::Save() { if (path.IsEmpty()) { path = ConfigFile(name + ".msg") ; } else if ( name != GetFileTitle(path)) { path = GetFileDirectory(path) + name + ".msg" ; } String f ; f << "from=" << from << "\r\n" << "subject="<< subject << "\r\n" ; Vector<String> lines = String2VectorString(qtfBody) ; for (int i = 0; i < lines.GetCount(); i++) f << "body" << i << "=" << lines[i] << "\r\n" ; SaveFile(path, f) ; }