48 {
50 return ".";
51
52 size_t put = 0;
54 size_t traversal_root = 0;
55 size_t component_start = 0;
56
58 put = 1;
60 component_start = 1;
61 }
62
65
66 if (c ==
'.' && (
get == component_start ||
get == component_start + 1)) {
67
68
70 continue;
71 }
72
73 if (c == '/') {
74 if (
get == component_start ||
get == component_start + 1) {
75
77 component_start =
get;
78 continue;
79 }
80 if (
get == component_start + 2) {
81
82
83 if (put == traversal_root) {
87 traversal_root = put;
88 } else {
89 put = ResolveParentDirectoryTraversal(
path, put);
90 }
92 component_start =
get;
93 continue;
94 }
95 }
96
97 size_t next_separator =
path.find(
'/',
get);
98 if (next_separator == std::string::npos) {
99
100 break;
101 }
102 size_t next_component_start = next_separator + 1;
103 ++next_separator;
104 size_t component_size = next_component_start - component_start;
105 if (put != component_start && component_size > 0) {
106 path.replace(put, component_size,
107 path.substr(component_start, component_size));
108 }
109 put += component_size;
110 get = next_component_start;
111 component_start = next_component_start;
112 }
113
114 size_t last_component_size =
path.size() - component_start;
115 if (last_component_size == 1 &&
path[component_start] ==
'.') {
116
117 }
else if (last_component_size == 2 &&
path[component_start] ==
'.' &&
118 path[component_start + 1] ==
'.') {
119
120
121 if (put == traversal_root) {
125 traversal_root = put;
126 } else {
127 put = ResolveParentDirectoryTraversal(
path, put);
128 }
129 } else {
130
131 if (put != component_start && last_component_size > 0) {
132 path.replace(put, last_component_size,
133 path.substr(component_start, last_component_size));
134 }
135 put += last_component_size;
136 }
137
138 if (put >= 2 &&
path[put - 1] ==
'/')
139 --put;
140 else if (put == 0)
141 return ".";
142
145}
const myers::Point & get(const myers::Segment &)