From 6ca1741e83ce8ea7e9338fa1f7a401acd07c2b8d Mon Sep 17 00:00:00 2001 From: SoftFever Date: Sun, 15 Sep 2024 22:58:41 +0800 Subject: [PATCH] Check and use data_dir folder if exists under application path (#6780) --- src/slic3r/GUI/GUI_App.cpp | 42 +++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index d6e9294b7a..937d1d9b91 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1908,23 +1908,31 @@ void GUI_App::init_app_config() // Mac : "~/Library/Application Support/Slic3r" if (data_dir().empty()) { - boost::filesystem::path data_dir_path; - #ifndef __linux__ - std::string data_dir = wxStandardPaths::Get().GetUserDataDir().ToUTF8().data(); - //BBS create folder if not exists - data_dir_path = boost::filesystem::path(data_dir); - set_data_dir(data_dir); - #else - // Since version 2.3, config dir on Linux is in ${XDG_CONFIG_HOME}. - // https://github.com/prusa3d/PrusaSlicer/issues/2911 - wxString dir; - if (! wxGetEnv(wxS("XDG_CONFIG_HOME"), &dir) || dir.empty() ) - dir = wxFileName::GetHomeDir() + wxS("/.config"); - set_data_dir((dir + "/" + GetAppName()).ToUTF8().data()); - data_dir_path = boost::filesystem::path(data_dir()); - #endif - if (!boost::filesystem::exists(data_dir_path)){ - boost::filesystem::create_directory(data_dir_path); + // Orca: check if data_dir folder exists in application folder + // use it if it exists + boost::filesystem::path app_data_dir_path = boost::filesystem::current_path() / "data_dir"; + if (boost::filesystem::exists(app_data_dir_path)) { + set_data_dir(app_data_dir_path.string()); + } + else{ + boost::filesystem::path data_dir_path; + #ifndef __linux__ + std::string data_dir = wxStandardPaths::Get().GetUserDataDir().ToUTF8().data(); + //BBS create folder if not exists + data_dir_path = boost::filesystem::path(data_dir); + set_data_dir(data_dir); + #else + // Since version 2.3, config dir on Linux is in ${XDG_CONFIG_HOME}. + // https://github.com/prusa3d/PrusaSlicer/issues/2911 + wxString dir; + if (! wxGetEnv(wxS("XDG_CONFIG_HOME"), &dir) || dir.empty() ) + dir = wxFileName::GetHomeDir() + wxS("/.config"); + set_data_dir((dir + "/" + GetAppName()).ToUTF8().data()); + data_dir_path = boost::filesystem::path(data_dir()); + #endif + if (!boost::filesystem::exists(data_dir_path)){ + boost::filesystem::create_directory(data_dir_path); + } } // Change current dirtory of application