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

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

Issue 863583002: Add FilePath::FinalExtension and RemoveFinalExtension (Closed) Base URL: https://chromium.googlesource.com/chromium/mini_chromium@master
Patch Set: simplify Created 5 years, 11 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 | « no previous file | base/files/file_path.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 2008 The Chromium Authors. All rights reserved. 1 // Copyright 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 // 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 140
141 // Null-terminated array of separators used to separate components in 141 // Null-terminated array of separators used to separate components in
142 // hierarchical paths. Each character in this array is a valid separator, 142 // hierarchical paths. Each character in this array is a valid separator,
143 // but kSeparators[0] is treated as the canonical separator and will be used 143 // but kSeparators[0] is treated as the canonical separator and will be used
144 // when composing pathnames. 144 // when composing pathnames.
145 static const CharType kSeparators[]; 145 static const CharType kSeparators[];
146 146
147 // A special path component meaning "this directory." 147 // A special path component meaning "this directory."
148 static const CharType kCurrentDirectory[]; 148 static const CharType kCurrentDirectory[];
149 149
150 // A special path component meaning "the parent directory."
151 static const CharType kParentDirectory[];
152
153 // The character used to identify a file extension.
154 static const CharType kExtensionSeparator;
155
150 FilePath(); 156 FilePath();
151 FilePath(const FilePath& that); 157 FilePath(const FilePath& that);
152 explicit FilePath(const StringType& path); 158 explicit FilePath(const StringType& path);
153 ~FilePath(); 159 ~FilePath();
154 FilePath& operator=(const FilePath& that); 160 FilePath& operator=(const FilePath& that);
155 161
156 bool operator==(const FilePath& that) const; 162 bool operator==(const FilePath& that) const;
157 163
158 bool operator!=(const FilePath& that) const; 164 bool operator!=(const FilePath& that) const;
159 165
(...skipping 17 matching lines...) Expand all
177 // kCurrentDirectory. If this object already refers to the root directory, 183 // kCurrentDirectory. If this object already refers to the root directory,
178 // returns a FilePath identifying the root directory. 184 // returns a FilePath identifying the root directory.
179 FilePath DirName() const WARN_UNUSED_RESULT; 185 FilePath DirName() const WARN_UNUSED_RESULT;
180 186
181 // Returns a FilePath corresponding to the last path component of this 187 // Returns a FilePath corresponding to the last path component of this
182 // object, either a file or a directory. If this object already refers to 188 // object, either a file or a directory. If this object already refers to
183 // the root directory, returns a FilePath identifying the root directory; 189 // the root directory, returns a FilePath identifying the root directory;
184 // this is the only situation in which BaseName will return an absolute path. 190 // this is the only situation in which BaseName will return an absolute path.
185 FilePath BaseName() const WARN_UNUSED_RESULT; 191 FilePath BaseName() const WARN_UNUSED_RESULT;
186 192
193 // Returns the path's file extension. This does not have a special case for
194 // common double extensions, so FinalExtension() of "foo.tar.gz" is simply
195 // ".gz". If there is no extension, "" will be returned.
196 StringType FinalExtension() const WARN_UNUSED_RESULT;
197
198 // Returns a FilePath with FinalExtension() removed.
199 FilePath RemoveFinalExtension() const WARN_UNUSED_RESULT;
200
187 // Returns a FilePath by appending a separator and the supplied path 201 // Returns a FilePath by appending a separator and the supplied path
188 // component to this object's path. Append takes care to avoid adding 202 // component to this object's path. Append takes care to avoid adding
189 // excessive separators if this object's path already ends with a separator. 203 // excessive separators if this object's path already ends with a separator.
190 // If this object's path is kCurrentDirectory, a new FilePath corresponding 204 // If this object's path is kCurrentDirectory, a new FilePath corresponding
191 // only to |component| is returned. |component| must be a relative path; 205 // only to |component| is returned. |component| must be a relative path;
192 // it is an error to pass an absolute path. 206 // it is an error to pass an absolute path.
193 FilePath Append(const StringType& component) const WARN_UNUSED_RESULT; 207 FilePath Append(const StringType& component) const WARN_UNUSED_RESULT;
194 FilePath Append(const FilePath& component) const WARN_UNUSED_RESULT; 208 FilePath Append(const FilePath& component) const WARN_UNUSED_RESULT;
195 209
196 // Returns true if this FilePath contains an absolute path. On Windows, an 210 // Returns true if this FilePath contains an absolute path. On Windows, an
(...skipping 24 matching lines...) Expand all
221 #define FILE_PATH_LITERAL(x) x 235 #define FILE_PATH_LITERAL(x) x
222 #define PRFilePath "s" 236 #define PRFilePath "s"
223 #define PRFilePathLiteral "%s" 237 #define PRFilePathLiteral "%s"
224 #elif defined(OS_WIN) 238 #elif defined(OS_WIN)
225 #define FILE_PATH_LITERAL(x) L ## x 239 #define FILE_PATH_LITERAL(x) L ## x
226 #define PRFilePath "ls" 240 #define PRFilePath "ls"
227 #define PRFilePathLiteral L"%ls" 241 #define PRFilePathLiteral L"%ls"
228 #endif // OS_WIN 242 #endif // OS_WIN
229 243
230 #endif // MINI_CHROMIUM_BASE_FILES_FILE_PATH_H_ 244 #endif // MINI_CHROMIUM_BASE_FILES_FILE_PATH_H_
OLDNEW
« no previous file with comments | « no previous file | base/files/file_path.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698