AMF I/O - Fixed error messages

This commit is contained in:
Enrico Turri 2018-02-14 15:52:39 +01:00
parent f5f27859e0
commit dcc667cdc7

View file

@ -576,8 +576,8 @@ bool load_amf_archive(const char *path, PresetBundle* bundle, Model *model)
return false; return false;
} }
std::string internal_aml_filename = boost::ireplace_last_copy(boost::filesystem::path(path).filename().string(), ".zip.amf", ".amf"); std::string internal_amf_filename = boost::ireplace_last_copy(boost::filesystem::path(path).filename().string(), ".zip.amf", ".amf");
if (internal_aml_filename != stat.m_filename) if (internal_amf_filename != stat.m_filename)
{ {
printf("Found invalid internal filename\n"); printf("Found invalid internal filename\n");
mz_zip_reader_end(&archive); mz_zip_reader_end(&archive);
@ -606,7 +606,7 @@ bool load_amf_archive(const char *path, PresetBundle* bundle, Model *model)
void* parser_buffer = XML_GetBuffer(parser, (int)stat.m_uncomp_size); void* parser_buffer = XML_GetBuffer(parser, (int)stat.m_uncomp_size);
if (parser_buffer == nullptr) if (parser_buffer == nullptr)
{ {
printf("Unable to create buffer"); printf("Unable to create buffer\n");
mz_zip_reader_end(&archive); mz_zip_reader_end(&archive);
return false; return false;
} }
@ -614,14 +614,14 @@ bool load_amf_archive(const char *path, PresetBundle* bundle, Model *model)
res = mz_zip_reader_extract_file_to_mem(&archive, stat.m_filename, parser_buffer, (size_t)stat.m_uncomp_size, 0); res = mz_zip_reader_extract_file_to_mem(&archive, stat.m_filename, parser_buffer, (size_t)stat.m_uncomp_size, 0);
if (res == 0) if (res == 0)
{ {
printf("Error while reading model data to buffer"); printf("Error while reading model data to buffer\n");
mz_zip_reader_end(&archive); mz_zip_reader_end(&archive);
return false; return false;
} }
if (!XML_ParseBuffer(parser, (int)stat.m_uncomp_size, 1)) if (!XML_ParseBuffer(parser, (int)stat.m_uncomp_size, 1))
{ {
printf("Error (%s) while parsing xml file at line %d", XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser)); printf("Error (%s) while parsing xml file at line %d\n", XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser));
mz_zip_reader_end(&archive); mz_zip_reader_end(&archive);
return false; return false;
} }
@ -767,10 +767,10 @@ bool store_amf(const char *path, Model *model, Print* print)
} }
stream << "</amf>\n"; stream << "</amf>\n";
std::string internal_aml_filename = boost::ireplace_last_copy(boost::filesystem::path(path).filename().string(), ".zip.amf", ".amf"); std::string internal_amf_filename = boost::ireplace_last_copy(boost::filesystem::path(path).filename().string(), ".zip.amf", ".amf");
std::string out = stream.str(); std::string out = stream.str();
if (!mz_zip_writer_add_mem(&archive, internal_aml_filename.c_str(), (const void*)out.data(), out.length(), MZ_DEFAULT_COMPRESSION)) if (!mz_zip_writer_add_mem(&archive, internal_amf_filename.c_str(), (const void*)out.data(), out.length(), MZ_DEFAULT_COMPRESSION))
{ {
mz_zip_writer_end(&archive); mz_zip_writer_end(&archive);
boost::filesystem::remove(path); boost::filesystem::remove(path);