file_util_deprecated.h revision 21d179b334e59e9a3bfcaed4c4430bef1bc5759d
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#pragma once
16
17#include "build/build_config.h"
18
19// We've successfully deprecated all of these functions on non-Windows
20// platforms.
21
22#if defined(OS_WIN)
23
24namespace file_util {
25
26// Use the FilePath versions instead.
27FILE* OpenFile(const std::string& filename, const char* mode);
28FILE* OpenFile(const std::wstring& filename, const char* mode);
29
30// Use FilePath::BaseName instead.
31std::wstring GetFilenameFromPath(const std::wstring& path);
32
33// Returns the directory component of a path, without the trailing
34// path separator, or an empty string on error. The function does not
35// check for the existence of the path, so if it is passed a directory
36// without the trailing \, it will interpret the last component of the
37// path as a file and chomp it. This does not support relative paths.
38// Examples:
39// path == "C:\pics\jojo.jpg",     returns "C:\pics"
40// path == "C:\Windows\system32\", returns "C:\Windows\system32"
41// path == "C:\Windows\system32",  returns "C:\Windows"
42// Deprecated. Use FilePath's DirName() instead.
43std::wstring GetDirectoryFromPath(const std::wstring& path);
44
45// Appends new_ending to path, adding a separator between the two if necessary.
46void AppendToPath(std::wstring* path, const std::wstring& new_ending);
47
48// Use FilePath::Extension instead.
49FilePath::StringType GetFileExtensionFromPath(const FilePath& path);
50std::wstring GetFileExtensionFromPath(const std::wstring& path);
51
52// Use version that takes a FilePath.
53bool Delete(const std::wstring& path, bool recursive);
54bool CopyDirectory(const std::wstring& from_path, const std::wstring& to_path,
55                   bool recursive);
56int ReadFile(const std::wstring& filename, char* data, int size);
57int WriteFile(const std::wstring& filename, const char* data, int size);
58
59}
60
61#endif  // OS_WIN
62
63#endif  // BASE_FILE_UTIL_DEPRECATED_H_
64