
Change required for http://codereview.chromium.org/9639 . Review URL: http://codereview.chromium.org/12407 Patch from Pawel Hajdan Jr. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6006 0039d316-1c4b-4281-b951-d872f2087c98
29 lines
684 B
C++
29 lines
684 B
C++
// Copyright (c) 2008 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.
|
|
|
|
#include "base/test_file_util.h"
|
|
|
|
#include <fcntl.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/types.h>
|
|
|
|
#include "base/file_path.h"
|
|
|
|
namespace file_util {
|
|
|
|
bool EvictFileFromSystemCache(const wchar_t* file) {
|
|
FilePath fpath = FilePath::FromWStringHack(file);
|
|
int fd = open(fpath.value().c_str(), O_RDONLY);
|
|
if (fd < 0)
|
|
return false;
|
|
if (fdatasync(fd) != 0)
|
|
return false;
|
|
if (posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED) != 0)
|
|
return false;
|
|
close(fd);
|
|
return true;
|
|
}
|
|
|
|
} // namespace file_util
|