From 5a204fd31c73932d3847b5b27999384d147c5ea6 Mon Sep 17 00:00:00 2001 From: Jaeyun Jung Date: Mon, 22 Jan 2024 14:14:13 +0900 Subject: [PATCH] [C-Api] remove space of models To prevent not-found error, remove space of model path. Also check file existence when validating model files. Signed-off-by: Jaeyun Jung --- c/src/ml-api-inference-single.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/c/src/ml-api-inference-single.c b/c/src/ml-api-inference-single.c index 866ccf8..aa1f079 100644 --- a/c/src/ml-api-inference-single.c +++ b/c/src/ml-api-inference-single.c @@ -933,7 +933,7 @@ ml_single_open_custom (ml_single_h * single, ml_single_preset * info) ml_nnfw_hw_e hw; const gchar *fw_name; gchar **list_models; - guint num_models; + guint i, num_models; char *hw_name; check_feature_state (ML_FEATURE_INFERENCE); @@ -957,6 +957,8 @@ ml_single_open_custom (ml_single_h * single, ml_single_preset * info) */ list_models = g_strsplit (info->models, ",", -1); num_models = g_strv_length (list_models); + for (i = 0; i < num_models; i++) + g_strstrip (list_models[i]); status = _ml_validate_model_file ((const char **) list_models, num_models, &nnfw); @@ -1847,7 +1849,8 @@ __ml_validate_model_file (const char *const *model, } for (i = 0; i < num_models; i++) { - if (!model[i] || !g_file_test (model[i], G_FILE_TEST_IS_REGULAR)) { + if (!model[i] || + !g_file_test (model[i], G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) { _ml_error_report_return (ML_ERROR_INVALID_PARAMETER, "The given param, model path [%d] = \"%s\" is invalid or the file is not found or accessible.", i, _STR_NULL (model[i])); -- 2.7.4