diff --git a/src/slic3r/GUI/RemovableDriveManager.cpp b/src/slic3r/GUI/RemovableDriveManager.cpp index 776334bf2..2d1f4ba6f 100644 --- a/src/slic3r/GUI/RemovableDriveManager.cpp +++ b/src/slic3r/GUI/RemovableDriveManager.cpp @@ -29,46 +29,43 @@ void RemovableDriveManager::search_for_drives() { m_current_drives.clear(); m_current_drives.reserve(26); - DWORD drivesMask = GetLogicalDrives(); + DWORD drives_mask = GetLogicalDrives(); for (size_t i = 0; i < 26; i++) { - if(drivesMask & (1 << i)) + if(drives_mask & (1 << i)) { std::string path (1,(char)('A' + i)); path+=":"; - UINT driveType = GetDriveTypeA(path.c_str()); + UINT drive_type = GetDriveTypeA(path.c_str()); //std::cout << "found drive" << (char)('A' + i) << ": type:" < 0) + if (free_space.QuadPart > 0) { - m_current_drives.push_back(DriveData(boost::nowide::narrow(volumeName), path)); + m_current_drives.push_back(DriveData(boost::nowide::narrow(volume_name), path)); } } } } - else if(driveType == 3)//disks and usb drives - { - } } } @@ -93,10 +90,10 @@ void RemovableDriveManager::eject_drive(const std::string &path) DWORD deviceControlRetVal(0); BOOL error = DeviceIoControl(handle, IOCTL_STORAGE_EJECT_MEDIA, nullptr, 0, nullptr, 0, &deviceControlRetVal, nullptr); CloseHandle(handle); - if (error != 0) - std::cout << "Ejected " << mpath << "\n"; - else + if (error == 0) + { std::cerr << "Ejecting " << mpath << " failed " << deviceControlRetVal << " " << GetLastError() << " \n"; + } m_current_drives.erase(it); @@ -104,6 +101,19 @@ void RemovableDriveManager::eject_drive(const std::string &path) } } } +bool RemovableDriveManager::is_path_on_removable_drive(const std::string &path) +{ + if (m_current_drives.empty()) + return false; + int letter = PathGetDriveNumberA(path.c_str()); + for (auto it = m_current_drives.begin(); it != m_current_drives.end(); ++it) + { + char drive = (*it).path[0]; + if (drive == ('A' + letter)) + return true; + } + return false; +} #else void RemovableDriveManager::search_for_drives() { @@ -112,11 +122,11 @@ void RemovableDriveManager::search_for_drives() std::string pp(path); m_current_drives.clear(); - m_current_Drives.reserve(26); + m_current_drives.reserve(26); //search /media/* folder stat("/media/",&buf); - std::cout << "/media ID: " < RemovableDriveManager::get_all_drives() return m_current_drives; } #if _WIN32 -bool RemovableDriveManager::is_path_on_removable_drive(const std::string& path) -{ - if (m_current_drives.empty()) - return false; - int letter = PathGetDriveNumberA(path.c_str()); - for (auto it = m_current_drives.begin(); it != m_current_drives.end(); ++it) - { - char drive = (*it).path[0]; - if (drive == ('A' + letter)) - return true; - } - return false; -} -#else -bool RemovableDriveManager::is_path_on_removable_drive(const std::string& path, const std::string& drive) -{ - if (m_current_drives.empty()) - return false; - return false; -} +#else + #endif }}//namespace Slicer::Gui:: \ No newline at end of file