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

Method Resolve

src/ResourceProvider.cpp:410–439  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

408 : searchPaths(std::move(searchPaths_)) {}
409
410std::string
411FilesystemResourceProvider::Resolve(std::string_view resourceName) const {
412 const std::string resourcePath(resourceName);
413 if (resourcePath.empty()) {
414 throw FileNotFound(resourcePath);
415 }
416
417 if (IsAbsolutePath(resourcePath)) {
418 if (IsRegularFileUtf8(resourcePath)) {
419 return resourcePath;
420 }
421 throw FileNotFound(resourcePath);
422 }
423
424 std::ostringstream searched;
425 for (size_t i = 0; i < searchPaths.size(); i++) {
426 const std::string& root = searchPaths[i];
427 if (i != 0) {
428 searched << ", ";
429 }
430 searched << root;
431
432 const std::string candidate = JoinPath(root, resourcePath);
433 if (IsRegularFileUtf8(candidate)) {
434 return candidate;
435 }
436 }
437
438 throw FileNotFound(resourcePath + " (searched: " + searched.str() + ")");
439}
440
441ZipResourceProvider::ZipResourceProvider(std::string zipFileName)
442 : internal(new Internal(zipFileName)) {}

Callers 6

TEST_FFunction · 0.80
SchemaMethod · 0.80
HandleRefSchemaMethod · 0.80
FindIdMethod · 0.80
GetUriFunction · 0.80

Calls 6

IsRegularFileUtf8Function · 0.85
IsAbsolutePathFunction · 0.70
JoinPathFunction · 0.70
emptyMethod · 0.45
sizeMethod · 0.45
strMethod · 0.45

Tested by 1

TEST_FFunction · 0.64