static TextWriter OpenLog() { static bool initialised = false; static AllocatedPath path = nullptr; const bool append = initialised; if (!initialised) { initialised = true; /* delete the obsolete log file */ File::Delete(LocalPath(_T("xcsoar-startup.log"))); path = LocalPath(_T("xcsoar.log")); File::Replace(path, LocalPath(_T("xcsoar-old.log"))); #ifdef ANDROID /* redirect stdout/stderr to xcsoar-startup.log on Android so we get debug logs from libraries and output from child processes there */ int fd = open(path.c_str(), O_APPEND|O_CREAT|O_WRONLY, 0666); if (fd >= 0) { dup2(fd, 1); dup2(fd, 2); close(fd); } #endif } return TextWriter(path, append); }
void Profile::Save() { if (!IsModified()) return; LogFormat("Saving profiles"); if (startProfileFile.IsNull()) SetFiles(nullptr); assert(!startProfileFile.IsNull()); SaveFile(startProfileFile); }
void Profile::Load() { assert(!startProfileFile.IsNull()); LogFormat("Loading profiles"); LoadFile(startProfileFile); SetModified(false); }
static void ParseCommandLine(Args &args) { path = args.ExpectNextPath(); #ifdef USE_GDI TCHAR *endptr; unsigned _id = ParseUnsigned(path.c_str(), &endptr); if (StringIsEmpty(endptr)) id = ResourceId(_id); #endif }
void CloudServer::Save() { cout << "Saving data to " << db_path.c_str() << endl; FileOutputStream fos(db_path); { Serialiser s(fos); CloudData::Save(s); s.Flush(); } fos.Commit(); }
bool IsDefined() const { return !path.IsNull(); }
bool InterfaceConfigPanel::Save(bool &_changed) { UISettings &settings = CommonInterface::SetUISettings(); bool changed = false;; if (SaveValueEnum(UIScale, ProfileKeys::UIScale, settings.scale)) require_restart = changed = true; if (SaveValueFileReader(InputFile, ProfileKeys::InputFile)) require_restart = changed = true; #ifndef HAVE_NATIVE_GETTEXT WndProperty *wp = (WndProperty *)&GetControl(LanguageFile); if (wp != nullptr) { DataFieldEnum &df = *(DataFieldEnum *)wp->GetDataField(); const auto old_value_buffer = Profile::GetPath(ProfileKeys::LanguageFile); Path old_value = old_value_buffer; if (old_value == nullptr) old_value = Path(_T("")); auto old_base = old_value.GetBase(); if (old_base == nullptr) old_base = old_value; AllocatedPath buffer = nullptr; const TCHAR *new_value, *new_base; switch (df.GetValue()) { case 0: new_value = new_base = _T("auto"); break; case 1: new_value = new_base = _T("none"); break; default: new_value = df.GetAsString(); buffer = ContractLocalPath(Path(new_value)); if (!buffer.IsNull()) new_value = buffer.c_str(); new_base = Path(new_value).GetBase().c_str(); if (new_base == nullptr) new_base = new_value; break; } if (old_value != Path(new_value) && old_base != Path(new_base)) { Profile::Set(ProfileKeys::LanguageFile, new_value); LanguageChanged = changed = true; } } #endif unsigned menu_timeout = GetValueInteger(MenuTimeout) * 2; if (settings.menu_timeout != menu_timeout) { settings.menu_timeout = menu_timeout; Profile::Set(ProfileKeys::MenuTimeout, menu_timeout); changed = true; } if (HasPointer()) changed |= SaveValueEnum(TextInput, ProfileKeys::AppTextInputStyle, settings.dialog.text_input_style); #ifdef HAVE_VIBRATOR changed |= SaveValueEnum(HapticFeedback, ProfileKeys::HapticFeedback, settings.haptic_feedback); #endif _changed |= changed; return true; }