diff options
author | Tim Barron <tjbarron@google.com> | 2020-12-29 00:23:52 +0000 |
---|---|---|
committer | Tim Barron <tjbarron@google.com> | 2021-01-05 19:03:14 +0000 |
commit | 59c2caa38fd8dca3760dad751f4f8e5de8be25f5 (patch) | |
tree | 28b5f15e8bbfb73eb7470bef37f554ea4f4847a7 /icing/file/filesystem.cc | |
parent | 282a5708af10879b12a09a59ad5bbfa253b1e92a (diff) | |
download | icing-59c2caa38fd8dca3760dad751f4f8e5de8be25f5.tar.gz |
Update Icing from upstream.
Change-Id: Iff50aebffb83529b0454e7c3a6dc6864e7a85f4a
Diffstat (limited to 'icing/file/filesystem.cc')
-rw-r--r-- | icing/file/filesystem.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/icing/file/filesystem.cc b/icing/file/filesystem.cc index 4a76c01..6a596f5 100644 --- a/icing/file/filesystem.cc +++ b/icing/file/filesystem.cc @@ -464,6 +464,20 @@ bool Filesystem::Write(const char* filename, const void* data, return success; } +bool Filesystem::CopyFile(const char* src, const char* dst) const { + ScopedFd src_fd(OpenForRead(src)); + ScopedFd dst_fd(OpenForWrite(dst)); + if (!src_fd.is_valid() || !dst_fd.is_valid()) { + return false; + } + uint64_t size = GetFileSize(*src_fd); + std::unique_ptr<uint8_t[]> buf = std::make_unique<uint8_t[]>(size); + if (!Read(*src_fd, buf.get(), size)) { + return false; + } + return Write(*dst_fd, buf.get(), size); +} + bool Filesystem::PWrite(int fd, off_t offset, const void* data, size_t data_size) const { size_t write_len = data_size; |