26 lines
525 B
C++
26 lines
525 B
C++
// sherpa-onnx/csrc/file-utils.cc
|
|
//
|
|
// Copyright (c) 2022-2023 Xiaomi Corporation
|
|
|
|
#include "sherpa-onnx/csrc/file-utils.h"
|
|
|
|
#include <fstream>
|
|
#include <string>
|
|
|
|
#include "sherpa-onnx/csrc/macros.h"
|
|
|
|
namespace sherpa_onnx {
|
|
|
|
bool FileExists(const std::string &filename) {
|
|
return std::ifstream(filename).good();
|
|
}
|
|
|
|
void AssertFileExists(const std::string &filename) {
|
|
if (!FileExists(filename)) {
|
|
SHERPA_ONNX_LOGE("filename '%s' does not exist", filename.c_str());
|
|
exit(-1);
|
|
}
|
|
}
|
|
|
|
} // namespace sherpa_onnx
|