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

Side by Side Diff: base/file_util.h

Issue 17243: Add implementations of various extension related methods (derived from file_u... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « base/file_path_unittest.cc ('k') | no next file » | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-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 // This file contains utility functions for dealing with the local 5 // This file contains utility functions for dealing with the local
6 // filesystem. 6 // filesystem.
7 7
8 #ifndef BASE_FILE_UTIL_H_ 8 #ifndef BASE_FILE_UTIL_H_
9 #define BASE_FILE_UTIL_H_ 9 #define BASE_FILE_UTIL_H_
10 10
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 // Strips the filename component from the end of 'path'. If path ends with a 69 // Strips the filename component from the end of 'path'. If path ends with a
70 // separator, then just drop the separator. 70 // separator, then just drop the separator.
71 // Deprecated. Use FilePath::DirName instead. 71 // Deprecated. Use FilePath::DirName instead.
72 void TrimFilename(std::wstring* path); 72 void TrimFilename(std::wstring* path);
73 73
74 // Returns the filename portion of 'path', without any leading \'s or /'s. 74 // Returns the filename portion of 'path', without any leading \'s or /'s.
75 // Deprecated. Use FilePath::BaseName instead. 75 // Deprecated. Use FilePath::BaseName instead.
76 std::wstring GetFilenameFromPath(const std::wstring& path); 76 std::wstring GetFilenameFromPath(const std::wstring& path);
77 77
78 // Returns "jpg" for path "C:\pics\jojo.jpg", or an empty string if 78 // Deprecated compatibility function. Use FilePath::Extension.
79 // the file has no extension.
80 FilePath::StringType GetFileExtensionFromPath(const FilePath& path); 79 FilePath::StringType GetFileExtensionFromPath(const FilePath& path);
81 // Deprecated temporary compatibility function. 80 // Deprecated temporary compatibility function.
82 std::wstring GetFileExtensionFromPath(const std::wstring& path); 81 std::wstring GetFileExtensionFromPath(const std::wstring& path);
83 82
84 // Returns 'jojo' for path "C:\pics\jojo.jpg". 83 // Deprecated compatibility function. Use FilePath::RemoveExtension.
85 std::wstring GetFilenameWithoutExtensionFromPath(const std::wstring& path); 84 std::wstring GetFilenameWithoutExtensionFromPath(const std::wstring& path);
86 85
87 // Returns the directory component of a path, without the trailing 86 // Returns the directory component of a path, without the trailing
88 // path separator, or an empty string on error. The function does not 87 // path separator, or an empty string on error. The function does not
89 // check for the existence of the path, so if it is passed a directory 88 // check for the existence of the path, so if it is passed a directory
90 // without the trailing \, it will interpret the last component of the 89 // without the trailing \, it will interpret the last component of the
91 // path as a file and chomp it. This does not support relative paths. 90 // path as a file and chomp it. This does not support relative paths.
92 // Examples: 91 // Examples:
93 // path == "C:\pics\jojo.jpg", returns "C:\pics" 92 // path == "C:\pics\jojo.jpg", returns "C:\pics"
94 // path == "C:\Windows\system32\", returns "C:\Windows\system32" 93 // path == "C:\Windows\system32\", returns "C:\Windows\system32"
95 // path == "C:\Windows\system32", returns "C:\Windows" 94 // path == "C:\Windows\system32", returns "C:\Windows"
96 std::wstring GetDirectoryFromPath(const std::wstring& path); 95 std::wstring GetDirectoryFromPath(const std::wstring& path);
97 96
98 // Appends new_ending to path, adding a separator between the two if necessary. 97 // Appends new_ending to path, adding a separator between the two if necessary.
99 void AppendToPath(std::wstring* path, const std::wstring& new_ending); 98 void AppendToPath(std::wstring* path, const std::wstring& new_ending);
100 99
101 // Convert provided relative path into an absolute path. Returns false on 100 // Convert provided relative path into an absolute path. Returns false on
102 // error. 101 // error.
103 bool AbsolutePath(FilePath* path); 102 bool AbsolutePath(FilePath* path);
104 // Deprecated temporary compatibility function. 103 // Deprecated temporary compatibility function.
105 bool AbsolutePath(std::wstring* path); 104 bool AbsolutePath(std::wstring* path);
106 105
107 // Inserts |suffix| after the file name portion of |path| but before the 106 // Returns true if this FilePath represents a parent dir of |other|. Both
108 // extension. 107 // paths are normalized before doing the comparison, but neither |this| nor
109 // Examples: 108 // |other| are modified.
110 // path == "C:\pics\jojo.jpg" suffix == " (1)", returns "C:\pics\jojo (1).jpg" 109 bool PathContains(const FilePath& path, const FilePath& other);
111 // path == "jojo.jpg" suffix == " (1)", returns "jojo (1).jpg" 110
112 // path == "C:\pics\jojo" suffix == " (1)", returns "C:\pics\jojo (1)" 111 // Deprecated compatibility function. Use FilePath::InsertBeforeExtension.
113 // path == "C:\pics.old\jojo" suffix == " (1)", returns "C:\pics.old\jojo (1)"
114 void InsertBeforeExtension(FilePath* path, const FilePath::StringType& suffix); 112 void InsertBeforeExtension(FilePath* path, const FilePath::StringType& suffix);
115 113
116 // Replaces the extension of |file_name| with |extension|. If |file_name| 114 // Deprecated compatibility function. Use FilePath::ReplaceExtension.
117 // does not have an extension, them |extension| is added. If |extension| is
118 // empty, then the extension is removed from |file_name|.
119 void ReplaceExtension(FilePath* file_name, 115 void ReplaceExtension(FilePath* file_name,
120 const FilePath::StringType& extension); 116 const FilePath::StringType& extension);
121 117
122 #if defined(OS_WIN) 118 #if defined(OS_WIN)
123 // Deprecated temporary compatibility functions. 119 // Deprecated temporary compatibility functions.
124 void InsertBeforeExtension(std::wstring* path, const std::wstring& suffix); 120 void InsertBeforeExtension(std::wstring* path, const std::wstring& suffix);
125 void ReplaceExtension(std::wstring* file_name, const std::wstring& extension); 121 void ReplaceExtension(std::wstring* file_name, const std::wstring& extension);
126 #endif 122 #endif
127 123
128 // Replaces characters in 'file_name' that are illegal for file names with 124 // Replaces characters in 'file_name' that are illegal for file names with
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 461
466 // Renames a file using the SHFileOperation API to ensure that the target file 462 // Renames a file using the SHFileOperation API to ensure that the target file
467 // gets the correct default security descriptor in the new path. 463 // gets the correct default security descriptor in the new path.
468 bool RenameFileAndResetSecurityDescriptor( 464 bool RenameFileAndResetSecurityDescriptor(
469 const FilePath& source_file_path, 465 const FilePath& source_file_path,
470 const FilePath& target_file_path); 466 const FilePath& target_file_path);
471 467
472 } // namespace file_util 468 } // namespace file_util
473 469
474 #endif // BASE_FILE_UTIL_H_ 470 #endif // BASE_FILE_UTIL_H_
OLDNEW
« no previous file with comments | « base/file_path_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698