pkalinnikov | 18c8614 | 2016-08-05 15:51:47 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Pavel Kalinnikov | d797063 | 2017-06-20 09:07:34 | [diff] [blame] | 5 | #include "components/url_pattern_index/copying_file_stream.h" |
pkalinnikov | 18c8614 | 2016-08-05 15:51:47 | [diff] [blame] | 6 | |
Pavel Kalinnikov | d797063 | 2017-06-20 09:07:34 | [diff] [blame] | 7 | namespace url_pattern_index { |
pkalinnikov | 18c8614 | 2016-08-05 15:51:47 | [diff] [blame] | 8 | |
| 9 | // CopyingFileInputStream ------------------------------------------------------ |
| 10 | |
| 11 | CopyingFileInputStream::~CopyingFileInputStream() = default; |
| 12 | |
| 13 | CopyingFileInputStream::CopyingFileInputStream(base::File file) |
| 14 | : file_(std::move(file)) {} |
| 15 | |
| 16 | int CopyingFileInputStream::Read(void* buffer, int size) { |
| 17 | return file_.ReadAtCurrentPosNoBestEffort(static_cast<char*>(buffer), size); |
| 18 | } |
| 19 | |
| 20 | // CopyingFileOutputStream ----------------------------------------------------- |
| 21 | CopyingFileOutputStream::~CopyingFileOutputStream() = default; |
| 22 | |
| 23 | CopyingFileOutputStream::CopyingFileOutputStream(base::File file) |
| 24 | : file_(std::move(file)) {} |
| 25 | |
| 26 | bool CopyingFileOutputStream::Write(const void* buffer, int size) { |
| 27 | return file_.WriteAtCurrentPos(static_cast<const char*>(buffer), size) == |
| 28 | size; |
| 29 | } |
| 30 | |
Pavel Kalinnikov | d797063 | 2017-06-20 09:07:34 | [diff] [blame] | 31 | } // namespace url_pattern_index |