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#ifndef BASE_TEST_TEST_FILE_UTIL_H_ 6#define BASE_TEST_TEST_FILE_UTIL_H_ 7#pragma once 8 9// File utility functions used only by tests. 10 11#include <string> 12 13class FilePath; 14 15namespace file_util { 16 17// Wrapper over file_util::Delete. On Windows repeatedly invokes Delete in case 18// of failure to workaround Windows file locking semantics. Returns true on 19// success. 20bool DieFileDie(const FilePath& file, bool recurse); 21 22// Clear a specific file from the system cache. After this call, trying 23// to access this file will result in a cold load from the hard drive. 24bool EvictFileFromSystemCache(const FilePath& file); 25 26// Like CopyFileNoCache but recursively copies all files and subdirectories 27// in the given input directory to the output directory. Any files in the 28// destination that already exist will be overwritten. 29// 30// Returns true on success. False means there was some error copying, so the 31// state of the destination is unknown. 32bool CopyRecursiveDirNoCache(const FilePath& source_dir, 33 const FilePath& dest_dir); 34 35#if defined(OS_WIN) 36// Returns true if the volume supports Alternate Data Streams. 37bool VolumeSupportsADS(const FilePath& path); 38 39// Returns true if the ZoneIdentifier is correctly set to "Internet" (3). 40// Note that this function must be called from the same process as 41// the one that set the zone identifier. I.e. don't use it in UI/automation 42// based tests. 43bool HasInternetZoneIdentifier(const FilePath& full_path); 44#endif // defined(OS_WIN) 45 46// In general it's not reliable to convert a FilePath to a wstring and we use 47// string16 elsewhere for Unicode strings, but in tests it is frequently 48// convenient to be able to compare paths to literals like L"foobar". 49std::wstring FilePathAsWString(const FilePath& path); 50FilePath WStringAsFilePath(const std::wstring& path); 51 52} // namespace file_util 53 54#endif // BASE_TEST_TEST_FILE_UTIL_H_ 55