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

Side by Side Diff: base/file_path.cc

Issue 549224: Support reordering of Browser Actions within the container. Currently does no... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 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
« no previous file with comments | « base/file_path.h ('k') | chrome/browser/bookmarks/bookmark_drag_data.h » ('j') | 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) 2010 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 6
7 #if defined(OS_MACOSX) 7 #if defined(OS_MACOSX)
8 #include <CoreServices/CoreServices.h> 8 #include <CoreServices/CoreServices.h>
9 #endif 9 #endif
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/pickle.h"
12 13
13 // These includes are just for the *Hack functions, and should be removed 14 // These includes are just for the *Hack functions, and should be removed
14 // when those functions are removed. 15 // when those functions are removed.
15 #include "base/string_piece.h" 16 #include "base/string_piece.h"
16 #include "base/string_util.h" 17 #include "base/string_util.h"
17 #include "base/sys_string_conversions.h" 18 #include "base/sys_string_conversions.h"
18 19
19 #if defined(OS_MACOSX) 20 #if defined(OS_MACOSX)
20 #include "base/scoped_cftyperef.h" 21 #include "base/scoped_cftyperef.h"
21 #include "base/third_party/icu/icu_utf.h" 22 #include "base/third_party/icu/icu_utf.h"
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 } 1045 }
1045 #endif 1046 #endif
1046 1047
1047 FilePath FilePath::StripTrailingSeparators() const { 1048 FilePath FilePath::StripTrailingSeparators() const {
1048 FilePath new_path(path_); 1049 FilePath new_path(path_);
1049 new_path.StripTrailingSeparatorsInternal(); 1050 new_path.StripTrailingSeparatorsInternal();
1050 1051
1051 return new_path; 1052 return new_path;
1052 } 1053 }
1053 1054
1055 // static.
1056 void FilePath::WriteStringTypeToPickle(Pickle* pickle,
1057 const FilePath::StringType& path) {
1058 #if defined(WCHAR_T_IS_UTF16)
1059 pickle->WriteWString(path);
1060 #elif defined(WCHAR_T_IS_UTF32)
1061 pickle->WriteString(path);
1062 #else
1063 NOTIMPLEMENTED() << "Impossible encoding situation!";
1064 #endif
1065 }
1066
1067 // static.
1068 bool FilePath::ReadStringTypeFromPickle(Pickle* pickle, void** iter,
1069 FilePath::StringType* path) {
1070 #if defined(WCHAR_T_IS_UTF16)
1071 if (!pickle->ReadWString(iter, path))
1072 return false;
1073 #elif defined(WCHAR_T_IS_UTF32)
1074 if (!pickle->ReadString(iter, path))
1075 return false;
1076 #else
1077 NOTIMPLEMENTED() << "Impossible encoding situation!";
1078 return false;
1079 #endif
1080
1081 return true;
1082 }
1083
1084 void FilePath::WriteToPickle(Pickle* pickle) {
1085 WriteStringTypeToPickle(pickle, value());
1086 }
1087
1088 bool FilePath::ReadFromPickle(Pickle* pickle, void** iter) {
1089 return ReadStringTypeFromPickle(pickle, iter, &path_);
1090 }
1091
1054 void FilePath::StripTrailingSeparatorsInternal() { 1092 void FilePath::StripTrailingSeparatorsInternal() {
1055 // If there is no drive letter, start will be 1, which will prevent stripping 1093 // If there is no drive letter, start will be 1, which will prevent stripping
1056 // the leading separator if there is only one separator. If there is a drive 1094 // the leading separator if there is only one separator. If there is a drive
1057 // letter, start will be set appropriately to prevent stripping the first 1095 // letter, start will be set appropriately to prevent stripping the first
1058 // separator following the drive letter, if a separator immediately follows 1096 // separator following the drive letter, if a separator immediately follows
1059 // the drive letter. 1097 // the drive letter.
1060 StringType::size_type start = FindDriveLetter(path_) + 2; 1098 StringType::size_type start = FindDriveLetter(path_) + 2;
1061 1099
1062 StringType::size_type last_stripped = StringType::npos; 1100 StringType::size_type last_stripped = StringType::npos;
1063 for (StringType::size_type pos = path_.length(); 1101 for (StringType::size_type pos = path_.length();
(...skipping 15 matching lines...) Expand all
1079 1117
1080 std::vector<FilePath::StringType>::const_iterator it = components.begin(); 1118 std::vector<FilePath::StringType>::const_iterator it = components.begin();
1081 for (; it != components.end(); ++it) { 1119 for (; it != components.end(); ++it) {
1082 const FilePath::StringType& component = *it; 1120 const FilePath::StringType& component = *it;
1083 if (component == kParentDirectory) 1121 if (component == kParentDirectory)
1084 return true; 1122 return true;
1085 } 1123 }
1086 return false; 1124 return false;
1087 } 1125 }
1088 1126
OLDNEW
« no previous file with comments | « base/file_path.h ('k') | chrome/browser/bookmarks/bookmark_drag_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698