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

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

Issue 2692273008: Hacky slashy (Closed)
Patch Set: wip Created 3 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
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 // 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 namespace base { 137 namespace base {
138 138
139 class Pickle; 139 class Pickle;
140 class PickleIterator; 140 class PickleIterator;
141 class PickleSizer; 141 class PickleSizer;
142 142
143 // An abstraction to isolate users from the differences between native 143 // An abstraction to isolate users from the differences between native
144 // pathnames on different platforms. 144 // pathnames on different platforms.
145 class BASE_EXPORT FilePath { 145 class BASE_EXPORT FilePath {
146 public: 146 public:
147 #if defined(OS_POSIX) 147 #if defined(OS_POSIX) || defined(OS_FUCHSIA)
148 // On most platforms, native pathnames are char arrays, and the encoding 148 // On most platforms, native pathnames are char arrays, and the encoding
149 // may or may not be specified. On Mac OS X, native pathnames are encoded 149 // may or may not be specified. On Mac OS X, native pathnames are encoded
150 // in UTF-8. 150 // in UTF-8.
151 typedef std::string StringType; 151 typedef std::string StringType;
152 #elif defined(OS_WIN) 152 #elif defined(OS_WIN)
153 // On Windows, for Unicode-aware applications, native pathnames are wchar_t 153 // On Windows, for Unicode-aware applications, native pathnames are wchar_t
154 // arrays encoded in UTF-16. 154 // arrays encoded in UTF-16.
155 typedef std::wstring StringType; 155 typedef std::wstring StringType;
156 #endif // OS_WIN 156 #endif // OS_WIN
157 157
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 // This is required by googletest to print a readable output on test failures. 455 // This is required by googletest to print a readable output on test failures.
456 // This is declared here for use in gtest-based unit tests but is defined in 456 // This is declared here for use in gtest-based unit tests but is defined in
457 // the test_support_base target. Depend on that to use this in your unit test. 457 // the test_support_base target. Depend on that to use this in your unit test.
458 // This should not be used in production code - call ToString() instead. 458 // This should not be used in production code - call ToString() instead.
459 void PrintTo(const FilePath& path, std::ostream* out); 459 void PrintTo(const FilePath& path, std::ostream* out);
460 460
461 } // namespace base 461 } // namespace base
462 462
463 // Macros for string literal initialization of FilePath::CharType[], and for 463 // Macros for string literal initialization of FilePath::CharType[], and for
464 // using a FilePath::CharType[] in a printf-style format string. 464 // using a FilePath::CharType[] in a printf-style format string.
465 #if defined(OS_POSIX) 465 #if defined(OS_POSIX) || defined(OS_FUCHSIA)
466 #define FILE_PATH_LITERAL(x) x 466 #define FILE_PATH_LITERAL(x) x
467 #define PRFilePath "s" 467 #define PRFilePath "s"
468 #elif defined(OS_WIN) 468 #elif defined(OS_WIN)
469 #define FILE_PATH_LITERAL(x) L ## x 469 #define FILE_PATH_LITERAL(x) L ## x
470 #define PRFilePath "ls" 470 #define PRFilePath "ls"
471 #endif // OS_WIN 471 #endif // OS_WIN
472 472
473 // Provide a hash function so that hash_sets and maps can contain FilePath 473 // Provide a hash function so that hash_sets and maps can contain FilePath
474 // objects. 474 // objects.
475 namespace BASE_HASH_NAMESPACE { 475 namespace BASE_HASH_NAMESPACE {
476 476
477 template<> 477 template<>
478 struct hash<base::FilePath> { 478 struct hash<base::FilePath> {
479 size_t operator()(const base::FilePath& f) const { 479 size_t operator()(const base::FilePath& f) const {
480 return hash<base::FilePath::StringType>()(f.value()); 480 return hash<base::FilePath::StringType>()(f.value());
481 } 481 }
482 }; 482 };
483 483
484 } // namespace BASE_HASH_NAMESPACE 484 } // namespace BASE_HASH_NAMESPACE
485 485
486 #endif // BASE_FILES_FILE_PATH_H_ 486 #endif // BASE_FILES_FILE_PATH_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698