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

Function FindOcd2DictionaryDir

src/ConfigTest.cpp:191–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189}
190
191std::string FindOcd2DictionaryDir(const std::string& configTestDirPath) {
192 std::vector<fs::path> candidates;
193 if (!PACKAGE_DATA_DIRECTORY.empty()) {
194 candidates.push_back(fs::u8path(PACKAGE_DATA_DIRECTORY));
195 }
196
197 const fs::path configDir = fs::u8path(configTestDirPath);
198 candidates.push_back(configDir.parent_path().parent_path() / "data" /
199 "dictionary");
200 candidates.push_back(fs::current_path() / "data" / "dictionary");
201 candidates.push_back(fs::current_path().parent_path() / "data" / "dictionary");
202
203 for (const fs::path& candidate : candidates) {
204 if (candidate.empty()) {
205 continue;
206 }
207 const fs::path phrases = candidate / "STPhrases.ocd2";
208 const fs::path characters = candidate / "STCharacters.ocd2";
209 if (fs::is_regular_file(phrases) && fs::is_regular_file(characters)) {
210 return PathString(candidate) + "/";
211 }
212 }
213 return "";
214}
215
216} // namespace
217

Callers 1

TEST_FFunction · 0.85

Calls 3

PathStringFunction · 0.85
emptyMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected