Home | History | Annotate | Download | only in unix_file
      1 /*
      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 
     20 namespace unix_file {
     21 
     22 NullFile::NullFile() {
     23 }
     24 
     25 NullFile::~NullFile() {
     26 }
     27 
     28 int NullFile::Close() {
     29   return 0;
     30 }
     31 
     32 int NullFile::Flush() {
     33   return 0;
     34 }
     35 
     36 int64_t NullFile::Read(char* buf, int64_t byte_count, int64_t offset) const {
     37   if (offset < 0) {
     38     return -EINVAL;
     39   }
     40   return 0;
     41 }
     42 
     43 int NullFile::SetLength(int64_t new_length) {
     44   if (new_length < 0) {
     45     return -EINVAL;
     46   }
     47   return 0;
     48 }
     49 
     50 int64_t NullFile::GetLength() const {
     51   return 0;
     52 }
     53 
     54 int64_t NullFile::Write(const char* buf, int64_t byte_count, int64_t offset) {
     55   if (offset < 0) {
     56     return -EINVAL;
     57   }
     58   return byte_count;
     59 }
     60 
     61 }  // namespace unix_file
     62