Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(802)

Side by Side Diff: base/files/file_path.cc

Issue 213353004: GN: Move towards only using / on Windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: only generate / in various places Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/files/file_path.h" 5 #include "base/files/file_path.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <algorithm> 8 #include <algorithm>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 // don't strip them, unless the string began with more than two separators. 1285 // don't strip them, unless the string began with more than two separators.
1286 if (pos != start + 1 || last_stripped == start + 2 || 1286 if (pos != start + 1 || last_stripped == start + 2 ||
1287 !IsSeparator(path_[start - 1])) { 1287 !IsSeparator(path_[start - 1])) {
1288 path_.resize(pos - 1); 1288 path_.resize(pos - 1);
1289 last_stripped = pos; 1289 last_stripped = pos;
1290 } 1290 }
1291 } 1291 }
1292 } 1292 }
1293 1293
1294 FilePath FilePath::NormalizePathSeparators() const { 1294 FilePath FilePath::NormalizePathSeparators() const {
1295 return NormalizePathSeparatorsTo(kSeparators[0]);
1296 }
1297
1298 FilePath FilePath::NormalizePathSeparatorsTo(CharType separator) const {
1295 #if defined(FILE_PATH_USES_WIN_SEPARATORS) 1299 #if defined(FILE_PATH_USES_WIN_SEPARATORS)
brettw 2014/04/02 17:34:28 How about DCHECKing here that separator == kSepara
scottmg 2014/04/02 20:20:19 Done.
1296 StringType copy = path_; 1300 StringType copy = path_;
1297 for (size_t i = 1; i < kSeparatorsLength; ++i) { 1301 for (size_t i = 0; i < kSeparatorsLength; ++i) {
1298 std::replace(copy.begin(), copy.end(), kSeparators[i], kSeparators[0]); 1302 std::replace(copy.begin(), copy.end(), kSeparators[i], separator);
1299 } 1303 }
1300 return FilePath(copy); 1304 return FilePath(copy);
1301 #else 1305 #else
1302 return *this; 1306 return *this;
1303 #endif 1307 #endif
1304 } 1308 }
1305 1309
1306 #if defined(OS_ANDROID) 1310 #if defined(OS_ANDROID)
1307 bool FilePath::IsContentUri() const { 1311 bool FilePath::IsContentUri() const {
1308 return StartsWithASCII(path_, "content://", false /*case_sensitive*/); 1312 return StartsWithASCII(path_, "content://", false /*case_sensitive*/);
1309 } 1313 }
1310 #endif 1314 #endif
1311 1315
1312 } // namespace base 1316 } // namespace base
1313 1317
1314 void PrintTo(const base::FilePath& path, std::ostream* out) { 1318 void PrintTo(const base::FilePath& path, std::ostream* out) {
1315 *out << path.value(); 1319 *out << path.value();
1316 } 1320 }
OLDNEW
« no previous file with comments | « base/files/file_path.h ('k') | tools/gn/build_settings.cc » ('j') | tools/gn/build_settings.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698