#include <CGBuffer.h>
Collaboration diagram for Datafile:

Public Member Functions | |
| void | Close () |
| Datafile () | |
| int | Open (const char *path) |
| int | Read () |
| void | Release () |
| void | Reset () |
| Datafile * | Retain () |
| ~Datafile () | |
Public Attributes | |
| MemoryBuffer * | data_buffer |
| unsigned long | data_size |
Private Attributes | |
| FILE * | file |
| int | ref_count |
|
|
Definition at line 154 of file CGBuffer.h. References data_buffer, data_size, file, and ref_count. 00154 : ref_count(1), file(NULL), data_buffer(NULL), data_size(0) 00155 { 00156 }
|
|
|
Definition at line 158 of file CGBuffer.h. References Reset(). 00159 {
00160 Reset();
00161 }
|
|
|
Definition at line 214 of file CGBuffer.h. References file. Referenced by CGBuffer::LoadJPEG(), and Reset(). 00215 {
00216 if (file) {
00217 fclose(file);
00218 file = NULL;
00219 }
00220 }
|
|
|
Definition at line 175 of file CGBuffer.h. References MemoryBuffer::Create(), data_buffer, data_size, DPRINTF, file, and Reset(). Referenced by CGBuffer::Open(). 00176 {
00177 file = fopen(path,"r");
00178 if (!file) {
00179 DPRINTF(0,"Datafile::Open() - Couldn't open %s\n", path);
00180 Reset();
00181 return 0;
00182 }
00183 fseek(file, 0, SEEK_END);
00184 data_size = ftell(file);
00185 data_buffer = MemoryBuffer::Create(data_size);
00186 if (!data_buffer) {
00187 DPRINTF(0,"Datafile::Open() - Couldn't allocate MemoryBuffer of size %d\n", data_size);
00188 Reset();
00189 return 0;
00190 }
00191 //DPRINTF(0,"Datafile::Open() - Successfully opened '%s' %d bytes\n", path, data_size);
00192 return 1;
00193 }
|
|
|
Definition at line 195 of file CGBuffer.h. References MemoryBuffer::data, data_buffer, data_size, DPRINTF, file, and Reset(). Referenced by CGBuffer::LoadJPEG(). 00196 {
00197 if ((file == NULL) || (data_buffer == NULL) || (data_size == 0)) {
00198 DPRINTF(0,"Datafile::Read() - No file open, file of zero size, or no valid MemoryBuffer\n");
00199 Reset();
00200 return 0;
00201 }
00202
00203 fseek(file, 0, SEEK_SET);
00204 if (fread((void*)data_buffer->data, 1, data_size, file) != data_size) {
00205 DPRINTF(0,"Datafile::Read() - Didn't read to finish?");
00206 Reset();
00207 return 0;
00208 }
00209
00210 //DPRINTF(0,"Datafile::Read() - Successfully read all %d bytes into buffer\n",data_size);
00211 return 1;
00212 }
|
|
|
Definition at line 169 of file CGBuffer.h. References ref_count. 00170 {
00171 if (--ref_count==0)
00172 delete this;
00173 }
|
|
|
Definition at line 222 of file CGBuffer.h. References Close(), data_buffer, and MemoryBuffer::Release(). Referenced by CGBuffer::Open(), Open(), Read(), CGBuffer::Render(), and ~Datafile(). 00223 {
00224 Close();
00225 if (data_buffer) {
00226 data_buffer->Release();
00227 data_buffer = NULL;
00228 }
00229 }
|
|
|
Definition at line 163 of file CGBuffer.h. References ref_count. 00164 {
00165 ++ref_count;
00166 return this;
00167 }
|
|
|
Definition at line 151 of file CGBuffer.h. Referenced by Datafile(), CGBuffer::LoadJPEG(), Open(), Read(), and Reset(). |
|
|
Definition at line 152 of file CGBuffer.h. Referenced by Datafile(), CGBuffer::LoadJPEG(), Open(), and Read(). |
|
|
Definition at line 148 of file CGBuffer.h. Referenced by Close(), Datafile(), Open(), and Read(). |
|
|
Definition at line 147 of file CGBuffer.h. Referenced by Datafile(), Release(), and Retain(). |
1.4.1