Browse Source

use data path for data files

xdg
Jørgen Lien Sellæg 5 years ago
parent
commit
adce2e0c55
  1. 2
      src/config.cpp
  2. 1
      src/config.hpp
  3. 5
      src/window.cpp

2
src/config.cpp

@ -13,6 +13,7 @@ Config::Config() {
juci_config_path = filesystem::get_config_path() / "juci"; juci_config_path = filesystem::get_config_path() / "juci";
juci_config_file = juci_config_path / "config.json"; juci_config_file = juci_config_path / "config.json";
juci_data_path = filesystem::get_data_path() / "juci";
} }
void Config::load() { void Config::load() {
@ -31,6 +32,7 @@ void Config::load() {
} }
boost::filesystem::create_directories(juci_config_path); boost::filesystem::create_directories(juci_config_path);
boost::filesystem::create_directories(juci_data_path);
if(!boost::filesystem::exists(juci_config_file)) if(!boost::filesystem::exists(juci_config_file))
filesystem::write(juci_config_file, default_config_file); filesystem::write(juci_config_file, default_config_file);

1
src/config.hpp

@ -135,6 +135,7 @@ public:
boost::filesystem::path juci_config_path; boost::filesystem::path juci_config_path;
boost::filesystem::path juci_config_file; boost::filesystem::path juci_config_file;
boost::filesystem::path juci_data_path;
private: private:
/// Used to dispatch Terminal outputs after juCi++ GUI setup and configuration /// Used to dispatch Terminal outputs after juCi++ GUI setup and configuration

5
src/window.cpp

@ -1,3 +1,4 @@
#include "window.hpp" #include "window.hpp"
#include "config.hpp" #include "config.hpp"
#ifdef JUCI_ENABLE_DEBUG #ifdef JUCI_ENABLE_DEBUG
@ -2210,7 +2211,7 @@ void Window::save_session() {
window_pt.put("height", height); window_pt.put("height", height);
root_pt.add_child("window", window_pt); 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(...) { catch(...) {
} }
@ -2219,7 +2220,7 @@ void Window::save_session() {
void Window::load_session(std::vector<boost::filesystem::path> &directories, std::vector<std::pair<boost::filesystem::path, size_t>> &files, std::vector<std::pair<int, int>> &file_offsets, std::string &current_file, bool read_directories_and_files) { void Window::load_session(std::vector<boost::filesystem::path> &directories, std::vector<std::pair<boost::filesystem::path, size_t>> &files, std::vector<std::pair<int, int>> &file_offsets, std::string &current_file, bool read_directories_and_files) {
try { try {
boost::property_tree::ptree root_pt; 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) { if(read_directories_and_files) {
auto folder = root_pt.get<std::string>("folder"); auto folder = root_pt.get<std::string>("folder");
if(!folder.empty() && boost::filesystem::exists(folder) && boost::filesystem::is_directory(folder)) if(!folder.empty() && boost::filesystem::exists(folder) && boost::filesystem::is_directory(folder))

Loading…
Cancel
Save