| 711 | |
| 712 | |
| 713 | void Path::parseWindows(const std::string& path) |
| 714 | { |
| 715 | clear(); |
| 716 | |
| 717 | std::string::const_iterator it = path.begin(); |
| 718 | std::string::const_iterator end = path.end(); |
| 719 | |
| 720 | if (it != end) |
| 721 | { |
| 722 | if (*it == '\\' || *it == '/') { _absolute = true; ++it; } |
| 723 | if (_absolute && it != end && (*it == '\\' || *it == '/')) // UNC |
| 724 | { |
| 725 | ++it; |
| 726 | while (it != end && *it != '\\' && *it != '/') _node += *it++; |
| 727 | if (it != end) ++it; |
| 728 | } |
| 729 | else if (it != end) |
| 730 | { |
| 731 | char d = *it++; |
| 732 | if (it != end && *it == ':') // drive letter |
| 733 | { |
| 734 | if (_absolute || !((d >= 'a' && d <= 'z') || (d >= 'A' && d <= 'Z'))) throw PathSyntaxException(path); |
| 735 | _absolute = true; |
| 736 | _device += d; |
| 737 | ++it; |
| 738 | if (it == end || (*it != '\\' && *it != '/')) throw PathSyntaxException(path); |
| 739 | ++it; |
| 740 | } |
| 741 | else --it; |
| 742 | } |
| 743 | while (it != end) |
| 744 | { |
| 745 | std::string name; |
| 746 | while (it != end && *it != '\\' && *it != '/') name += *it++; |
| 747 | if (it != end) |
| 748 | pushDirectory(name); |
| 749 | else |
| 750 | _name = name; |
| 751 | if (it != end) ++it; |
| 752 | } |
| 753 | } |
| 754 | if (!_node.empty() && _dirs.empty() && !_name.empty()) |
| 755 | makeDirectory(); |
| 756 | } |
| 757 | |
| 758 | |
| 759 | void Path::parseVMS(const std::string& path) |