gmio_stl: add gmio_stl_get_format_file()

This commit is contained in:
Hugues Delorme 2015-07-10 09:54:22 +02:00
parent 9fe35b1fc0
commit 2857f5ca30
2 changed files with 24 additions and 0 deletions

View File

@ -86,3 +86,16 @@ gmio_stl_format_t gmio_stl_get_format(gmio_stream_t *stream)
/* Fallback case */
return GMIO_STL_FORMAT_UNKNOWN;
}
gmio_stl_format_t gmio_stl_get_format_file(const char* filepath)
{
gmio_stl_format_t format = GMIO_STL_FORMAT_UNKNOWN;
FILE* file = fopen(filepath, "rb");
if (file != NULL) {
gmio_stream_t stream = gmio_stream_stdio(file);
format = gmio_stl_get_format(&stream);
fclose(file);
}
return format;
}

View File

@ -46,6 +46,17 @@ GMIO_C_LINKAGE_BEGIN
GMIO_LIBSTL_EXPORT
gmio_stl_format_t gmio_stl_get_format(gmio_stream_t* stream);
/*! Returns the format of the STL data in file at location \p filepath
*
* This function is a wrapper around gmio_stl_get_format()
*
* \param filepath Path to the STL file. A stream is opened with fopen() so
* the string shall follow the file name specifications of the running
* environment
*/
GMIO_LIBSTL_EXPORT
gmio_stl_format_t gmio_stl_get_format_file(const char* filepath);
GMIO_C_LINKAGE_END
#endif /* GMIO_STL_FORMAT_H */