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

Method basename

src/slave/containerizer/fetcher.cpp:104–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102
103
104Try<string> Fetcher::basename(const string& uri)
105{
106 // TODO(bernd-mesos): full URI parsing, then move this to stout.
107 // There is a bug (or is it a feature?) in the original fetcher
108 // code without caching that remains in effect here. URIs are
109 // treated like file paths, looking for occurrences of "/",
110 // but ignoring other separators that can show up
111 // (e.g. "?", "=" in HTTP URLs).
112
113 if (uri.find_first_of('\\') != string::npos ||
114 uri.find_first_of('\'') != string::npos ||
115 uri.find_first_of('\0') != string::npos) {
116 return Error("Illegal characters in URI");
117 }
118
119 size_t index = uri.find("://");
120 if (index != string::npos && 1 < index) {
121 // URI starts with protocol specifier, e.g., http://, https://,
122 // ftp://, ftps://, hdfs://, hftp://, s3://, s3n://.
123
124 string path = uri.substr(index + 3);
125 if (!strings::contains(path, "/") || path.size() <= path.find('/') + 1) {
126 return Error("Malformed URI (missing path): " + uri);
127 }
128
129 return path.substr(path.find_last_of('/') + 1);
130 }
131 return Path(uri).basename();
132}
133
134
135Try<Nothing> Fetcher::validateUri(const string& uri)

Callers 15

import_modulesFunction · 0.45
validateFunction · 0.45
_downloadMethod · 0.45
fetchMethod · 0.45
fetchMethod · 0.45
saveMethod · 0.45
recoverMethod · 0.45
getLogFileFunction · 0.45
foreachFunction · 0.45
usageFunction · 0.45
mainFunction · 0.45
extractFunction · 0.45

Calls 5

PathClass · 0.85
ErrorFunction · 0.50
containsFunction · 0.50
findMethod · 0.45
sizeMethod · 0.45

Tested by 10

validateFunction · 0.36
TESTFunction · 0.36
foreachFunction · 0.36
TEST_FFunction · 0.36
serveRequestMethod · 0.36
createProfileMethod · 0.36
usageFunction · 0.36
usageFunction · 0.36
parseVolumePathMethod · 0.36