Commit 3749db6a authored by thestig@chromium.org's avatar thestig@chromium.org

Cleanup: Remove remaining deprecated file_util functions.

BUG=24672
TEST=none

Review URL: http://codereview.chromium.org/9691059

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126749 0039d316-1c4b-4281-b951-d872f2087c98
parent 17b4fe7f
......@@ -101,7 +101,6 @@
'file_util.cc',
'file_util.h',
'file_util_android.cc',
'file_util_deprecated.h',
'file_util_linux.cc',
'file_util_mac.mm',
'file_util_posix.cc',
......
......@@ -380,20 +380,6 @@ bool MemoryMappedFile::MapFileToMemory(const FilePath& file_name) {
return MapFileToMemoryInternal();
}
// Deprecated functions ----------------------------------------------------
#if defined(OS_WIN)
FILE* OpenFile(const std::wstring& filename, const char* mode) {
return OpenFile(FilePath::FromWStringHack(filename), mode);
}
int ReadFile(const std::wstring& filename, char* data, int size) {
return ReadFile(FilePath::FromWStringHack(filename), data, size);
}
int WriteFile(const std::wstring& filename, const char* data, int size) {
return WriteFile(FilePath::FromWStringHack(filename), data, size);
}
#endif // OS_WIN
///////////////////////////////////////////////
// FileEnumerator
//
......
......@@ -640,10 +640,4 @@ BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type);
} // namespace file_util
#if defined(OS_WIN)
// Deprecated functions have been moved to this separate header file,
// which must be included last after all the above definitions.
#include "base/file_util_deprecated.h"
#endif
#endif // BASE_FILE_UTIL_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// We're trying to transition away from paths as wstrings into using
// FilePath objects. This file contains declarations of deprecated
// functions. By hiding them here rather in the main header, we hope
// to discourage callers.
// See file_util.h for documentation on all functions that don't have
// documentation here.
#ifndef BASE_FILE_UTIL_DEPRECATED_H_
#define BASE_FILE_UTIL_DEPRECATED_H_
#pragma once
#include "base/base_export.h"
#include "build/build_config.h"
// We've successfully deprecated all of these functions on non-Windows
// platforms.
#if !defined(OS_WIN)
#error Do not include on non-Windows platforms.
#endif
namespace file_util {
// Use the FilePath versions instead.
BASE_EXPORT FILE* OpenFile(const std::string& filename, const char* mode);
BASE_EXPORT FILE* OpenFile(const std::wstring& filename, const char* mode);
// Use version that takes a FilePath.
BASE_EXPORT int ReadFile(const std::wstring& filename, char* data, int size);
BASE_EXPORT int WriteFile(const std::wstring& filename,
const char* data, int size);
} // namespace file_util
#endif // BASE_FILE_UTIL_DEPRECATED_H_
......@@ -135,7 +135,7 @@ bool CreateOrderBlob(const FilePath& favorites_folder,
return true;
}
bool CreateUrlFile(const string16& file, const string16& url) {
bool CreateUrlFile(const FilePath& file, const string16& url) {
base::win::ScopedComPtr<IUniformResourceLocator> locator;
HRESULT result = locator.CreateInstance(CLSID_InternetShortcut, NULL,
CLSCTX_INPROC_SERVER);
......@@ -148,7 +148,7 @@ bool CreateUrlFile(const string16& file, const string16& url) {
result = locator->SetURL(url.c_str(), 0);
if (FAILED(result))
return false;
result = persist_file->Save(file.c_str(), TRUE);
result = persist_file->Save(file.value().c_str(), TRUE);
if (FAILED(result))
return false;
return true;
......@@ -353,30 +353,34 @@ class IEImporterTest : public ImporterTest {
TEST_F(IEImporterTest, IEImporter) {
// Sets up a favorites folder.
base::win::ScopedCOMInitializer com_init;
string16 path = temp_dir_.path().AppendASCII("Favorites").value();
CreateDirectory(path.c_str(), NULL);
CreateDirectory((path + L"\\SubFolder").c_str(), NULL);
CreateDirectory((path + L"\\Links").c_str(), NULL);
CreateDirectory((path + L"\\Links\\SubFolderOfLinks").c_str(), NULL);
CreateDirectory((path + L"\\\x0061").c_str(), NULL);
ASSERT_TRUE(CreateUrlFile(path + L"\\Google Home Page.url",
FilePath path = temp_dir_.path().AppendASCII("Favorites");
CreateDirectory(path.value().c_str(), NULL);
CreateDirectory(path.AppendASCII("SubFolder").value().c_str(), NULL);
FilePath links_path = path.AppendASCII("Links");
CreateDirectory(links_path.value().c_str(), NULL);
CreateDirectory(links_path.AppendASCII("SubFolderOfLinks").value().c_str(),
NULL);
CreateDirectory(path.AppendASCII("\x0061").value().c_str(), NULL);
ASSERT_TRUE(CreateUrlFile(path.AppendASCII("Google Home Page.url"),
L"http://www.google.com/"));
ASSERT_TRUE(CreateUrlFile(path + L"\\SubFolder\\Title.url",
ASSERT_TRUE(CreateUrlFile(path.AppendASCII("SubFolder\\Title.url"),
L"http://www.link.com/"));
ASSERT_TRUE(CreateUrlFile(path + L"\\SubFolder.url",
ASSERT_TRUE(CreateUrlFile(path.AppendASCII("SubFolder.url"),
L"http://www.subfolder.com/"));
ASSERT_TRUE(CreateUrlFile(path + L"\\TheLink.url",
ASSERT_TRUE(CreateUrlFile(path.AppendASCII("TheLink.url"),
L"http://www.links-thelink.com/"));
ASSERT_TRUE(CreateUrlFile(path + L"\\WithPortAndQuery.url",
ASSERT_TRUE(CreateUrlFile(path.AppendASCII("WithPortAndQuery.url"),
L"http://host:8080/cgi?q=query"));
ASSERT_TRUE(CreateUrlFile(path + L"\\\x0061\\\x4E2D\x6587.url",
L"http://chinese-title-favorite/"));
ASSERT_TRUE(CreateUrlFile(path + L"\\Links\\TheLink.url",
ASSERT_TRUE(CreateUrlFile(
path.AppendASCII("\x0061").Append(L"\x4E2D\x6587.url"),
L"http://chinese-title-favorite/"));
ASSERT_TRUE(CreateUrlFile(links_path.AppendASCII("TheLink.url"),
L"http://www.links-thelink.com/"));
ASSERT_TRUE(CreateUrlFile(path + L"\\Links\\SubFolderOfLinks\\SubLink.url",
L"http://www.links-sublink.com/"));
file_util::WriteFile(path + L"\\InvalidUrlFile.url", "x", 1);
file_util::WriteFile(path + L"\\PlainTextFile.txt", "x", 1);
ASSERT_TRUE(CreateUrlFile(
links_path.AppendASCII("SubFolderOfLinks").AppendASCII("SubLink.url"),
L"http://www.links-sublink.com/"));
file_util::WriteFile(path.AppendASCII("InvalidUrlFile.url"), "x", 1);
file_util::WriteFile(path.AppendASCII("PlainTextFile.txt"), "x", 1);
const char16* root_links[] = {
L"Links",
......@@ -432,16 +436,16 @@ TEST_F(IEImporterTest, IEImporter) {
TEST_F(IEImporterTest, IEImporterMalformedFavoritesRegistry) {
// Sets up a favorites folder.
base::win::ScopedCOMInitializer com_init;
string16 path = temp_dir_.path().AppendASCII("Favorites").value();
CreateDirectory(path.c_str(), NULL);
CreateDirectory((path + L"\\b").c_str(), NULL);
ASSERT_TRUE(CreateUrlFile(path + L"\\a.url",
FilePath path = temp_dir_.path().AppendASCII("Favorites");
CreateDirectory(path.value().c_str(), NULL);
CreateDirectory(path.AppendASCII("b").value().c_str(), NULL);
ASSERT_TRUE(CreateUrlFile(path.AppendASCII("a.url"),
L"http://www.google.com/0"));
ASSERT_TRUE(CreateUrlFile(path + L"\\b\\a.url",
ASSERT_TRUE(CreateUrlFile(path.AppendASCII("b").AppendASCII("a.url"),
L"http://www.google.com/1"));
ASSERT_TRUE(CreateUrlFile(path + L"\\b\\b.url",
ASSERT_TRUE(CreateUrlFile(path.AppendASCII("b").AppendASCII("b.url"),
L"http://www.google.com/2"));
ASSERT_TRUE(CreateUrlFile(path + L"\\c.url",
ASSERT_TRUE(CreateUrlFile(path.AppendASCII("c.url"),
L"http://www.google.com/3"));
struct BadBinaryData {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment