MCPcopy Create free account
hub / github.com/ablab/spades / find_first_component

Function find_first_component

ext/src/llvm/Path.cpp:59–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57 }
58
59 StringRef find_first_component(StringRef path, Style style) {
60 // Look for this first component in the following order.
61 // * empty (in this case we return an empty string)
62 // * either C: or {//,\\}net.
63 // * {/,\}
64 // * {file,directory}name
65
66 if (path.empty())
67 return path;
68
69 if (real_style(style) == Style::windows) {
70 // C:
71 if (path.size() >= 2 &&
72 std::isalpha(static_cast<unsigned char>(path[0])) && path[1] == ':')
73 return path.substr(0, 2);
74 }
75
76 // //net
77 if ((path.size() > 2) && is_separator(path[0], style) &&
78 path[0] == path[1] && !is_separator(path[2], style)) {
79 // Find the next directory separator.
80 size_t end = path.find_first_of(separators(style), 2);
81 return path.substr(0, end);
82 }
83
84 // {/,\}
85 if (is_separator(path[0], style))
86 return path.substr(0, 1);
87
88 // * {file,directory}name
89 size_t end = path.find_first_of(separators(style));
90 return path.substr(0, end);
91 }
92
93 // Returns the first character of the filename in str. For paths ending in
94 // '/', it returns the position of the '/'.

Callers 1

beginFunction · 0.85

Calls 8

real_styleFunction · 0.85
isalphaFunction · 0.85
is_separatorFunction · 0.85
separatorsFunction · 0.85
emptyMethod · 0.45
sizeMethod · 0.45
substrMethod · 0.45
find_first_ofMethod · 0.45

Tested by

no test coverage detected