From ae926bd1ed5c3c6f07ee9d957201647854cd2850 Mon Sep 17 00:00:00 2001
From: david kocik <kocikdav@gmail.com>
Date: Wed, 2 Dec 2020 12:16:07 +0100
Subject: [PATCH] error_code in boost::filesystem::space to ensure the drive
 exists. Fix of #5354

---
 src/slic3r/GUI/RemovableDriveManager.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/slic3r/GUI/RemovableDriveManager.cpp b/src/slic3r/GUI/RemovableDriveManager.cpp
index 740064b1a..bc733ee9f 100644
--- a/src/slic3r/GUI/RemovableDriveManager.cpp
+++ b/src/slic3r/GUI/RemovableDriveManager.cpp
@@ -20,6 +20,7 @@
 #include <glob.h>
 #include <pwd.h>
 #include <boost/filesystem.hpp>
+#include <boost/system/error_code.hpp>
 #include <boost/filesystem/convenience.hpp>
 #include <boost/process.hpp>
 #endif
@@ -187,8 +188,9 @@ namespace search_for_drives_internal
 		//if not same file system - could be removable drive
 		if (! compare_filesystem_id(path, parent_path)) {
 			//free space
-			boost::filesystem::space_info si = boost::filesystem::space(path);
-			if (si.available != 0) {
+			boost::system::error_code ec;
+			boost::filesystem::space_info si = boost::filesystem::space(path, ec);
+			if (!ec && si.available != 0) {
 				//user id
 				struct stat buf;
 				stat(path.c_str(), &buf);