blob: 322c25aa72d5f3a9be536cd7c6854391645ba6ce [file] [log] [blame]
Elliott Hughes76160052012-12-12 16:31:20 -08001/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "base/unix_file/null_file.h"
18#include <errno.h>
19
20namespace unix_file {
21
22NullFile::NullFile() {
23}
24
25NullFile::~NullFile() {
26}
27
28int NullFile::Close() {
29 return 0;
30}
31
32int NullFile::Flush() {
33 return 0;
34}
35
Ian Rogers6a3c1fc2014-10-31 00:33:20 -070036int64_t NullFile::Read(char* buf ATTRIBUTE_UNUSED, int64_t byte_count ATTRIBUTE_UNUSED,
37 int64_t offset) const {
Elliott Hughes76160052012-12-12 16:31:20 -080038 if (offset < 0) {
39 return -EINVAL;
40 }
41 return 0;
42}
43
44int NullFile::SetLength(int64_t new_length) {
45 if (new_length < 0) {
46 return -EINVAL;
47 }
48 return 0;
49}
50
51int64_t NullFile::GetLength() const {
52 return 0;
53}
54
Ian Rogers6a3c1fc2014-10-31 00:33:20 -070055int64_t NullFile::Write(const char* buf ATTRIBUTE_UNUSED, int64_t byte_count ATTRIBUTE_UNUSED,
56 int64_t offset) {
Elliott Hughes76160052012-12-12 16:31:20 -080057 if (offset < 0) {
58 return -EINVAL;
59 }
60 return byte_count;
61}
62
63} // namespace unix_file