Browse Source

Additional checks to reopened folder and files at startup

merge-requests/365/head
eidheim 10 years ago
parent
commit
28eae2a12a
  1. 6
      src/juci.cc

6
src/juci.cc

@ -52,15 +52,15 @@ void Application::on_activate() {
boost::property_tree::ptree pt; boost::property_tree::ptree pt;
boost::property_tree::read_json((Config::get().juci_home_path()/"last_session.json").string(), pt); boost::property_tree::read_json((Config::get().juci_home_path()/"last_session.json").string(), pt);
auto folder=pt.get<std::string>("folder"); auto folder=pt.get<std::string>("folder");
if(!folder.empty() && boost::filesystem::exists(folder)) if(!folder.empty() && boost::filesystem::exists(folder) && boost::filesystem::is_directory(folder))
directories.emplace_back(folder); directories.emplace_back(folder);
for(auto &v: pt.get_child("files")) { for(auto &v: pt.get_child("files")) {
std::string file=v.second.data(); std::string file=v.second.data();
if(!file.empty() && boost::filesystem::exists(file)) if(!file.empty() && boost::filesystem::exists(file) && !boost::filesystem::is_directory(file))
files.emplace_back(file); files.emplace_back(file);
} }
last_current_file=pt.get<std::string>("current_file"); last_current_file=pt.get<std::string>("current_file");
if(!boost::filesystem::exists(last_current_file)) if(!boost::filesystem::exists(last_current_file) || boost::filesystem::is_directory(last_current_file))
last_current_file.clear(); last_current_file.clear();
} }
catch(const std::exception &) {} catch(const std::exception &) {}

Loading…
Cancel
Save