MCPcopy Create free account
hub / github.com/GDRETools/gdsdecomp / get_base_dir

Function get_base_dir

utility/glob.cpp:175–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173// `get_base_dir()` but with escaped glob characters
174
175String get_base_dir(const String &path) {
176 int end = 0;
177
178 // URL scheme style base.
179 int basepos = path.find("://");
180 if (basepos != -1) {
181 end = basepos + 3;
182 }
183
184 // Windows top level directory base.
185 if (end == 0) {
186 basepos = path.find(":/");
187 if (basepos == -1) {
188 basepos = path.find(":\\");
189 }
190 if (basepos != -1) {
191 end = basepos + 2;
192 }
193 }
194
195 // Windows UNC network share path.
196 if (end == 0) {
197 if (path.is_network_share_path()) {
198 basepos = path.find_char('/', 2);
199 if (basepos == -1) {
200 basepos = path.find_char('\\', 2);
201 }
202 int servpos = path.find_char('/', basepos + 1);
203 if (servpos == -1) {
204 servpos = path.find_char('\\', basepos + 1);
205 }
206 if (servpos != -1) {
207 end = servpos + 1;
208 }
209 }
210 }
211
212 // Unix root directory base.
213 if (end == 0) {
214 if (path.begins_with("/")) {
215 end = 1;
216 }
217 }
218
219 String rs;
220 String base;
221 if (end != 0) {
222 rs = path.substr(end, path.length());
223 base = path.substr(0, end);
224 } else {
225 rs = path;
226 }
227
228 int sep = get_last_dir_sep(rs);
229 if (sep == -1) {
230 return base;
231 }
232

Callers 3

get_real_base_dirFunction · 0.85
_globMethod · 0.85
dirs_in_namesMethod · 0.85

Calls 3

get_last_dir_sepFunction · 0.85
lengthMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected