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 // We're trying to transition away from paths as wstrings into using | 5 // We're trying to transition away from paths as wstrings into using |
6 // FilePath objects. This file contains declarations of deprecated | 6 // FilePath objects. This file contains declarations of deprecated |
7 // functions. By hiding them here rather in the main header, we hope | 7 // functions. By hiding them here rather in the main header, we hope |
8 // to discourage callers. | 8 // to discourage callers. |
9 | 9 |
10 // See file_util.h for documentation on all functions that don't have | 10 // See file_util.h for documentation on all functions that don't have |
11 // documentation here. | 11 // documentation here. |
12 | 12 |
13 #ifndef BASE_FILE_UTIL_DEPRECATED_H_ | 13 #ifndef BASE_FILE_UTIL_DEPRECATED_H_ |
14 #define BASE_FILE_UTIL_DEPRECATED_H_ | 14 #define BASE_FILE_UTIL_DEPRECATED_H_ |
15 | 15 |
16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
17 | 17 |
| 18 |
18 namespace file_util { | 19 namespace file_util { |
19 | 20 |
20 // Use FilePath::Extension instead. | 21 // Use the FilePath versions instead. |
21 FilePath::StringType GetFileExtensionFromPath(const FilePath& path); | |
22 std::wstring GetFileExtensionFromPath(const std::wstring& path); | |
23 | |
24 bool AbsolutePath(std::wstring* path); | |
25 | |
26 // Use FilePath::InsertBeforeExtension. | |
27 void InsertBeforeExtension(FilePath* path, const FilePath::StringType& suffix); | |
28 | |
29 bool Delete(const std::wstring& path, bool recursive); | |
30 bool CopyDirectory(const std::wstring& from_path, const std::wstring& to_path, | |
31 bool recursive); | |
32 bool ReadFileToString(const std::wstring& path, std::string* contents); | |
33 FILE* OpenFile(const std::string& filename, const char* mode); | 22 FILE* OpenFile(const std::string& filename, const char* mode); |
34 FILE* OpenFile(const std::wstring& filename, const char* mode); | 23 FILE* OpenFile(const std::wstring& filename, const char* mode); |
35 int ReadFile(const std::wstring& filename, char* data, int size); | |
36 int WriteFile(const std::wstring& filename, const char* data, int size); | |
37 | 24 |
38 // Functions successfully deprecated on non-Windows, but Win-specific | 25 // We've successfully deprecated most of these functions on non-Windows |
39 // callers remain. | 26 // platforms. |
40 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
| 28 |
41 // Use FilePath::DirName instead. | 29 // Use FilePath::DirName instead. |
42 void UpOneDirectory(std::wstring* dir); | 30 void UpOneDirectory(std::wstring* dir); |
43 // Use FilePath::DirName instead. | 31 // Use FilePath::DirName instead. |
44 void UpOneDirectoryOrEmpty(std::wstring* dir); | 32 void UpOneDirectoryOrEmpty(std::wstring* dir); |
45 | 33 |
46 // Use FilePath::BaseName instead. | 34 // Use FilePath::BaseName instead. |
47 std::wstring GetFilenameFromPath(const std::wstring& path); | 35 std::wstring GetFilenameFromPath(const std::wstring& path); |
48 | 36 |
49 // Returns the directory component of a path, without the trailing | 37 // Returns the directory component of a path, without the trailing |
50 // path separator, or an empty string on error. The function does not | 38 // path separator, or an empty string on error. The function does not |
51 // check for the existence of the path, so if it is passed a directory | 39 // check for the existence of the path, so if it is passed a directory |
52 // without the trailing \, it will interpret the last component of the | 40 // without the trailing \, it will interpret the last component of the |
53 // path as a file and chomp it. This does not support relative paths. | 41 // path as a file and chomp it. This does not support relative paths. |
54 // Examples: | 42 // Examples: |
55 // path == "C:\pics\jojo.jpg", returns "C:\pics" | 43 // path == "C:\pics\jojo.jpg", returns "C:\pics" |
56 // path == "C:\Windows\system32\", returns "C:\Windows\system32" | 44 // path == "C:\Windows\system32\", returns "C:\Windows\system32" |
57 // path == "C:\Windows\system32", returns "C:\Windows" | 45 // path == "C:\Windows\system32", returns "C:\Windows" |
58 // Deprecated. Use FilePath's DirName() instead. | 46 // Deprecated. Use FilePath's DirName() instead. |
59 std::wstring GetDirectoryFromPath(const std::wstring& path); | 47 std::wstring GetDirectoryFromPath(const std::wstring& path); |
60 | 48 |
61 // Appends new_ending to path, adding a separator between the two if necessary. | 49 // Appends new_ending to path, adding a separator between the two if necessary. |
62 void AppendToPath(std::wstring* path, const std::wstring& new_ending); | 50 void AppendToPath(std::wstring* path, const std::wstring& new_ending); |
63 #endif | 51 |
| 52 // Use FilePath::Extension instead. |
| 53 FilePath::StringType GetFileExtensionFromPath(const FilePath& path); |
| 54 std::wstring GetFileExtensionFromPath(const std::wstring& path); |
| 55 |
| 56 bool AbsolutePath(std::wstring* path); |
| 57 |
| 58 // Use FilePath::InsertBeforeExtension. |
| 59 void InsertBeforeExtension(FilePath* path, const FilePath::StringType& suffix); |
| 60 |
| 61 // Use version that takes a FilePath. |
| 62 bool Delete(const std::wstring& path, bool recursive); |
| 63 bool CopyDirectory(const std::wstring& from_path, const std::wstring& to_path, |
| 64 bool recursive); |
| 65 bool ReadFileToString(const std::wstring& path, std::string* contents); |
| 66 int ReadFile(const std::wstring& filename, char* data, int size); |
| 67 int WriteFile(const std::wstring& filename, const char* data, int size); |
| 68 |
| 69 #endif // OS_WIN |
64 | 70 |
65 } | 71 } |
66 | 72 |
67 #endif // BASE_FILE_UTIL_DEPRECATED_H_ | 73 #endif // BASE_FILE_UTIL_DEPRECATED_H_ |
OLD | NEW |