ENH:limit file size and collapse long text

Jira: STUDIO-5007
Change-Id: I8b36812c825ff41ade076e6375ed29f357dec814
This commit is contained in:
zhou.xu
2023-10-31 10:34:33 +08:00
committed by Lane.Wei
parent 4a5bca2402
commit 1c416d5781
5 changed files with 88 additions and 9 deletions

View 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

View 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_