| 5395 | } |
| 5396 | |
| 5397 | String String::get_base_dir() const |
| 5398 | { |
| 5399 | int end = 0; |
| 5400 | |
| 5401 | // URL scheme style base. |
| 5402 | int basepos = find("://"); |
| 5403 | if (basepos != -1) |
| 5404 | { |
| 5405 | end = basepos + 3; |
| 5406 | } |
| 5407 | |
| 5408 | // Windows top level directory base. |
| 5409 | if (end == 0) |
| 5410 | { |
| 5411 | basepos = find(":/"); |
| 5412 | if (basepos == -1) |
| 5413 | { |
| 5414 | basepos = find(":\\"); |
| 5415 | } |
| 5416 | if (basepos != -1) |
| 5417 | { |
| 5418 | end = basepos + 2; |
| 5419 | } |
| 5420 | } |
| 5421 | |
| 5422 | // Windows UNC network share path. |
| 5423 | if (end == 0) |
| 5424 | { |
| 5425 | if (is_network_share_path()) |
| 5426 | { |
| 5427 | basepos = find("/", 2); |
| 5428 | if (basepos == -1) |
| 5429 | { |
| 5430 | basepos = find("\\", 2); |
| 5431 | } |
| 5432 | int servpos = find("/", basepos + 1); |
| 5433 | if (servpos == -1) |
| 5434 | { |
| 5435 | servpos = find("\\", basepos + 1); |
| 5436 | } |
| 5437 | if (servpos != -1) |
| 5438 | { |
| 5439 | end = servpos + 1; |
| 5440 | } |
| 5441 | } |
| 5442 | } |
| 5443 | |
| 5444 | // Unix root directory base. |
| 5445 | if (end == 0) |
| 5446 | { |
| 5447 | if (begins_with("/")) |
| 5448 | { |
| 5449 | end = 1; |
| 5450 | } |
| 5451 | } |
| 5452 | |
| 5453 | String rs; |
| 5454 | String base; |