1/*
2 * Copyright 2011 Google Inc. All Rights Reserved.
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#ifndef SFNTLY_CPP_SRC_SFNTLY_PORT_FILE_INPUT_STREAM_H_
18#define SFNTLY_CPP_SRC_SFNTLY_PORT_FILE_INPUT_STREAM_H_
19
20#include <stdio.h>
21
22#include "sfntly/port/input_stream.h"
23
24namespace sfntly {
25
26class FileInputStream : public PushbackInputStream {
27 public:
28  FileInputStream();
29  virtual ~FileInputStream();
30
31  // InputStream methods
32  virtual int32_t Available();
33  virtual void Close();
34  virtual void Mark(int32_t readlimit);
35  virtual bool MarkSupported();
36  virtual int32_t Read();
37  virtual int32_t Read(ByteVector* b);
38  virtual int32_t Read(ByteVector* b, int32_t offset, int32_t length);
39  virtual void Reset();
40  virtual int64_t Skip(int64_t n);
41
42  // PushbackInputStream methods
43  virtual void Unread(ByteVector* b);
44  virtual void Unread(ByteVector* b, int32_t offset, int32_t length);
45
46  // Own methods
47  virtual bool Open(const char* file_path);
48
49 private:
50  FILE* file_;
51  size_t position_;
52  size_t length_;
53};
54
55}  // namespace sfntly
56
57#endif  // SFNTLY_CPP_SRC_SFNTLY_PORT_FILE_INPUT_STREAM_H_
58