* @brief Checks if path is an absolute path. * @param [in] path Path to check. * @return true if given path is absolute path. */
| 596 | * @return true if given path is absolute path. |
| 597 | */ |
| 598 | bool IsPathAbsolute(const String &path) |
| 599 | { |
| 600 | if (path.length() < 3) |
| 601 | return false; |
| 602 | |
| 603 | size_t pos = path.find_last_of('\\'); |
| 604 | |
| 605 | // Absolute path must have "\" and cannot start with it. |
| 606 | // Also "\\blahblah" is invalid. |
| 607 | if (pos < 2 || pos == String::npos) |
| 608 | return false; |
| 609 | |
| 610 | // Maybe "X:\blahblah"? |
| 611 | if (path[1] == ':' && path[2] == '\\') |
| 612 | return true; |
| 613 | |
| 614 | // So "\\blahblah\"? |
| 615 | if (path[0] == '\\' && path[1] == '\\' && pos > 2) |
| 616 | return true; |
| 617 | else |
| 618 | return false; |
| 619 | } |
| 620 | |
| 621 | /** |
| 622 | * @brief Checks if folder exists and creates it if needed. |