diff options
Diffstat (limited to 'src/libslic3r/utils.cpp')
-rw-r--r-- | src/libslic3r/utils.cpp | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/libslic3r/utils.cpp b/src/libslic3r/utils.cpp index ad91e5239..0c26d42c8 100644 --- a/src/libslic3r/utils.cpp +++ b/src/libslic3r/utils.cpp @@ -39,9 +39,9 @@ #include <tbb/task_scheduler_init.h> -#if defined(__linux) || defined(__GNUC__ ) +#if defined(__linux__) || defined(__GNUC__ ) #include <strings.h> -#endif /* __linux */ +#endif /* __linux__ */ #ifdef _MSC_VER #define strcasecmp _stricmp @@ -417,7 +417,7 @@ std::error_code rename_file(const std::string &from, const std::string &to) #endif } -CopyFileResult copy_file_inner(const std::string& from, const std::string& to) +CopyFileResult copy_file_inner(const std::string& from, const std::string& to, std::string& error_message) { const boost::filesystem::path source(from); const boost::filesystem::path target(to); @@ -431,18 +431,25 @@ CopyFileResult copy_file_inner(const std::string& from, const std::string& to) // or when the target file doesn't exist. boost::system::error_code ec; boost::filesystem::permissions(target, perms, ec); + if (ec) + BOOST_LOG_TRIVIAL(debug) << "boost::filesystem::permisions before copy error message (this could be irrelevant message based on file system): " << ec.message(); + ec.clear(); boost::filesystem::copy_file(source, target, boost::filesystem::copy_option::overwrite_if_exists, ec); if (ec) { + error_message = ec.message(); return FAIL_COPY_FILE; } + ec.clear(); boost::filesystem::permissions(target, perms, ec); + if (ec) + BOOST_LOG_TRIVIAL(debug) << "boost::filesystem::permisions after copy error message (this could be irrelevant message based on file system): " << ec.message(); return SUCCESS; } -CopyFileResult copy_file(const std::string &from, const std::string &to, const bool with_check) +CopyFileResult copy_file(const std::string &from, const std::string &to, std::string& error_message, const bool with_check) { std::string to_temp = to + ".tmp"; - CopyFileResult ret_val = copy_file_inner(from,to_temp); + CopyFileResult ret_val = copy_file_inner(from, to_temp, error_message); if(ret_val == SUCCESS) { if (with_check) @@ -515,6 +522,12 @@ 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; } +bool is_gcode_file(const std::string &path) +{ + return boost::iends_with(path, ".gcode") || boost::iends_with(path, ".gco") || + boost::iends_with(path, ".g") || boost::iends_with(path, ".ngc"); +} + } // namespace Slic3r #ifdef WIN32 @@ -545,6 +558,7 @@ std::string encode_path(const char *src) } // Encode an 8-bit string from a local code page to UTF-8. +// Multibyte to utf8 std::string decode_path(const char *src) { #ifdef WIN32 @@ -604,7 +618,12 @@ std::string string_printf(const char *format, ...) std::string header_slic3r_generated() { - return std::string("generated by " SLIC3R_APP_NAME " " SLIC3R_VERSION " on " ) + Utils::utc_timestamp(); + return std::string("generated by " SLIC3R_APP_NAME " " SLIC3R_VERSION " on " ) + Utils::utc_timestamp(); +} + +std::string header_gcodeviewer_generated() +{ + return std::string("generated by " GCODEVIEWER_APP_NAME " " SLIC3R_VERSION " on ") + Utils::utc_timestamp(); } unsigned get_current_pid() |