blob: 7f6d6d1d838a705d3ae74e315c626f5c3e01340d [file] [log] [blame]
pkalinnikov18c86142016-08-05 15:51:471// 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 Kalinnikovd7970632017-06-20 09:07:345#include "components/url_pattern_index/copying_file_stream.h"
pkalinnikov18c86142016-08-05 15:51:476
Pavel Kalinnikovd7970632017-06-20 09:07:347namespace url_pattern_index {
pkalinnikov18c86142016-08-05 15:51:478
9// CopyingFileInputStream ------------------------------------------------------
10
11CopyingFileInputStream::~CopyingFileInputStream() = default;
12
13CopyingFileInputStream::CopyingFileInputStream(base::File file)
14 : file_(std::move(file)) {}
15
16int CopyingFileInputStream::Read(void* buffer, int size) {
17 return file_.ReadAtCurrentPosNoBestEffort(static_cast<char*>(buffer), size);
18}
19
20// CopyingFileOutputStream -----------------------------------------------------
21CopyingFileOutputStream::~CopyingFileOutputStream() = default;
22
23CopyingFileOutputStream::CopyingFileOutputStream(base::File file)
24 : file_(std::move(file)) {}
25
26bool CopyingFileOutputStream::Write(const void* buffer, int size) {
27 return file_.WriteAtCurrentPos(static_cast<const char*>(buffer), size) ==
28 size;
29}
30
Pavel Kalinnikovd7970632017-06-20 09:07:3431} // namespace url_pattern_index