MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / createRelativePath

Function createRelativePath

source/utility/fix_embedded_tilesets.cpp:16–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14}
15
16String createRelativePath(String fromFile, String toFile) {
17 if (!File::isDirectory(fromFile))
18 fromFile = File::dirName(fromFile);
19 fromFile = File::fullPath(fromFile);
20 toFile = File::fullPath(toFile);
21
22 StringList fromParts = fromFile.splitAny("/\\");
23 StringList toParts = toFile.splitAny("/\\");
24 removeCommonPrefix(fromParts, toParts);
25
26 StringList relativeParts;
27 for (String part : fromParts)
28 relativeParts.append("..");
29 relativeParts.appendAll(toParts);
30
31 return relativeParts.join("/");
32}
33
34Maybe<Json> repairTileset(Json tileset, String const& mapPath, String const& tilesetPath) {
35 if (tileset.contains("source"))

Callers 1

repairTilesetFunction · 0.85

Calls 5

removeCommonPrefixFunction · 0.85
splitAnyMethod · 0.80
appendAllMethod · 0.80
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected