[C-Api] remove space of models accepted/tizen/unified/20240125.160250 accepted/tizen/unified/20240126.061440 accepted/tizen/unified/20240126.061457 accepted/tizen/unified/toolchain/20240311.065123 accepted/tizen/unified/x/20240205.064038
authorJaeyun Jung <jy1210.jung@samsung.com>
Mon, 22 Jan 2024 05:14:13 +0000 (14:14 +0900)
committerSangjung Woo <again4you@gmail.com>
Thu, 25 Jan 2024 05:34:41 +0000 (14:34 +0900)
To prevent not-found error, remove space of model path.
Also check file existence when validating model files.

Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
c/src/ml-api-inference-single.c

index 866ccf8..aa1f079 100644 (file)
@@ -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]));