diff options
author | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-25 23:10:46 +0000 |
---|---|---|
committer | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-25 23:10:46 +0000 |
commit | 60aac62ddf3cc40741a824cae25ab190005513be (patch) | |
tree | 0f55441604d8e4ee3693d0ce6b3e8e8d4dbe06cc /base/test_file_util_linux.cc | |
parent | da4e34b86c37f77dc7027fbc1fd599d319b69bd0 (diff) | |
download | chromium_src-60aac62ddf3cc40741a824cae25ab190005513be.zip chromium_src-60aac62ddf3cc40741a824cae25ab190005513be.tar.gz chromium_src-60aac62ddf3cc40741a824cae25ab190005513be.tar.bz2 |
Un-duplicate EvictFileFromSystemCache.
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
Diffstat (limited to 'base/test_file_util_linux.cc')
-rw-r--r-- | base/test_file_util_linux.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/base/test_file_util_linux.cc b/base/test_file_util_linux.cc new file mode 100644 index 0000000..421d182 --- /dev/null +++ b/base/test_file_util_linux.cc @@ -0,0 +1,28 @@ +// 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 |