diff options
Diffstat (limited to 'base/test/test_file_util_linux.cc')
-rw-r--r-- | base/test/test_file_util_linux.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/base/test/test_file_util_linux.cc b/base/test/test_file_util_linux.cc new file mode 100644 index 0000000..c2911ce --- /dev/null +++ b/base/test/test_file_util_linux.cc @@ -0,0 +1,27 @@ +// 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/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 FilePath& file) { + int fd = open(file.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 |