| 52 | bool FileExists(const std::string& path) { return std::ifstream(path.c_str()).good(); } |
| 53 | |
| 54 | Status PurgeLocalFileFromOsCache(const std::string& path) { |
| 55 | #if defined(POSIX_FADV_WILLNEED) |
| 56 | int fd = open(path.c_str(), O_WRONLY); |
| 57 | if (fd < 0) { |
| 58 | return IOErrorFromErrno(errno, "open on ", path, |
| 59 | " to clear from cache did not succeed."); |
| 60 | } |
| 61 | int err = posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED); |
| 62 | if (err != 0) { |
| 63 | return IOErrorFromErrno(err, "fadvise on ", path, |
| 64 | " to clear from cache did not succeed"); |
| 65 | } |
| 66 | err = close(fd); |
| 67 | if (err == 0) { |
| 68 | return Status::OK(); |
| 69 | } |
| 70 | return IOErrorFromErrno(err, "close on ", path, " to clear from cache did not succeed"); |
| 71 | #else |
| 72 | return Status::NotImplemented("posix_fadvise is not implemented on this machine"); |
| 73 | #endif |
| 74 | } |
| 75 | |
| 76 | Status ZeroMemoryMap(MemoryMappedFile* file) { |
| 77 | constexpr int64_t kBufferSize = 512; |
nothing calls this directly
no test coverage detected