OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::search_for_drives_internal Namespace Reference

Functions

static bool compare_filesystem_id (const std::string &path_a, const std::string &path_b)
void inspect_file (const std::string &path, const std::string &parent_path, std::vector< DriveData > &out)
static void search_path (const std::string &path, const std::string &parent_path, std::vector< DriveData > &out)

Function Documentation

◆ compare_filesystem_id()

bool Slic3r::GUI::search_for_drives_internal::compare_filesystem_id ( const std::string & path_a,
const std::string & path_b )
static
189 {
190 struct stat buf;
191 stat(path_a.c_str() ,&buf);
192 dev_t id_a = buf.st_dev;
193 stat(path_b.c_str() ,&buf);
194 dev_t id_b = buf.st_dev;
195 return id_a == id_b;
196 }

Referenced by Slic3r::GUI::RemovableDriveManager::get_removable_drive_from_path(), Slic3r::GUI::RemovableDriveManager::get_removable_drive_path(), and inspect_file().

Here is the caller graph for this function:

◆ inspect_file()

void Slic3r::GUI::search_for_drives_internal::inspect_file ( const std::string & path,
const std::string & parent_path,
std::vector< DriveData > & out )
199 {
200 //confirms if the file is removable drive and adds it to vector
201
202 if (
203#ifdef __linux__
204 // Chromium mounts removable drives in a way that produces the same device ID.
206#endif
207 // If not same file system - could be removable drive.
208 ! compare_filesystem_id(path, parent_path)) {
209 //free space
210 boost::system::error_code ec;
211 boost::filesystem::space_info si = boost::filesystem::space(path, ec);
212 if (!ec && si.available != 0) {
213 //user id
214 struct stat buf;
215 stat(path.c_str(), &buf);
216 uid_t uid = buf.st_uid;
217 if (getuid() == uid)
218 out.emplace_back(DriveData{ boost::filesystem::path(path).stem().string(), path });
219 }
220 }
221 }
static bool compare_filesystem_id(const std::string &path_a, const std::string &path_b)
Definition RemovableDriveManager.cpp:188
@ LinuxOnChromium
Definition Platform.hpp:24
PlatformFlavor platform_flavor()
Definition Platform.cpp:108
Definition RemovableDriveManager.hpp:21

References compare_filesystem_id(), Slic3r::LinuxOnChromium, and Slic3r::platform_flavor().

Referenced by search_path().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ search_path()

void Slic3r::GUI::search_for_drives_internal::search_path ( const std::string & path,
const std::string & parent_path,
std::vector< DriveData > & out )
static
225 {
226 glob_t globbuf;
227 globbuf.gl_offs = 2;
228 int error = glob(path.c_str(), GLOB_TILDE, NULL, &globbuf);
229 if (error == 0) {
230 for (size_t i = 0; i < globbuf.gl_pathc; ++ i)
231 inspect_file(globbuf.gl_pathv[i], parent_path, out);
232 } else {
233 //if error - path probably doesnt exists so function just exits
234 //std::cout<<"glob error "<< error<< "\n";
235 }
236 globfree(&globbuf);
237 }
void inspect_file(const std::string &path, const std::string &parent_path, std::vector< DriveData > &out)
Definition RemovableDriveManager.cpp:198

References inspect_file().

Referenced by Slic3r::GUI::RemovableDriveManager::search_for_removable_drives().

Here is the call graph for this function:
Here is the caller graph for this function: