Lines 59-79
public:
Link Here
|
59 |
} |
59 |
} |
60 |
|
60 |
|
61 |
int valid() { |
61 |
int valid() { |
62 |
return (_io && _handle); |
62 |
return (_io && _handle) ? 1 : 0; |
63 |
} |
63 |
} |
64 |
|
64 |
|
65 |
int read(void *buffer, size_t size, size_t count) { |
65 |
int read(void *buffer, size_t size, size_t count) { |
66 |
if(substream) return substream->read(buffer, size, count); |
|
|
67 |
return _io->read_proc(buffer, (unsigned)size, (unsigned)count, _handle); |
66 |
return _io->read_proc(buffer, (unsigned)size, (unsigned)count, _handle); |
68 |
} |
67 |
} |
69 |
|
68 |
|
70 |
int seek(INT64 offset, int origin) { |
69 |
int seek(INT64 offset, int origin) { |
71 |
if(substream) return substream->seek(offset, origin); |
|
|
72 |
return _io->seek_proc(_handle, (long)offset, origin); |
70 |
return _io->seek_proc(_handle, (long)offset, origin); |
73 |
} |
71 |
} |
74 |
|
72 |
|
75 |
INT64 tell() { |
73 |
INT64 tell() { |
76 |
if(substream) return substream->tell(); |
|
|
77 |
return _io->tell_proc(_handle); |
74 |
return _io->tell_proc(_handle); |
78 |
} |
75 |
} |
79 |
|
76 |
|
Lines 83-101
public:
Link Here
|
83 |
|
80 |
|
84 |
int get_char() { |
81 |
int get_char() { |
85 |
int c = 0; |
82 |
int c = 0; |
86 |
if(substream) return substream->get_char(); |
83 |
if (!_io->read_proc(&c, 1, 1, _handle)) { |
87 |
if(!_io->read_proc(&c, 1, 1, _handle)) return -1; |
84 |
return -1; |
|
|
85 |
} |
88 |
return c; |
86 |
return c; |
89 |
} |
87 |
} |
90 |
|
88 |
|
91 |
char* gets(char *buffer, int length) { |
89 |
char* gets(char *buffer, int length) { |
92 |
if (substream) return substream->gets(buffer, length); |
|
|
93 |
memset(buffer, 0, length); |
90 |
memset(buffer, 0, length); |
94 |
for(int i = 0; i < length; i++) { |
91 |
for(int i = 0; i < length; i++) { |
95 |
if(!_io->read_proc(&buffer[i], 1, 1, _handle)) |
92 |
if (!_io->read_proc(&buffer[i], 1, 1, _handle)) { |
96 |
return NULL; |
93 |
return NULL; |
97 |
if(buffer[i] == 0x0A) |
94 |
} |
|
|
95 |
if (buffer[i] == 0x0A) { |
98 |
break; |
96 |
break; |
|
|
97 |
} |
99 |
} |
98 |
} |
100 |
return buffer; |
99 |
return buffer; |
101 |
} |
100 |
} |
Lines 104-110
public:
Link Here
|
104 |
std::string buffer; |
103 |
std::string buffer; |
105 |
char element = 0; |
104 |
char element = 0; |
106 |
bool bDone = false; |
105 |
bool bDone = false; |
107 |
if(substream) return substream->scanf_one(fmt,val); |
|
|
108 |
do { |
106 |
do { |
109 |
if(_io->read_proc(&element, 1, 1, _handle) == 1) { |
107 |
if(_io->read_proc(&element, 1, 1, _handle) == 1) { |
110 |
switch(element) { |
108 |
switch(element) { |
Lines 127-133
public:
Link Here
|
127 |
} |
125 |
} |
128 |
|
126 |
|
129 |
int eof() { |
127 |
int eof() { |
130 |
if(substream) return substream->eof(); |
|
|
131 |
return (_io->tell_proc(_handle) >= _eof); |
128 |
return (_io->tell_proc(_handle) >= _eof); |
132 |
} |
129 |
} |
133 |
|
130 |
|