diff options
author | bubnikv <bubnikv@gmail.com> | 2018-05-21 23:10:38 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2018-05-21 23:10:38 +0300 |
commit | 6b4fe7975f0dbd32d45fbb7a6708fc39fbd92996 (patch) | |
tree | 8f7ebff70316e2cc300357e6a0a82e17d41a6eab /xs/src/slic3r/GUI/GUI.cpp | |
parent | 7b4aeef40cee995e7db49e4a882a13bc1c65d5d3 (diff) |
Fix of the previous commit: When asking the operating system to open
the datadir using the platform specific file explorer, enquote
and escape the path.
Diffstat (limited to 'xs/src/slic3r/GUI/GUI.cpp')
-rw-r--r-- | xs/src/slic3r/GUI/GUI.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 99b63e1f9..afb0cf614 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -5,8 +5,7 @@ #include <cmath> #include <boost/lexical_cast.hpp> -#include <boost/algorithm/string/split.hpp> -#include <boost/algorithm/string/classification.hpp> +#include <boost/algorithm/string.hpp> #include <boost/format.hpp> #if __APPLE__ @@ -931,6 +930,7 @@ void about() void desktop_open_datadir_folder() { + // Execute command to open a file explorer, platform dependent. std::string cmd = #ifdef _WIN32 "explorer " @@ -940,7 +940,21 @@ void desktop_open_datadir_folder() "xdg-open " #endif ; - cmd += data_dir(); + // Escape the path, platform dependent. + std::string path = data_dir(); +#ifdef _WIN32 + // Enclose the path into double quotes on Windows. A quote character is forbidden in file names, + // therefore it does not need to be escaped. + cmd += '"'; + cmd += path; + cmd += '"'; +#else + // Enclose the path into single quotes on Unix / OSX. All single quote characters need to be escaped + // inside a file name. + cmd += '\''; + boost::replace_all(path, "'", "\\'"); + cmd += '\''; +#endif ::wxExecute(wxString::FromUTF8(cmd.c_str()), wxEXEC_ASYNC, nullptr); } |