mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 09:17:52 -06:00
skip .stl/.png file when copying system profiles
This commit is contained in:
parent
38409359a8
commit
9f1d47117e
3 changed files with 25 additions and 4 deletions
|
@ -654,7 +654,7 @@ inline std::string filter_characters(const std::string& str, const std::string&
|
||||||
return filteredStr;
|
return filteredStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void copy_directory_recursively(const boost::filesystem::path &source, const boost::filesystem::path &target);
|
void copy_directory_recursively(const boost::filesystem::path &source, const boost::filesystem::path &target, std::function<bool(const std::string)> filter = nullptr);
|
||||||
|
|
||||||
// Orca: Since 1.7.9 Boost deprecated save_string_file and load_string_file, copy and modified from boost 1.7.8
|
// Orca: Since 1.7.9 Boost deprecated save_string_file and load_string_file, copy and modified from boost 1.7.8
|
||||||
void save_string_file(const boost::filesystem::path& p, const std::string& str);
|
void save_string_file(const boost::filesystem::path& p, const std::string& str);
|
||||||
|
|
|
@ -1509,7 +1509,7 @@ bool bbl_calc_md5(std::string &filename, std::string &md5_out)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SoftFever: copy directory recursively
|
// SoftFever: copy directory recursively
|
||||||
void copy_directory_recursively(const boost::filesystem::path &source, const boost::filesystem::path &target)
|
void copy_directory_recursively(const boost::filesystem::path &source, const boost::filesystem::path &target, std::function<bool(const std::string)> filter)
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(info) << Slic3r::format("copy_directory_recursively %1% -> %2%", source, target);
|
BOOST_LOG_TRIVIAL(info) << Slic3r::format("copy_directory_recursively %1% -> %2%", source, target);
|
||||||
std::string error_message;
|
std::string error_message;
|
||||||
|
@ -1528,6 +1528,8 @@ void copy_directory_recursively(const boost::filesystem::path &source, const boo
|
||||||
copy_directory_recursively(dir_entry, target_path);
|
copy_directory_recursively(dir_entry, target_path);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if(filter && filter(name))
|
||||||
|
continue;
|
||||||
CopyFileResult cfr = copy_file(source_file, target_file, error_message, false);
|
CopyFileResult cfr = copy_file(source_file, target_file, error_message, false);
|
||||||
if (cfr != CopyFileResult::SUCCESS) {
|
if (cfr != CopyFileResult::SUCCESS) {
|
||||||
BOOST_LOG_TRIVIAL(error) << "Copying failed(" << cfr << "): " << error_message;
|
BOOST_LOG_TRIVIAL(error) << "Copying failed(" << cfr << "): " << error_message;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "PresetUpdater.hpp"
|
#include "PresetUpdater.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <functional>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
@ -80,6 +81,8 @@ struct Update
|
||||||
//BBS: use changelog string instead of url
|
//BBS: use changelog string instead of url
|
||||||
std::string change_log;
|
std::string change_log;
|
||||||
std::string descriptions;
|
std::string descriptions;
|
||||||
|
// Orca: add file filter support
|
||||||
|
std::function<bool(const std::string)> file_filter;
|
||||||
|
|
||||||
bool forced_update;
|
bool forced_update;
|
||||||
//BBS: add directory support
|
//BBS: add directory support
|
||||||
|
@ -99,11 +102,23 @@ struct Update
|
||||||
, is_directory(is_dir)
|
, is_directory(is_dir)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
Update(fs::path &&source, fs::path &&target, const Version &version, std::string vendor, std::string changelog, std::string description, std::function<bool(const std::string)> file_filter, bool forced = false, bool is_dir = false)
|
||||||
|
: source(std::move(source))
|
||||||
|
, target(std::move(target))
|
||||||
|
, version(version)
|
||||||
|
, vendor(std::move(vendor))
|
||||||
|
, change_log(std::move(changelog))
|
||||||
|
, descriptions(std::move(description))
|
||||||
|
, file_filter(file_filter)
|
||||||
|
, forced_update(forced)
|
||||||
|
, is_directory(is_dir)
|
||||||
|
{}
|
||||||
|
|
||||||
//BBS: add directory support
|
//BBS: add directory support
|
||||||
void install() const
|
void install() const
|
||||||
{
|
{
|
||||||
if (is_directory) {
|
if (is_directory) {
|
||||||
copy_directory_recursively(source, target);
|
copy_directory_recursively(source, target, file_filter);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
copy_file_fix(source, target);
|
copy_file_fix(source, target);
|
||||||
|
@ -1066,7 +1081,11 @@ bool PresetUpdater::priv::install_bundles_rsrc(std::vector<std::string> bundles,
|
||||||
if (fs::exists(print_folder))
|
if (fs::exists(print_folder))
|
||||||
fs::remove_all(print_folder);
|
fs::remove_all(print_folder);
|
||||||
fs::create_directories(print_folder);
|
fs::create_directories(print_folder);
|
||||||
updates.updates.emplace_back(std::move(print_in_rsrc), std::move(print_in_vendors), Version(), bundle, "", "", false, true);
|
updates.updates.emplace_back(std::move(print_in_rsrc), std::move(print_in_vendors), Version(), bundle, "", "",[](const std::string name){
|
||||||
|
// return false if name is end with .stl, case insensitive
|
||||||
|
return boost::iends_with(name, ".stl") || boost::iends_with(name, ".png") || boost::iends_with(name, ".svg") ||
|
||||||
|
boost::iends_with(name, ".jpeg") || boost::iends_with(name, ".jpg") || boost::iends_with(name, ".3mf");
|
||||||
|
}, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return perform_updates(std::move(updates), snapshot);
|
return perform_updates(std::move(updates), snapshot);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue