MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / get_base_dir

Method get_base_dir

core/string/ustring.cpp:5258–5317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5256}
5257
5258String String::get_base_dir() const {
5259 int end = 0;
5260
5261 // URL scheme style base.
5262 int basepos = find("://");
5263 if (basepos != -1) {
5264 end = basepos + 3;
5265 }
5266
5267 // Windows top level directory base.
5268 if (end == 0) {
5269 basepos = find(":/");
5270 if (basepos == -1) {
5271 basepos = find(":\\");
5272 }
5273 if (basepos != -1) {
5274 end = basepos + 2;
5275 }
5276 }
5277
5278 // Windows UNC network share path.
5279 if (end == 0) {
5280 if (is_network_share_path()) {
5281 basepos = find_char('/', 2);
5282 if (basepos == -1) {
5283 basepos = find_char('\\', 2);
5284 }
5285 int servpos = find_char('/', basepos + 1);
5286 if (servpos == -1) {
5287 servpos = find_char('\\', basepos + 1);
5288 }
5289 if (servpos != -1) {
5290 end = servpos + 1;
5291 }
5292 }
5293 }
5294
5295 // Unix root directory base.
5296 if (end == 0) {
5297 if (begins_with("/")) {
5298 end = 1;
5299 }
5300 }
5301
5302 String rs;
5303 String base;
5304 if (end != 0) {
5305 rs = substr(end, length());
5306 base = substr(0, end);
5307 } else {
5308 rs = *this;
5309 }
5310
5311 int sep = MAX(rs.rfind_char('/'), rs.rfind_char('\\'));
5312 if (sep == -1) {
5313 return base;
5314 }
5315

Callers 15

_load_bitmap_fontMethod · 0.80
loadMethod · 0.80
get_dependenciesMethod · 0.80
rename_dependenciesMethod · 0.80
_get_mono_user_dirFunction · 0.80
_GodotSharpDirsMethod · 0.80
relative_to_implFunction · 0.80
_encode_buffer_glbMethod · 0.80
_encode_buffer_binsMethod · 0.80
write_to_filesystemMethod · 0.80
append_from_bufferMethod · 0.80

Calls 4

findFunction · 0.85
MAXFunction · 0.85
rfind_charMethod · 0.80
substrMethod · 0.80

Tested by 2

testFunction · 0.64
get_executable_dirMethod · 0.64