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

Side by Side Diff: base/file_path.cc

Issue 174053: Set OS X cache directory to ~/Library/Caches/[app name]/[profile name] (Closed)
Patch Set: Addressed Mark's comments Created 11 years, 3 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
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/logging.h" 6 #include "base/logging.h"
7 7
8 // These includes are just for the *Hack functions, and should be removed 8 // These includes are just for the *Hack functions, and should be removed
9 // when those functions are removed. 9 // when those functions are removed.
10 #include "base/string_piece.h" 10 #include "base/string_piece.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 bool FilePath::operator!=(const FilePath& that) const { 153 bool FilePath::operator!=(const FilePath& that) const {
154 #if defined(FILE_PATH_USES_DRIVE_LETTERS) 154 #if defined(FILE_PATH_USES_DRIVE_LETTERS)
155 return !EqualDriveLetterCaseInsensitive(this->path_, that.path_); 155 return !EqualDriveLetterCaseInsensitive(this->path_, that.path_);
156 #else // defined(FILE_PATH_USES_DRIVE_LETTERS) 156 #else // defined(FILE_PATH_USES_DRIVE_LETTERS)
157 return path_ != that.path_; 157 return path_ != that.path_;
158 #endif // defined(FILE_PATH_USES_DRIVE_LETTERS) 158 #endif // defined(FILE_PATH_USES_DRIVE_LETTERS)
159 } 159 }
160 160
161 bool FilePath::IsParent(const FilePath& child) const { 161 bool FilePath::IsParent(const FilePath& child) const {
162 return AppendRelativePath(child, NULL);
163 }
164
165 bool FilePath::AppendRelativePath(const FilePath& child,
166 FilePath* path) const {
162 std::vector<FilePath::StringType> parent_components; 167 std::vector<FilePath::StringType> parent_components;
163 std::vector<FilePath::StringType> child_components; 168 std::vector<FilePath::StringType> child_components;
164 GetComponents(&parent_components); 169 GetComponents(&parent_components);
165 child.GetComponents(&child_components); 170 child.GetComponents(&child_components);
166 171
167 if (parent_components.size() >= child_components.size()) 172 if (parent_components.size() >= child_components.size())
168 return false; 173 return false;
169 if (parent_components.size() == 0) 174 if (parent_components.size() == 0)
170 return false; 175 return false;
171 176
(...skipping 15 matching lines...) Expand all
187 } 192 }
188 #endif // defined(FILE_PATH_USES_DRIVE_LETTERS) 193 #endif // defined(FILE_PATH_USES_DRIVE_LETTERS)
189 194
190 while (parent_comp != parent_components.end()) { 195 while (parent_comp != parent_components.end()) {
191 if (*parent_comp != *child_comp) 196 if (*parent_comp != *child_comp)
192 return false; 197 return false;
193 ++parent_comp; 198 ++parent_comp;
194 ++child_comp; 199 ++child_comp;
195 } 200 }
196 201
202 if (path != NULL) {
203 for (; child_comp != child_components.end(); ++child_comp) {
204 *path = path->Append(*child_comp);
205 }
206 }
197 return true; 207 return true;
198 } 208 }
199 209
200 // libgen's dirname and basename aren't guaranteed to be thread-safe and aren't 210 // libgen's dirname and basename aren't guaranteed to be thread-safe and aren't
201 // guaranteed to not modify their input strings, and in fact are implemented 211 // guaranteed to not modify their input strings, and in fact are implemented
202 // differently in this regard on different platforms. Don't use them, but 212 // differently in this regard on different platforms. Don't use them, but
203 // adhere to their behavior. 213 // adhere to their behavior.
204 FilePath FilePath::DirName() const { 214 FilePath FilePath::DirName() const {
205 FilePath new_path(path_); 215 FilePath new_path(path_);
206 new_path.StripTrailingSeparatorsInternal(); 216 new_path.StripTrailingSeparatorsInternal();
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 479
470 std::vector<FilePath::StringType>::const_iterator it = components.begin(); 480 std::vector<FilePath::StringType>::const_iterator it = components.begin();
471 for (; it != components.end(); ++it) { 481 for (; it != components.end(); ++it) {
472 const FilePath::StringType& component = *it; 482 const FilePath::StringType& component = *it;
473 if (component == kParentDirectory) 483 if (component == kParentDirectory)
474 return true; 484 return true;
475 } 485 }
476 return false; 486 return false;
477 } 487 }
478 488
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698