From adce2e0c559312e0afabf55bdfc87510a4f02ec3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Sverre=20Lien=20Sell=C3=A6g?= Date: Sat, 30 Jan 2021 15:51:33 +0100 Subject: [PATCH] use data path for data files --- src/config.cpp | 2 ++ src/config.hpp | 1 + src/window.cpp | 5 +++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index 1c569a2..898fbdc 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -13,6 +13,7 @@ Config::Config() { juci_config_path = filesystem::get_config_path() / "juci"; juci_config_file = juci_config_path / "config.json"; + juci_data_path = filesystem::get_data_path() / "juci"; } void Config::load() { @@ -31,6 +32,7 @@ void Config::load() { } boost::filesystem::create_directories(juci_config_path); + boost::filesystem::create_directories(juci_data_path); if(!boost::filesystem::exists(juci_config_file)) filesystem::write(juci_config_file, default_config_file); diff --git a/src/config.hpp b/src/config.hpp index 530d1cd..bf80886 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -135,6 +135,7 @@ public: boost::filesystem::path juci_config_path; boost::filesystem::path juci_config_file; + boost::filesystem::path juci_data_path; private: /// Used to dispatch Terminal outputs after juCi++ GUI setup and configuration diff --git a/src/window.cpp b/src/window.cpp index 1498aee..a478216 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1,3 +1,4 @@ + #include "window.hpp" #include "config.hpp" #ifdef JUCI_ENABLE_DEBUG @@ -2210,7 +2211,7 @@ void Window::save_session() { window_pt.put("height", height); root_pt.add_child("window", window_pt); - boost::property_tree::write_json((Config::get().juci_config_path / "last_session.json").string(), root_pt); + boost::property_tree::write_json((Config::get().juci_data_path / "last_session.json").string(), root_pt); } catch(...) { } @@ -2219,7 +2220,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().juci_config_path / "last_session.json").string(), root_pt); + boost::property_tree::read_json((Config::get().juci_data_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))