OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::anonymous_namespace{Downloader.cpp} Namespace Reference

Functions

void open_folder (const std::string &path)
std::string filename_from_url (const std::string &url)

Function Documentation

◆ filename_from_url()

std::string Slic3r::GUI::anonymous_namespace{Downloader.cpp}::filename_from_url ( const std::string & url)
80{
81 // TODO: can it be done with curl?
82 size_t slash = url.find_last_of("/");
83 if (slash == std::string::npos && slash != url.size() - 1)
84 return {};
85 return url.substr(slash + 1, url.size() - slash + 1);
86}

References filename_from_url().

Referenced by filename_from_url().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ open_folder()

void Slic3r::GUI::anonymous_namespace{Downloader.cpp}::open_folder ( const std::string & path)
32{
33 // Code taken from NotificationManager.cpp
34
35 // Execute command to open a file explorer, platform dependent.
36#ifdef _WIN32
37 const wxString widepath = from_u8(path);
38 const wchar_t* argv[] = { L"explorer", widepath.GetData(), nullptr };
39 ::wxExecute(argv, wxEXEC_ASYNC, nullptr);
40#elif __APPLE__
41 const char* argv[] = { "open", path.data(), nullptr };
42 ::wxExecute(argv, wxEXEC_ASYNC, nullptr);
43#else
44 const char* argv[] = { "xdg-open", path.data(), nullptr };
45
46 // Check if we're running in an AppImage container, if so, we need to remove AppImage's env vars,
47 // because they may mess up the environment expected by the file manager.
48 // Mostly this is about LD_LIBRARY_PATH, but we remove a few more too for good measure.
49 if (wxGetEnv("APPIMAGE", nullptr)) {
50 // We're running from AppImage
51 wxEnvVariableHashMap env_vars;
52 wxGetEnvMap(&env_vars);
53
54 env_vars.erase("APPIMAGE");
55 env_vars.erase("APPDIR");
56 env_vars.erase("LD_LIBRARY_PATH");
57 env_vars.erase("LD_PRELOAD");
58 env_vars.erase("UNION_PRELOAD");
59
60 wxExecuteEnv exec_env;
61 exec_env.env = std::move(env_vars);
62
63 wxString owd;
64 if (wxGetEnv("OWD", &owd)) {
65 // This is the original work directory from which the AppImage image was run,
66 // set it as CWD for the child process:
67 exec_env.cwd = std::move(owd);
68 }
69
70 ::wxExecute(argv, wxEXEC_ASYNC, nullptr, &exec_env);
71 }
72 else {
73 // Looks like we're NOT running from AppImage, we'll make no changes to the environment.
74 ::wxExecute(argv, wxEXEC_ASYNC, nullptr, nullptr);
75 }
76#endif
77}
#define L(s)
Definition ExtrusionEntity.cpp:25
wxString from_u8(const std::string &str)
Definition GUI.cpp:544

References Slic3r::GUI::from_u8(), L, and open_folder().

Referenced by open_folder().

Here is the call graph for this function:
Here is the caller graph for this function: