From beea90b28f2f873e456d9b2e752ba59c28f0fd4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Sverre=20Lien=20Sell=C3=A6g?= Date: Tue, 26 Jan 2021 19:32:01 +0100 Subject: [PATCH] use new filesystem functions for home path --- src/config.cpp | 10 +++++----- src/config.hpp | 2 +- src/project.cpp | 2 +- src/snippets.cpp | 2 +- src/source.cpp | 2 +- src/window.cpp | 6 +++--- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index 3d31e98..1c569a2 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -11,8 +11,8 @@ Config::Config() { if(home_path.empty()) throw std::runtime_error("Could not find home path"); - home_juci_path = filesystem::get_config_path() / "juci"; - juci_config_file = home_juci_path / "config.json"; + juci_config_path = filesystem::get_config_path() / "juci"; + juci_config_file = juci_config_path / "config.json"; } void Config::load() { @@ -30,12 +30,12 @@ void Config::load() { } } - boost::filesystem::create_directories(home_juci_path); + boost::filesystem::create_directories(juci_config_path); if(!boost::filesystem::exists(juci_config_file)) filesystem::write(juci_config_file, default_config_file); - auto juci_style_path = home_juci_path / "styles"; + auto juci_style_path = juci_config_path / "styles"; boost::filesystem::create_directories(juci_style_path); juci_style_path /= "juci-light.xml"; @@ -81,7 +81,7 @@ void Config::update(boost::property_tree::ptree &cfg) { it_version->second.data() = JUCI_VERSION; } - auto style_path = home_juci_path / "styles"; + auto style_path = juci_config_path / "styles"; filesystem::write(style_path / "juci-light.xml", juci_light_style); filesystem::write(style_path / "juci-dark.xml", juci_dark_style); filesystem::write(style_path / "juci-dark-blue.xml", juci_dark_blue_style); diff --git a/src/config.hpp b/src/config.hpp index 28b3a90..530d1cd 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -133,7 +133,7 @@ public: Source source; Log log; - boost::filesystem::path home_juci_path; + boost::filesystem::path juci_config_path; boost::filesystem::path juci_config_file; private: diff --git a/src/project.cpp b/src/project.cpp index 397a303..9b97b93 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -73,7 +73,7 @@ void Project::on_save(size_t index) { if(!view) return; - if(view->file_path == Config::get().home_juci_path / "snippets.json") { + if(view->file_path == Config::get().juci_config_path / "snippets.json") { Snippets::get().load(); for(auto view : Notebook::get().get_views()) view->set_snippets(); diff --git a/src/snippets.cpp b/src/snippets.cpp index 413f520..70c98fe 100644 --- a/src/snippets.cpp +++ b/src/snippets.cpp @@ -5,7 +5,7 @@ #include void Snippets::load() { - auto snippets_file = Config::get().home_juci_path / "snippets.json"; + auto snippets_file = Config::get().juci_config_path / "snippets.json"; boost::system::error_code ec; if(!boost::filesystem::exists(snippets_file, ec)) diff --git a/src/source.cpp b/src/source.cpp index 7000bcd..c1bdd7a 100644 --- a/src/source.cpp +++ b/src/source.cpp @@ -41,7 +41,7 @@ Glib::RefPtr Source::StyleSchemeManager::get_default() static auto instance = Gsv::StyleSchemeManager::create(); static bool first = true; if(first) { - instance->prepend_search_path((Config::get().home_juci_path / "styles").string()); + instance->prepend_search_path((Config::get().juci_config_path / "styles").string()); first = false; } return instance; diff --git a/src/window.cpp b/src/window.cpp index e5cf75b..1498aee 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -282,7 +282,7 @@ void Window::set_menu_actions() { Notebook::get().open(Config::get().juci_config_file); }); menu.add_action("snippets", []() { - Notebook::get().open(Config::get().home_juci_path / "snippets.json"); + Notebook::get().open(Config::get().juci_config_path / "snippets.json"); }); menu.add_action("quit", [this]() { close(); @@ -2210,7 +2210,7 @@ void Window::save_session() { window_pt.put("height", height); root_pt.add_child("window", window_pt); - boost::property_tree::write_json((Config::get().home_juci_path / "last_session.json").string(), root_pt); + boost::property_tree::write_json((Config::get().juci_config_path / "last_session.json").string(), root_pt); } catch(...) { } @@ -2219,7 +2219,7 @@ void Window::save_session() { void Window::load_session(std::vector &directories, std::vector> &files, std::vector> &file_offsets, std::string ¤t_file, bool read_directories_and_files) { try { boost::property_tree::ptree root_pt; - boost::property_tree::read_json((Config::get().home_juci_path / "last_session.json").string(), root_pt); + boost::property_tree::read_json((Config::get().juci_config_path / "last_session.json").string(), root_pt); if(read_directories_and_files) { auto folder = root_pt.get("folder"); if(!folder.empty() && boost::filesystem::exists(folder) && boost::filesystem::is_directory(folder))