check if last path is on rem drive
This commit is contained in:
parent
fdf159af42
commit
97a9f245f9
@ -21,7 +21,6 @@
|
||||
|
||||
#include <wx/string.h>
|
||||
#include "I18N.hpp"
|
||||
#include "RemovableDriveManager.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
@ -358,10 +357,7 @@ void AppConfig::update_skein_dir(const std::string &dir)
|
||||
|
||||
std::string AppConfig::get_last_output_dir(const std::string &alt) const
|
||||
{
|
||||
if (GUI::RemovableDriveManager::getInstance().update())
|
||||
{
|
||||
return GUI::RemovableDriveManager::getInstance().get_last_drive_path();
|
||||
}
|
||||
|
||||
const auto it = m_storage.find("");
|
||||
if (it != m_storage.end()) {
|
||||
const auto it2 = it->second.find("last_output_path");
|
||||
|
@ -77,6 +77,7 @@
|
||||
#include "../Utils/FixModelByWin10.hpp"
|
||||
#include "../Utils/UndoRedo.hpp"
|
||||
#include "../Utils/Thread.hpp"
|
||||
#include "RemovableDriveManager.hpp"
|
||||
|
||||
#include <wx/glcanvas.h> // Needs to be last because reasons :-/
|
||||
#include "WipeTowerDialog.hpp"
|
||||
@ -4549,7 +4550,13 @@ void Plater::export_gcode()
|
||||
}
|
||||
default_output_file = fs::path(Slic3r::fold_utf8_to_ascii(default_output_file.string()));
|
||||
auto start_dir = wxGetApp().app_config->get_last_output_dir(default_output_file.parent_path().string());
|
||||
|
||||
if (GUI::RemovableDriveManager::getInstance().update())
|
||||
{
|
||||
if (!RemovableDriveManager::getInstance().is_path_on_removable_drive(start_dir))
|
||||
{
|
||||
start_dir = RemovableDriveManager::getInstance().get_last_drive_path();
|
||||
}
|
||||
}
|
||||
wxFileDialog dlg(this, (printer_technology() == ptFFF) ? _(L("Save G-code file as:")) : _(L("Save SL1 file as:")),
|
||||
start_dir,
|
||||
from_path(default_output_file.filename()),
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <winioctl.h>
|
||||
#include <shlwapi.h>
|
||||
DEFINE_GUID(GUID_DEVINTERFACE_USB_DEVICE,
|
||||
0xA5DCBF10L, 0x6530, 0x11D2, 0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED);
|
||||
#else
|
||||
@ -208,7 +209,11 @@ std::string RemovableDriveManager::get_last_drive_path()
|
||||
{
|
||||
if (!m_current_drives.empty())
|
||||
{
|
||||
#if _WIN32
|
||||
return m_current_drives.back().path + "\\";
|
||||
#else
|
||||
return m_current_drives.back().path;
|
||||
#endif
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@ -216,4 +221,27 @@ std::vector<DriveData> 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;
|
||||
}
|
||||
#endif
|
||||
}}//namespace Slicer::Gui::
|
@ -29,6 +29,7 @@ public:
|
||||
static void eject_drive(const std::string &path);
|
||||
static std::string get_last_drive_path();
|
||||
static std::vector<DriveData> get_all_drives();
|
||||
static bool is_path_on_removable_drive(const std::string &path);
|
||||
private:
|
||||
RemovableDriveManager(){}
|
||||
static void search_for_drives();
|
||||
|
Loading…
Reference in New Issue
Block a user