diff --git a/src/slic3r/GUI/RemovableDriveManager.cpp b/src/slic3r/GUI/RemovableDriveManager.cpp index 777085165d..4368d06b64 100644 --- a/src/slic3r/GUI/RemovableDriveManager.cpp +++ b/src/slic3r/GUI/RemovableDriveManager.cpp @@ -1,6 +1,5 @@ #include "RemovableDriveManager.hpp" #include -#include #include "boost/nowide/convert.hpp" #if _WIN32 @@ -17,6 +16,7 @@ DEFINE_GUID(GUID_DEVINTERFACE_USB_DEVICE, #include #include #include +#include #endif namespace Slic3r { @@ -96,8 +96,6 @@ void RemovableDriveManager::eject_drive(const std::string &path) { std::cerr << "Ejecting " << mpath << " failed " << deviceControlRetVal << " " << GetLastError() << " \n"; } - - m_current_drives.erase(it); break; } @@ -138,65 +136,85 @@ void RemovableDriveManager::register_window() #else void RemovableDriveManager::search_for_drives() { - struct stat buf; - std::string path(std::getenv("USER")); - std::string pp(path); - + m_current_drives.clear(); m_current_drives.reserve(26); //search /media/* folder - stat("/media/",&buf); - //std::cout << "/media ID: " <pw_name; + pp = path; + //search /media/USERNAME/* folder + pp = "/media/"+pp; + path = "/media/" + path + "/*"; + search_path(path, pp); - stat(pp.c_str() ,&buf); - //std::cout << pp <<" ID: " < RemovableDriveManager::get_all_drives() } void RemovableDriveManager::check_and_notify() { - static int number_of_drives = 0; + static size_t number_of_drives = 0; if(number_of_drives != m_current_drives.size()) { for (auto it = m_callbacks.begin(); it != m_callbacks.end(); ++it) diff --git a/src/slic3r/GUI/RemovableDriveManager.hpp b/src/slic3r/GUI/RemovableDriveManager.hpp index f3abc42073..43e47a0867 100644 --- a/src/slic3r/GUI/RemovableDriveManager.hpp +++ b/src/slic3r/GUI/RemovableDriveManager.hpp @@ -41,7 +41,8 @@ private: #if _WIN32 void register_window(); #else - void search_path(const std::string &path, const dev_t &parentDevID); + void search_path(const std::string &path, const std::string &parent_path); + bool compare_filesystem_id(const std::string &path_a, const std::string &path_b); #endif }; }}