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