MCPcopy Create free account
hub / github.com/apache/mesos / parseMountPath

Function parseMountPath

src/csi/paths.cpp:298–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

296
297
298Try<string> parseMountPath(const string& mountRootDir, const string& dir)
299{
300 // TODO(chhsiao): Consider using `<regex>`, which requires GCC 4.9+.
301
302 // Make sure there's a separator at the end of the `mountRootDir` so that we
303 // don't accidentally slice off part of a directory.
304 const string prefix = path::join(mountRootDir, "");
305
306 if (!strings::startsWith(dir, prefix)) {
307 return Error(
308 "Directory '" + dir + "' does not fall under the mount root directory"
309 " '" + mountRootDir + "'");
310 }
311
312 // Volume ID is percent-encoded to avoid invalid characters in the path.
313 Try<string> volumeId = http::decode(Path(dir).basename());
314 if (volumeId.isError()) {
315 return Error(
316 "Could not decode volume ID from string '" + Path(dir).basename() +
317 "': " + volumeId.error());
318 }
319
320 return volumeId.get();
321}
322
323
324string getMountStagingPath(

Callers 2

foreachFunction · 0.85
foreachFunction · 0.85

Calls 9

startsWithFunction · 0.85
PathClass · 0.85
errorMethod · 0.65
joinFunction · 0.50
ErrorFunction · 0.50
decodeFunction · 0.50
basenameMethod · 0.45
isErrorMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected