1 | /** |
---|
2 | * Licensed to the Apache Software Foundation (ASF) under one |
---|
3 | * or more contributor license agreements. See the NOTICE file |
---|
4 | * distributed with this work for additional information |
---|
5 | * regarding copyright ownership. The ASF licenses this file |
---|
6 | * to you under the Apache License, Version 2.0 (the |
---|
7 | * "License"); you may not use this file except in compliance |
---|
8 | * with the License. You may obtain a copy of the License at |
---|
9 | * |
---|
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
11 | * |
---|
12 | * Unless required by applicable law or agreed to in writing, software |
---|
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
15 | * See the License for the specific language governing permissions and |
---|
16 | * limitations under the License. |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef FILESTREAM_HH_ |
---|
20 | #define FILESTREAM_HH_ |
---|
21 | |
---|
22 | #include <stdio.h> |
---|
23 | #include <stdint.h> |
---|
24 | #include <string> |
---|
25 | #include "recordio.hh" |
---|
26 | |
---|
27 | namespace hadoop { |
---|
28 | |
---|
29 | class FileInStream : public InStream { |
---|
30 | public: |
---|
31 | FileInStream(); |
---|
32 | bool open(const std::string& name); |
---|
33 | ssize_t read(void *buf, size_t buflen); |
---|
34 | bool skip(size_t nbytes); |
---|
35 | bool close(); |
---|
36 | virtual ~FileInStream(); |
---|
37 | private: |
---|
38 | FILE *mFile; |
---|
39 | }; |
---|
40 | |
---|
41 | |
---|
42 | class FileOutStream: public OutStream { |
---|
43 | public: |
---|
44 | FileOutStream(); |
---|
45 | bool open(const std::string& name, bool overwrite); |
---|
46 | ssize_t write(const void* buf, size_t len); |
---|
47 | bool advance(size_t nbytes); |
---|
48 | bool close(); |
---|
49 | virtual ~FileOutStream(); |
---|
50 | private: |
---|
51 | FILE *mFile; |
---|
52 | }; |
---|
53 | |
---|
54 | }; // end namespace |
---|
55 | #endif /*FILESTREAM_HH_*/ |
---|