On Windows, system and hidden files are now ignored in all file

enumeration loops.
Should fix "desktop.ini still displaying error" #1761
This commit is contained in:
bubnikv 2019-02-03 15:30:37 +01:00
parent 14a623f50e
commit f9743d17e9
8 changed files with 70 additions and 49 deletions

View file

@ -30,7 +30,13 @@
#include <tbb/task_scheduler_init.h>
#include <tbb/task_scheduler_init.h>
#if defined(__linux) || defined(__GNUC__ )
#include <strings.h>
#endif /* __linux */
#ifdef _MSC_VER
#define strcasecmp _stricmp
#endif
namespace Slic3r {
@ -248,6 +254,30 @@ int copy_file(const std::string &from, const std::string &to)
return 0;
}
// Ignore system and hidden files, which may be created by the DropBox synchronisation process.
// https://github.com/prusa3d/Slic3r/issues/1298
bool is_plain_file(const boost::filesystem::directory_entry &dir_entry)
{
if (! boost::filesystem::is_regular_file(dir_entry.status()))
return false;
#ifdef _MSC_VER
DWORD attributes = GetFileAttributesW(boost::nowide::widen(dir_entry.path().string()).c_str());
return (attributes & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) == 0;
#else
return true;
#endif
}
bool is_ini_file(const boost::filesystem::directory_entry &dir_entry)
{
return is_plain_file(dir_entry) && strcasecmp(dir_entry.path().extension().string().c_str(), ".ini") == 0;
}
bool is_idx_file(const boost::filesystem::directory_entry &dir_entry)
{
return is_plain_file(dir_entry) && strcasecmp(dir_entry.path().extension().string().c_str(), ".idx") == 0;
}
} // namespace Slic3r
#ifdef WIN32