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

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

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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
« no previous file with comments | « base/containers/hash_tables.h ('k') | base/files/file_path_watcher_linux.cc » ('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) 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // at all, making them safe to use without fear of blocking on I/O operations. 46 // at all, making them safe to use without fear of blocking on I/O operations.
47 // These methods do not function as mutators but instead return distinct 47 // These methods do not function as mutators but instead return distinct
48 // instances of FilePath objects, and are therefore safe to use on const 48 // instances of FilePath objects, and are therefore safe to use on const
49 // objects. The objects themselves are safe to share between threads. 49 // objects. The objects themselves are safe to share between threads.
50 // 50 //
51 // To aid in initialization of FilePath objects from string literals, a 51 // To aid in initialization of FilePath objects from string literals, a
52 // FILE_PATH_LITERAL macro is provided, which accounts for the difference 52 // FILE_PATH_LITERAL macro is provided, which accounts for the difference
53 // between char[]-based pathnames on POSIX systems and wchar_t[]-based 53 // between char[]-based pathnames on POSIX systems and wchar_t[]-based
54 // pathnames on Windows. 54 // pathnames on Windows.
55 // 55 //
56 // Paths can't contain NULs as a precaution agaist premature truncation. 56 // As a precaution against premature truncation, paths can't contain NULs.
57 // 57 //
58 // Because a FilePath object should not be instantiated at the global scope, 58 // Because a FilePath object should not be instantiated at the global scope,
59 // instead, use a FilePath::CharType[] and initialize it with 59 // instead, use a FilePath::CharType[] and initialize it with
60 // FILE_PATH_LITERAL. At runtime, a FilePath object can be created from the 60 // FILE_PATH_LITERAL. At runtime, a FilePath object can be created from the
61 // character array. Example: 61 // character array. Example:
62 // 62 //
63 // | const FilePath::CharType kLogFileName[] = FILE_PATH_LITERAL("log.txt"); 63 // | const FilePath::CharType kLogFileName[] = FILE_PATH_LITERAL("log.txt");
64 // | 64 // |
65 // | void Function() { 65 // | void Function() {
66 // | FilePath log_file_path(kLogFileName); 66 // | FilePath log_file_path(kLogFileName);
67 // | [...] 67 // | [...]
68 // | } 68 // | }
69 // 69 //
70 // WARNING: FilePaths should ALWAYS be displayed with LTR directionality, even 70 // WARNING: FilePaths should ALWAYS be displayed with LTR directionality, even
71 // when the UI language is RTL. This means you always need to pass filepaths 71 // when the UI language is RTL. This means you always need to pass filepaths
72 // through base::i18n::WrapPathWithLTRFormatting() before displaying it in the 72 // through base::i18n::WrapPathWithLTRFormatting() before displaying it in the
73 // RTL UI. 73 // RTL UI.
74 // 74 //
75 // This is a very common source of bugs, please try to keep this in mind. 75 // This is a very common source of bugs, please try to keep this in mind.
76 // 76 //
77 // ARCANE BITS OF PATH TRIVIA 77 // ARCANE BITS OF PATH TRIVIA
78 // 78 //
79 // - A double leading slash is actually part of the POSIX standard. Systems 79 // - A double leading slash is actually part of the POSIX standard. Systems
80 // are allowed to treat // as an alternate root, as Windows does for UNC 80 // are allowed to treat // as an alternate root, as Windows does for UNC
81 // (network share) paths. Most POSIX systems don't do anything special 81 // (network share) paths. Most POSIX systems don't do anything special
82 // with two leading slashes, but FilePath handles this case properly 82 // with two leading slashes, but FilePath handles this case properly
83 // in case it ever comes across such a system. FilePath needs this support 83 // in case it ever comes across such a system. FilePath needs this support
84 // for Windows UNC paths, anyway. 84 // for Windows UNC paths, anyway.
85 // References: 85 // References:
86 // The Open Group Base Specifications Issue 7, sections 3.266 ("Pathname") 86 // The Open Group Base Specifications Issue 7, sections 3.267 ("Pathname")
87 // and 4.12 ("Pathname Resolution"), available at: 87 // and 4.12 ("Pathname Resolution"), available at:
88 // http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag _03_266 88 // http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag _03_267
89 // http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag _04_12 89 // http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag _04_12
90 // 90 //
91 // - Windows treats c:\\ the same way it treats \\. This was intended to 91 // - Windows treats c:\\ the same way it treats \\. This was intended to
92 // allow older applications that require drive letters to support UNC paths 92 // allow older applications that require drive letters to support UNC paths
93 // like \\server\share\path, by permitting c:\\server\share\path as an 93 // like \\server\share\path, by permitting c:\\server\share\path as an
94 // equivalent. Since the OS treats these paths specially, FilePath needs 94 // equivalent. Since the OS treats these paths specially, FilePath needs
95 // to do the same. Since Windows can use either / or \ as the separator, 95 // to do the same. Since Windows can use either / or \ as the separator,
96 // FilePath treats c://, c:\\, //, and \\ all equivalently. 96 // FilePath treats c://, c:\\, //, and \\ all equivalently.
97 // Reference: 97 // Reference:
98 // The Old New Thing, "Why is a drive letter permitted in front of UNC 98 // The Old New Thing, "Why is a drive letter permitted in front of UNC
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 template<> 457 template<>
458 struct hash<base::FilePath> { 458 struct hash<base::FilePath> {
459 size_t operator()(const base::FilePath& f) const { 459 size_t operator()(const base::FilePath& f) const {
460 return hash<base::FilePath::StringType>()(f.value()); 460 return hash<base::FilePath::StringType>()(f.value());
461 } 461 }
462 }; 462 };
463 463
464 } // namespace BASE_HASH_NAMESPACE 464 } // namespace BASE_HASH_NAMESPACE
465 465
466 #endif // BASE_FILES_FILE_PATH_H_ 466 #endif // BASE_FILES_FILE_PATH_H_
OLDNEW
« no previous file with comments | « base/containers/hash_tables.h ('k') | base/files/file_path_watcher_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698