mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
Merge pull request #56 from Tridify/obj_mtl_fix
Fix temp name usage of .mtl file
This commit is contained in:
@@ -378,12 +378,13 @@ int main(int argc, char** argv) {
|
||||
|
||||
GeometrySerializer* serializer;
|
||||
if (output_extension == ".obj") {
|
||||
const std::string mtl_temp_filename = change_extension(output_filename, "mtl") + TEMP_FILE_EXTENSION;
|
||||
// Do not use temp file for MTL as it's such a small file.
|
||||
const std::string mtl_filename = change_extension(output_filename, "mtl");
|
||||
if (!use_world_coords) {
|
||||
Logger::Message(Logger::LOG_NOTICE, "Using world coords when writing WaveFront OBJ files");
|
||||
settings.set(IfcGeom::IteratorSettings::USE_WORLD_COORDS, true);
|
||||
}
|
||||
serializer = new WaveFrontOBJSerializer(output_temp_filename, mtl_temp_filename, settings);
|
||||
serializer = new WaveFrontOBJSerializer(output_temp_filename, mtl_filename, settings);
|
||||
#ifdef WITH_OPENCOLLADA
|
||||
} else if (output_extension == ".dae") {
|
||||
serializer = new ColladaSerializer(output_temp_filename, settings);
|
||||
@@ -514,12 +515,11 @@ int main(int argc, char** argv) {
|
||||
|
||||
delete serializer;
|
||||
|
||||
rename_file(output_temp_filename, output_filename);
|
||||
|
||||
if (output_extension == ".obj") {
|
||||
std::string mtl_filename = change_extension(output_filename, "mtl");
|
||||
std::string mtl_tmp_filename = mtl_filename + TEMP_FILE_EXTENSION;
|
||||
rename_file(mtl_tmp_filename, mtl_filename);
|
||||
// Renaming might fail (e.g. maybe the existing file was open in a viewer application)
|
||||
// Do not remove the temp file as user can salvage the conversion result from it.
|
||||
bool successful = rename_file(output_temp_filename, output_filename);
|
||||
if (!successful) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Unable to write output file '" + output_filename + "");
|
||||
}
|
||||
|
||||
write_log();
|
||||
@@ -531,7 +531,7 @@ int main(int argc, char** argv) {
|
||||
else
|
||||
printf("\nConversion took %d minute(s) %d seconds\n", seconds/60, seconds%60); // TODO Logger::Message(Logger::LOG_NOTICE, ...);
|
||||
|
||||
return 0;
|
||||
return successful ? 0 : 1;
|
||||
}
|
||||
|
||||
void write_log() {
|
||||
|
||||
Reference in New Issue
Block a user