free space check linux + mac

This commit is contained in:
David Kocik 2019-12-19 16:27:48 +01:00
parent 7b95ec486f
commit 8d52663871

View file

@ -20,6 +20,7 @@ GUID WceusbshGUID = { 0x25dbce51, 0x6c8f, 0x4a72,
#include <glob.h> #include <glob.h>
#include <libgen.h> #include <libgen.h>
#include <pwd.h> #include <pwd.h>
#include <filesystem>
#endif #endif
namespace Slic3r { namespace Slic3r {
@ -308,6 +309,11 @@ void RemovableDriveManager::inspect_file(const std::string &path, const std::str
//if not same file system - could be removable drive //if not same file system - could be removable drive
if(!compare_filesystem_id(path, parent_path)) if(!compare_filesystem_id(path, parent_path))
{
//free space
std::filesystem::space_info fs_si = std::filesystem::space(path);
//std::cout << "Free space: " << fs_si.free << "Available space: " << fs_si.available << " " << path << '\n';
if(fs_si.free != 0 && fs_si.available != 0)
{ {
//user id //user id
struct stat buf; struct stat buf;
@ -324,6 +330,8 @@ void RemovableDriveManager::inspect_file(const std::string &path, const std::str
} }
} }
} }
}
} }
bool RemovableDriveManager::compare_filesystem_id(const std::string &path_a, const std::string &path_b) bool RemovableDriveManager::compare_filesystem_id(const std::string &path_a, const std::string &path_b)
{ {