| OLD | NEW |
| 1 // Copyright (c) 2010 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 // FilePath is a container for pathnames stored in a platform's native string | 5 // FilePath is a container for pathnames stored in a platform's native string |
| 6 // type, providing containers for manipulation in according with the | 6 // type, providing containers for manipulation in according with the |
| 7 // platform's conventions for pathnames. It supports the following path | 7 // platform's conventions for pathnames. It supports the following path |
| 8 // types: | 8 // types: |
| 9 // | 9 // |
| 10 // POSIX Windows | 10 // POSIX Windows |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 bool IsAbsolute() const; | 270 bool IsAbsolute() const; |
| 271 | 271 |
| 272 // Returns a copy of this FilePath that does not end with a trailing | 272 // Returns a copy of this FilePath that does not end with a trailing |
| 273 // separator. | 273 // separator. |
| 274 FilePath StripTrailingSeparators() const; | 274 FilePath StripTrailingSeparators() const; |
| 275 | 275 |
| 276 // Returns true if this FilePath contains any attempt to reference a parent | 276 // Returns true if this FilePath contains any attempt to reference a parent |
| 277 // directory (i.e. has a path component that is ".." | 277 // directory (i.e. has a path component that is ".." |
| 278 bool ReferencesParent() const; | 278 bool ReferencesParent() const; |
| 279 | 279 |
| 280 // Return a Unicode human-readable version of this path. |
| 281 // Warning: you can *not*, in general, go from a display name back to a real |
| 282 // path. Only use this when displaying paths to users, not just when you |
| 283 // want to stuff a string16 into some other API. |
| 284 string16 LossyDisplayName() const; |
| 285 |
| 280 // Older Chromium code assumes that paths are always wstrings. | 286 // Older Chromium code assumes that paths are always wstrings. |
| 281 // These functions convert wstrings to/from FilePaths, and are | 287 // These functions convert wstrings to/from FilePaths, and are |
| 282 // useful to smooth porting that old code to the FilePath API. | 288 // useful to smooth porting that old code to the FilePath API. |
| 283 // They have "Hack" in their names so people feel bad about using them. | 289 // They have "Hack" in their names so people feel bad about using them. |
| 284 // http://code.google.com/p/chromium/issues/detail?id=24672 | 290 // http://code.google.com/p/chromium/issues/detail?id=24672 |
| 285 // | 291 // |
| 286 // If you are trying to be a good citizen and remove these, ask yourself: | 292 // If you are trying to be a good citizen and remove these, ask yourself: |
| 287 // - Am I interacting with other Chrome code that deals with files? Then | 293 // - Am I interacting with other Chrome code that deals with files? Then |
| 288 // try to convert the API into using FilePath. | 294 // try to convert the API into using FilePath. |
| 289 // - Am I interacting with OS-native calls? Then use value() to get at an | 295 // - Am I interacting with OS-native calls? Then use value() to get at an |
| 290 // OS-native string format. | 296 // OS-native string format. |
| 291 // - Am I using well-known file names, like "config.ini"? Then use the | 297 // - Am I using well-known file names, like "config.ini"? Then use the |
| 292 // ASCII functions (we require paths to always be supersets of ASCII). | 298 // ASCII functions (we require paths to always be supersets of ASCII). |
| 299 // - Am I displaying a string to the user in some UI? Then use the |
| 300 // LossyDisplayName() function, but keep in mind that you can't |
| 301 // ever use the result of that again as a path. |
| 293 static FilePath FromWStringHack(const std::wstring& wstring); | 302 static FilePath FromWStringHack(const std::wstring& wstring); |
| 294 std::wstring ToWStringHack() const; | 303 std::wstring ToWStringHack() const; |
| 295 | 304 |
| 296 // Static helper method to write a StringType to a pickle. | 305 // Static helper method to write a StringType to a pickle. |
| 297 static void WriteStringTypeToPickle(Pickle* pickle, | 306 static void WriteStringTypeToPickle(Pickle* pickle, |
| 298 const FilePath::StringType& path); | 307 const FilePath::StringType& path); |
| 299 static bool ReadStringTypeFromPickle(Pickle* pickle, void** iter, | 308 static bool ReadStringTypeFromPickle(Pickle* pickle, void** iter, |
| 300 FilePath::StringType* path); | 309 FilePath::StringType* path); |
| 301 | 310 |
| 302 void WriteToPickle(Pickle* pickle); | 311 void WriteToPickle(Pickle* pickle); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 namespace stdext { | 391 namespace stdext { |
| 383 | 392 |
| 384 inline size_t hash_value(const FilePath& f) { | 393 inline size_t hash_value(const FilePath& f) { |
| 385 return hash_value(f.value()); | 394 return hash_value(f.value()); |
| 386 } | 395 } |
| 387 | 396 |
| 388 } // namespace stdext | 397 } // namespace stdext |
| 389 #endif // COMPILER | 398 #endif // COMPILER |
| 390 | 399 |
| 391 #endif // BASE_FILE_PATH_H_ | 400 #endif // BASE_FILE_PATH_H_ |
| OLD | NEW |