mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-09 10:16:50 +00:00
ENH:limit file size and collapse long text
Jira: STUDIO-5007 Change-Id: I8b36812c825ff41ade076e6375ed29f357dec814
This commit is contained in:
20
src/slic3r/Utils/FileHelp.cpp
Normal file
20
src/slic3r/Utils/FileHelp.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include "FileHelp.hpp"
|
||||
#include <boost/filesystem.hpp>
|
||||
namespace Slic3r {
|
||||
namespace Utils {
|
||||
|
||||
bool is_file_too_large(std::string file_path, bool &try_ok)
|
||||
{
|
||||
try {
|
||||
uintmax_t fileSizeBytes = boost::filesystem::file_size(file_path);
|
||||
double fileSizeMB = static_cast<double>(fileSizeBytes) / 1024 / 1024;
|
||||
try_ok = true;
|
||||
if (fileSizeMB > STL_SVG_MAX_FILE_SIZE_MB) { return true; }
|
||||
} catch (boost::filesystem::filesystem_error &e) {
|
||||
try_ok = false;
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " error message: " << e.what();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}} // namespace Slic3r::Utils
|
||||
13
src/slic3r/Utils/FileHelp.hpp
Normal file
13
src/slic3r/Utils/FileHelp.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef file_help_hpp_
|
||||
#define file_help_hpp_
|
||||
#include <string>
|
||||
|
||||
#define STL_SVG_MAX_FILE_SIZE_MB 3
|
||||
namespace Slic3r {
|
||||
namespace Utils {
|
||||
|
||||
bool is_file_too_large(std::string file_path, bool &try_ok);
|
||||
|
||||
}
|
||||
}
|
||||
#endif // file_help_hpp_
|
||||
Reference in New Issue
Block a user