OLD | NEW |
1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
4 */ | 4 */ |
5 #include "nacl_io/path.h" | 5 #include "nacl_io/path.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <string.h> | 8 #include <string.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 size_t next = 0; | 173 size_t next = 0; |
174 | 174 |
175 if (path[0] == '/') { | 175 if (path[0] == '/') { |
176 offs = 1; | 176 offs = 1; |
177 components.push_back("/"); | 177 components.push_back("/"); |
178 } | 178 } |
179 | 179 |
180 while (next != std::string::npos) { | 180 while (next != std::string::npos) { |
181 next = path.find('/', offs); | 181 next = path.find('/', offs); |
182 | 182 |
183 // Remove extra seperators | 183 // Remove extra separators |
184 if (next == offs) { | 184 if (next == offs) { |
185 ++offs; | 185 ++offs; |
186 continue; | 186 continue; |
187 } | 187 } |
188 | 188 |
189 std::string part = path.substr(offs, next - offs); | 189 std::string part = path.substr(offs, next - offs); |
190 if (!part.empty()) components.push_back(part); | 190 if (!part.empty()) components.push_back(part); |
191 offs = next + 1; | 191 offs = next + 1; |
192 } | 192 } |
193 return components; | 193 return components; |
194 } | 194 } |
195 | 195 |
196 Path& Path::operator =(const Path& p) { | 196 Path& Path::operator =(const Path& p) { |
197 paths_ = p.paths_; | 197 paths_ = p.paths_; |
198 return *this; | 198 return *this; |
199 } | 199 } |
200 | 200 |
201 Path& Path::operator =(const std::string& p) { | 201 Path& Path::operator =(const std::string& p) { |
202 return Set(p); | 202 return Set(p); |
203 } | 203 } |
OLD | NEW |