1// Aseprite FLIC Library
2// Copyright (c) 2015 David Capello
3//
4// This file is released under the terms of the MIT license.
5// Read LICENSE.txt for more information.
6
7#include "flic.h"
8
9namespace flic {
10
11StdioFileInterface::StdioFileInterface(FILE* file)
12 : m_file(file)
13 , m_ok(true)
14{
15}
16
17bool StdioFileInterface::ok() const
18{
19 return m_ok;
20}
21
22size_t StdioFileInterface::tell()
23{
24 return ftell(m_file);
25}
26
27void StdioFileInterface::seek(size_t absPos)
28{
29 fseek(m_file, absPos, SEEK_SET);
30}
31
32uint8_t StdioFileInterface::read8()
33{
34 int value = fgetc(m_file);
35 if (value != EOF)
36 return value;
37
38 m_ok = false;
39 return 0;
40}
41
42void StdioFileInterface::write8(uint8_t value)
43{
44 fputc(value, m_file);
45}
46
47} // namespace flic
48