assimp_cmd: fix possible crash in assimp export if the file can be imported, cosmetic fixes.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@935 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
f8add9bb22
commit
d85c16b52f
|
@ -128,7 +128,7 @@ int Assimp_Export(const char* const* params, unsigned int num)
|
|||
|
||||
if (outfi == SIZE_MAX) {
|
||||
// still no match -> failure
|
||||
printf("assimp export: no output format specified and I failed to guess it");
|
||||
printf("assimp export: no output format specified and I failed to guess it\n");
|
||||
return -23;
|
||||
}
|
||||
}
|
||||
|
@ -152,6 +152,9 @@ int Assimp_Export(const char* const* params, unsigned int num)
|
|||
|
||||
// import the model
|
||||
const aiScene* scene = ImportModel(import,in);
|
||||
if (!scene) {
|
||||
return -39;
|
||||
}
|
||||
|
||||
// derive the final file name
|
||||
out += "."+outext;
|
||||
|
@ -160,9 +163,9 @@ int Assimp_Export(const char* const* params, unsigned int num)
|
|||
if(!ExportModel(scene, import, out,e->id)) {
|
||||
return -25;
|
||||
}
|
||||
printf("assimp export: wrote output file: %s",out.c_str());
|
||||
printf("assimp export: wrote output file: %s\n",out.c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // no export
|
||||
|
||||
|
||||
|
|
|
@ -62,14 +62,13 @@ const char* AICMD_MSG_HELP =
|
|||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||
" \texport - Export a file to one of the supported output formats\n"
|
||||
" \tlistexport - List all supported export formats\n"
|
||||
" \tknowexport - Check whether a particular export format is supported\n"
|
||||
" \texportinfo - Show basic information on a specific export format\n"
|
||||
#endif
|
||||
" \textract - Extract embedded texture images\n"
|
||||
" \tdump - Convert models to a binary or textual dump (ASSBIN/ASSXML)\n"
|
||||
" \tcmpdump - Compare dumps created using \'assimp dump <file> -s ...\'\n"
|
||||
" \tversion - Display Assimp version\n"
|
||||
"\n\n Use \'assimp <verb> --help\' for detailed help on a command.\n"
|
||||
"\n Use \'assimp <verb> --help\' for detailed help on a command.\n"
|
||||
;
|
||||
|
||||
/*extern*/ Assimp::Importer* globalImporter = NULL;
|
||||
|
@ -135,7 +134,7 @@ int main (int argc, char* argv[])
|
|||
aiString s;
|
||||
imp.GetExtensionList(s);
|
||||
|
||||
printf("%s",s.data);
|
||||
printf("%s\n",s.data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -153,29 +152,30 @@ int main (int argc, char* argv[])
|
|||
}
|
||||
}
|
||||
|
||||
printf("%s",s.data);
|
||||
printf("%s\n",s.data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// assimp exportinfo
|
||||
// stat an export format
|
||||
if (! strcmp(argv[1], "exportinfo")) {
|
||||
aiString s;
|
||||
|
||||
if (argc<3) {
|
||||
printf("Expected file format id");
|
||||
printf("Expected file format id\n");
|
||||
return -11;
|
||||
}
|
||||
|
||||
for(size_t i = 0, end = exp.GetExportFormatCount(); i < end; ++i) {
|
||||
const aiExportFormatDesc* const e = exp.GetExportFormatDescription(i);
|
||||
if (!strcmp(e->id,argv[2])) {
|
||||
printf("%s\n%s\n%s",e->id,e->fileExtension,e->description);
|
||||
printf("%s\n%s\n%s\n",e->id,e->fileExtension,e->description);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
printf("Unknown file format id: %s",argv[2]);
|
||||
printf("Unknown file format id: \'%s\'\n",argv[2]);
|
||||
return -12;
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,7 @@ int main (int argc, char* argv[])
|
|||
return -10;
|
||||
}
|
||||
const bool b = imp.IsExtensionSupported(argv[2]);
|
||||
printf("File extension %s is %sknown",argv[2],(b?"":"not "));
|
||||
printf("File extension \'%s\' is %sknown\n",argv[2],(b?"":"not "));
|
||||
return b?0:-1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue