diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index 6dcbc60b7..bb196d3fd 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -109,6 +109,8 @@ set(SLIC3R_GUI_SOURCES GUI/WipeTowerDialog.hpp GUI/RammingChart.cpp GUI/RammingChart.hpp + GUI/RemovableDriveManager.cpp + GUI/RemovableDriveManager.hpp GUI/BonjourDialog.cpp GUI/BonjourDialog.hpp GUI/ButtonsDescription.cpp diff --git a/src/slic3r/GUI/RemovableDriveManager.cpp b/src/slic3r/GUI/RemovableDriveManager.cpp index 44d4181d1..ae718b7d3 100644 --- a/src/slic3r/GUI/RemovableDriveManager.cpp +++ b/src/slic3r/GUI/RemovableDriveManager.cpp @@ -1,26 +1,34 @@ #include "RemovableDriveManager.hpp" -#include -#include + + #include #include -//#include -//#include "libslic3r/Utils.hpp" +#if _WIN32 +#include +#include DEFINE_GUID(GUID_DEVINTERFACE_USB_DEVICE, 0xA5DCBF10L, 0x6530, 0x11D2, 0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED); +#else +//linux includes +#include +#include +#include +#include +#include +#endif namespace Slic3r { namespace GUI { std::vector RemovableDriveManager::currentDrives; -bool RemovableDriveManager::update() -{ - searchForDrives(currentDrives); - return !currentDrives.empty(); -} + + + +#if _WIN32 void RemovableDriveManager::searchForDrives(std::vector& newDrives) { newDrives.clear(); @@ -69,37 +77,6 @@ void RemovableDriveManager::searchForDrives(std::vector& newDrives) } } - -void RemovableDriveManager::updateCurrentDrives(const std::vector& newDrives) -{ - currentDrives.clear(); - currentDrives.reserve(26); - for (auto it = newDrives.begin(); it != newDrives.end(); ++it) - { - currentDrives.push_back(*it); - } -} -void RemovableDriveManager::printDrivesToLog() -{ - //std::cout<<"current drives:"<< currentDrives.size() <<"\n"; - for (auto it = currentDrives.begin(); it != currentDrives.end(); ++it) - { - //BOOST_LOG_TRIVIAL(trace) << boost::format("found disk %1%:") % ('A' + i); - //std::cout << /*std::string((*it).name.begin(), (*it).name.end()) << "(" << */(*it).path << ":/, "; - } - //std::cout << "\n"; -} -bool RemovableDriveManager::isDriveMounted(std::string path) -{ - for (auto it = currentDrives.begin(); it != currentDrives.end(); ++it) - { - if ((*it).path == path) - { - return true; - } - } - return false; -} void RemovableDriveManager::ejectDrive(std::string path) { if (!update() || !isDriveMounted(path)) @@ -129,6 +106,115 @@ void RemovableDriveManager::ejectDrive(std::string path) } } } +#else +void RemovableDriveManager::searchForDrives(std::vector& newDrives) +{ + struct stat buf; + std::string path(std::getenv("USER")); + std::string pp(path); + + newDrives.clear(); + newDrives.reserve(26); + + //search /media/* folder + stat("/media/",&buf); + std::cout << "/media ID: " <& newDrives,const std::string path, const dev_t parentDevID) +{ + glob_t globbuf; + globbuf.gl_offs = 2; + std::cout<<"searching "<& newDrives) +{ + currentDrives.clear(); + currentDrives.reserve(26); + for (auto it = newDrives.begin(); it != newDrives.end(); ++it) + { + currentDrives.push_back(*it); + } +} +bool RemovableDriveManager::isDriveMounted(std::string path) +{ + for (auto it = currentDrives.begin(); it != currentDrives.end(); ++it) + { + if ((*it).path == path) + { + return true; + } + } + return false; +} + std::string RemovableDriveManager::getLastDrivePath() { if (!currentDrives.empty()) diff --git a/src/slic3r/GUI/RemovableDriveManager.hpp b/src/slic3r/GUI/RemovableDriveManager.hpp index cab58fee6..c503fdf18 100644 --- a/src/slic3r/GUI/RemovableDriveManager.hpp +++ b/src/slic3r/GUI/RemovableDriveManager.hpp @@ -8,9 +8,9 @@ namespace Slic3r { namespace GUI { struct DriveData { - std::wstring name; + std::string name; std::string path; - DriveData(std::wstring n, std::string p):name(n),path(p){} + DriveData(std::string n, std::string p):name(n),path(p){} }; class RemovableDriveManager { @@ -32,10 +32,12 @@ public: private: RemovableDriveManager(){} static void searchForDrives(std::vector& newDrives); - static void printDrivesToLog(); static void updateCurrentDrives(const std::vector& newDrives); static std::vector currentDrives; - +#if _WIN32 +#else + static void searchPath(std::vector& newDrives,const std::string path, const dev_t parentDevID); +#endif }; }} #endif \ No newline at end of file