|
41 | 41 | #include "runtime/executor/executor_settings_base.h" |
42 | 42 | #include "runtime/executor/llm_executor_settings.h" |
43 | 43 | #include "runtime/proto/sampler_params.pb.h" |
| 44 | +#include "runtime/util/file_util.h" |
44 | 45 | #include "runtime/util/logging.h" |
45 | 46 | #include "schema/capabilities/capabilities_c.h" |
46 | 47 | #include "tflite/logger.h" // from @litert |
@@ -69,6 +70,7 @@ using litert::lm::ConversationConfig; |
69 | 70 | using litert::lm::Engine; |
70 | 71 | using litert::lm::EngineFactory; |
71 | 72 | using litert::lm::EngineSettings; |
| 73 | +using litert::lm::FileExists; |
72 | 74 | using litert::lm::InputAudio; |
73 | 75 | using litert::lm::InputData; |
74 | 76 | using litert::lm::InputImage; |
@@ -352,9 +354,7 @@ LITERTLM_JNIEXPORT jlong JNICALL JNI_METHOD(nativeCreateEngine)( |
352 | 354 | std::string model_path_str(model_path_chars); |
353 | 355 | env->ReleaseStringUTFChars(model_path, model_path_chars); |
354 | 356 |
|
355 | | - // Check if the file exists. |
356 | | - struct stat buffer; |
357 | | - if (stat(model_path_str.c_str(), &buffer) != 0) { |
| 357 | + if (!FileExists(model_path_str)) { |
358 | 358 | ThrowLiteRtLmJniException(env, "Model file not found: " + model_path_str); |
359 | 359 | return 0; |
360 | 360 | } |
@@ -527,9 +527,7 @@ LITERTLM_JNIEXPORT jlong JNICALL JNI_METHOD(nativeCreateBenchmark)( |
527 | 527 | std::string model_path_str(model_path_chars); |
528 | 528 | env->ReleaseStringUTFChars(model_path, model_path_chars); |
529 | 529 |
|
530 | | - // Check if the file exists. |
531 | | - struct stat buffer; |
532 | | - if (stat(model_path_str.c_str(), &buffer) != 0) { |
| 530 | + if (!FileExists(model_path_str)) { |
533 | 531 | ThrowLiteRtLmJniException(env, "Model file not found: " + model_path_str); |
534 | 532 | return 0; |
535 | 533 | } |
|
0 commit comments