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

Method relativeTo

source/core/StarFile_windows.cpp:135–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133}
134
135String File::relativeTo(String const& relativeTo, String const& path) {
136 if (path.beginsWith('/') || path.beginsWith('\\') || path.regexMatch("^[a-z]:", false, false))
137 return path;
138
139 String finalPath;
140 if (relativeTo.endsWith('\\') || relativeTo.endsWith('/'))
141 finalPath = relativeTo.substr(0, relativeTo.size() - 1);
142 else if (relativeTo.endsWith("\\.") || relativeTo.endsWith("/."))
143 finalPath = relativeTo.substr(0, relativeTo.size() - 2);
144 else
145 finalPath = relativeTo;
146
147 if (path.beginsWith(".\\") || path.beginsWith("./"))
148 finalPath += '\\' + path.substr(2);
149 else
150 finalPath += '\\' + path;
151
152 return finalPath;
153}
154
155String File::temporaryFileName() {
156 WCHAR tempPath[MAX_PATH];

Callers

nothing calls this directly

Calls 5

regexMatchMethod · 0.80
beginsWithMethod · 0.45
endsWithMethod · 0.45
substrMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected