This repository has been archived by the owner on Oct 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
XTBFileStream.h
73 lines (61 loc) · 1.77 KB
/
XTBFileStream.h
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
// XTBFileStream.h
// XTBook
//
// Created by Kawada Tomoaki on 5/28/11.
// Copyright 2011 Nexhawks. All rights reserved.
//
#pragma once
#include <stdio.h>
#include "XTBStream.h"
#include "platform.h"
#ifndef XTB_USE_SYSIO
#if EV_PLATFORM_WIN32
#define XTB_USE_SYSIO 1
#define XTB_USE_WIN32IO 1
#else
#define XTB_USE_SYSIO 0
#endif
#endif
class XTBFileStream: public XTBStream{
#if XTB_USE_SYSIO
int m_handle;
#else
FILE *m_stdStream;
#endif
bool m_isReadable;
bool m_isWritable;
bool m_isSeekable;
bool m_shouldCloseStream;
XTBOffset m_position;
public:
#if XTB_USE_SYSIO
XTBFileStream(int, bool shouldCloseStream,
bool isReadable,
bool isWritable,
bool isSeekable);
#else
XTBFileStream(FILE *, bool shouldCloseStream,
bool isReadable,
bool isWritable,
bool isSeekable);
#endif
virtual ~XTBFileStream();
static XTBStream *streamForReadingAtPath(const XTBSysString&, bool detectArchive);
static XTBFileStream *streamForReadingAtPath(const XTBSysString&);
static XTBFileStream *streamForWritingAtPath(const XTBSysString&);
static XTBFileStream *streamForUpdatingAtPath(const XTBSysString&);
static XTBFileStream *streamWithStandardError();
static XTBFileStream *streamWithStandardInput();
static XTBFileStream *streamWithStandardOutput();
virtual bool shouldCloseStream() const{return m_shouldCloseStream;}
virtual size_t readToBuffer(void *, size_t maxLength);
virtual size_t writeBuffer(const void *, size_t maxLength);
virtual void seekToOffset(XTBOffset);
virtual void seekToEndOfStream();
virtual XTBOffset position() const;
virtual bool isReadable() const{return m_isReadable;}
virtual bool isWritable() const{return m_isWritable;}
virtual bool isSeekable() const{return m_isSeekable;}
virtual void synchronize();
};