-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstdio.cpp
More file actions
47 lines (37 loc) · 746 Bytes
/
stdio.cpp
File metadata and controls
47 lines (37 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Aseprite TGA Library
// Copyright (C) 2020 Igara Studio S.A.
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#include "tga.h"
namespace tga {
StdioFileInterface::StdioFileInterface(FILE* file)
: m_file(file)
, m_ok(true)
{
}
bool StdioFileInterface::ok() const
{
return m_ok;
}
size_t StdioFileInterface::tell()
{
return ftell(m_file);
}
void StdioFileInterface::seek(size_t absPos)
{
fseek(m_file, (long)absPos, SEEK_SET);
}
uint8_t StdioFileInterface::read8()
{
int value = fgetc(m_file);
if (value != EOF)
return (uint8_t)value;
m_ok = false;
return 0;
}
void StdioFileInterface::write8(uint8_t value)
{
fputc(value, m_file);
}
} // namespace tga