| 38 | InternalData(const ConverterPtr& _converter) : converter(_converter) {} |
| 39 | |
| 40 | static InternalData* NewInternalData(const std::string& configFileName, |
| 41 | const std::vector<std::string>& paths, |
| 42 | const char* argv0, |
| 43 | const ConfigLoadOptions& options) { |
| 44 | try { |
| 45 | Config config; |
| 46 | #ifdef BAZEL |
| 47 | std::string err; |
| 48 | std::unique_ptr<Runfiles> bazel_runfiles( |
| 49 | Runfiles::Create(argv0 != nullptr ? argv0 : "", &err)); |
| 50 | if (bazel_runfiles != nullptr) { |
| 51 | std::vector<std::string> paths_with_runfiles = paths; |
| 52 | paths_with_runfiles.push_back( |
| 53 | bazel_runfiles->Rlocation("opencc~/data/config")); |
| 54 | paths_with_runfiles.push_back( |
| 55 | bazel_runfiles->Rlocation("opencc~/data/dictionary")); |
| 56 | paths_with_runfiles.push_back( |
| 57 | bazel_runfiles->Rlocation("_main/data/config")); |
| 58 | paths_with_runfiles.push_back( |
| 59 | bazel_runfiles->Rlocation("_main/data/dictionary")); |
| 60 | return new InternalData( |
| 61 | config.NewFromFile(configFileName, paths_with_runfiles, argv0, |
| 62 | options)); |
| 63 | } |
| 64 | #endif |
| 65 | return new InternalData( |
| 66 | config.NewFromFile(configFileName, paths, argv0, options)); |
| 67 | } catch (Exception& ex) { |
| 68 | throw std::runtime_error(ex.what()); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | static InternalData* NewInternalData( |
| 73 | const std::string& configFileName, |
nothing calls this directly
no test coverage detected