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

Side by Side Diff: base/file_path.cc

Issue 16239: Add a method to explicitly request a UTF8 representation of a FilePath. This... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years 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
« no previous file with comments | « base/file_path.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 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/file_path.h" 5 #include "base/file_path.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 // These includes are just for the *Hack functions, and should be removed 9 // These includes are just for the *Hack functions, and should be removed
10 // when those functions are removed. 10 // when those functions are removed.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 return path.length() > 1 && 56 return path.length() > 1 &&
57 FilePath::IsSeparator(path[0]) && FilePath::IsSeparator(path[1]); 57 FilePath::IsSeparator(path[0]) && FilePath::IsSeparator(path[1]);
58 #else // FILE_PATH_USES_DRIVE_LETTERS 58 #else // FILE_PATH_USES_DRIVE_LETTERS
59 // Look for a separator in the first position. 59 // Look for a separator in the first position.
60 return path.length() > 0 && FilePath::IsSeparator(path[0]); 60 return path.length() > 0 && FilePath::IsSeparator(path[0]);
61 #endif // FILE_PATH_USES_DRIVE_LETTERS 61 #endif // FILE_PATH_USES_DRIVE_LETTERS
62 } 62 }
63 63
64 } // namespace 64 } // namespace
65 65
66 const std::string FilePath::UTF8Value() const {
67 #if defined(OS_POSIX)
68 // TODO(erikkay): I'm not sure how to make this code always correct for Linux.
darin (slow to review) 2008/12/23 20:23:55 this is precisely why this kind of function is pro
Avi (use Gerrit) 2008/12/23 22:58:49 There are cases where we need to have the path in
Erik does not do reviews 2008/12/23 23:02:04 Unfortunately, as Darin educated me here, this met
69 return path_;
70 #elif defined(OS_WIN)
71 return WideToUTF8(path_);
72 #endif
73 }
74
66 bool FilePath::IsSeparator(CharType character) { 75 bool FilePath::IsSeparator(CharType character) {
67 for (size_t i = 0; i < arraysize(kSeparators) - 1; ++i) { 76 for (size_t i = 0; i < arraysize(kSeparators) - 1; ++i) {
68 if (character == kSeparators[i]) { 77 if (character == kSeparators[i]) {
69 return true; 78 return true;
70 } 79 }
71 } 80 }
72 81
73 return false; 82 return false;
74 } 83 }
75 84
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 --pos) { 258 --pos) {
250 // If the string only has two separators and they're at the beginning, 259 // If the string only has two separators and they're at the beginning,
251 // don't strip them, unless the string began with more than two separators. 260 // don't strip them, unless the string began with more than two separators.
252 if (pos != start + 1 || last_stripped == start + 2 || 261 if (pos != start + 1 || last_stripped == start + 2 ||
253 !IsSeparator(path_[start - 1])) { 262 !IsSeparator(path_[start - 1])) {
254 path_.resize(pos - 1); 263 path_.resize(pos - 1);
255 last_stripped = pos; 264 last_stripped = pos;
256 } 265 }
257 } 266 }
258 } 267 }
OLDNEW
« no previous file with comments | « base/file_path.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698