MCPcopy Create free account
hub / github.com/BYVoid/OpenCC / ResolveSegmentationResourcePath

Function ResolveSegmentationResourcePath

src/benchmark/Performance.cpp:175–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173}
174
175std::string ResolveSegmentationResourcePath(
176 const std::string& source_config_directory, const std::string& resource_path) {
177 if (IsAbsolutePath(resource_path)) {
178 return resource_path;
179 }
180
181#ifdef OPENCC_BENCHMARK_JIEBA_CONFIG_DIR
182 if (resource_path.find("jieba_dict/") == 0) {
183 const std::string basename =
184 resource_path.substr(std::string("jieba_dict/").size());
185 const std::string plugin_build_path =
186 JoinPath(std::string(OPENCC_BENCHMARK_JIEBA_PLUGIN_DIR), resource_path);
187 if (IsRegularFile(plugin_build_path)) {
188 return plugin_build_path;
189 }
190 const std::string plugin_parent_path =
191 JoinPath(GetParentDirectory(OPENCC_BENCHMARK_JIEBA_PLUGIN_DIR), resource_path);
192 if (IsRegularFile(plugin_parent_path)) {
193 return plugin_parent_path;
194 }
195 const std::string source_jieba_path =
196 std::string(PROJECT_SOURCE_DIR) + "/plugins/jieba/deps/cppjieba/dict/" +
197 basename;
198 if (IsRegularFile(source_jieba_path)) {
199 return source_jieba_path;
200 }
201 }
202#endif
203
204 return JoinPath(source_config_directory, resource_path);
205}
206
207void RewriteDictNode(JSONValue& node, JSONDocument::AllocatorType& allocator,
208 const char* target_type) {

Calls 7

findMethod · 0.80
IsAbsolutePathFunction · 0.70
JoinPathFunction · 0.70
IsRegularFileFunction · 0.70
GetParentDirectoryFunction · 0.70
substrMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected