| 30 | namespace Firebird { |
| 31 | |
| 32 | void ParsedPath::parse(const PathName& path) |
| 33 | { |
| 34 | clear(); |
| 35 | |
| 36 | PathName oldpath = path; |
| 37 | int toSkip = 0; |
| 38 | |
| 39 | do |
| 40 | { |
| 41 | PathName newpath, elem; |
| 42 | PathUtils::splitLastComponent(newpath, elem, oldpath); |
| 43 | oldpath = newpath; |
| 44 | |
| 45 | if (elem.isEmpty()) // Skip double dir separator |
| 46 | continue; |
| 47 | |
| 48 | if (elem == PathUtils::curr_dir_link) // Skip current dir reference |
| 49 | continue; |
| 50 | |
| 51 | if (elem == PathUtils::up_dir_link) // skip next up dir |
| 52 | { |
| 53 | toSkip++; |
| 54 | continue; |
| 55 | } |
| 56 | |
| 57 | if (toSkip > 0) |
| 58 | { |
| 59 | toSkip--; |
| 60 | continue; |
| 61 | } |
| 62 | |
| 63 | insert(0, elem); |
| 64 | } while (oldpath.hasData()); |
| 65 | |
| 66 | if (toSkip != 0) |
| 67 | { |
| 68 | // Malformed path, attempt to hack?.. |
| 69 | // Let it be, consequent comparison will rule it out |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | PathName ParsedPath::subPath(FB_SIZE_T n) const |
| 74 | { |