Visualization Library 2.1.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
ZippedFile.cpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #include <vlCore/ZippedFile.hpp>
33 #include <vlCore/CRC32CheckSum.hpp>
34 #include <vlCore/Log.hpp>
35 #include <vlCore/Say.hpp>
36 #include <stdio.h>
37 #include <algorithm>
38 #include "zlib.h"
39 
40 using namespace vl;
41 
42 bool vl::compress(const void* data, size_t size, std::vector<unsigned char>& out_data, int level)
43 {
44  const size_t CHUNK_SIZE = 128*1024;
45  int ret, flush;
46  unsigned have;
47  z_stream strm;
48  const unsigned char* in = (const unsigned char*)data;
49  unsigned char out[CHUNK_SIZE];
50 
51  strm.zalloc = Z_NULL;
52  strm.zfree = Z_NULL;
53  strm.opaque = Z_NULL;
54  ret = deflateInit(&strm, level);
55  if (ret != Z_OK)
56  return false;
57 
58  size_t avail = size;
59 
60  do
61  {
62  strm.avail_in = std::min(avail, CHUNK_SIZE);
63  avail -= strm.avail_in;
64  strm.next_in = (unsigned char*)in;
65  in += strm.avail_in;
66  flush = avail == 0 ? Z_FINISH : Z_NO_FLUSH;
67 
68  do
69  {
70  strm.avail_out = CHUNK_SIZE;
71  strm.next_out = out;
72 
73  ret = deflate(&strm, flush);
74  if(ret == Z_STREAM_ERROR)
75  {
76  deflateEnd(&strm);
77  return false;
78  }
79 
80  have = CHUNK_SIZE - strm.avail_out;
81  out_data.insert( out_data.end(), out, out+have );
82  } while (strm.avail_out == 0);
83 
84  VL_CHECK(strm.avail_in == 0);
85 
86  } while (flush != Z_FINISH);
87 
88  VL_CHECK(ret == Z_STREAM_END);
89 
90  deflateEnd(&strm);
91  return true;
92 }
93 
94 bool vl::decompress(const void* cdata, size_t csize, void* data_out)
95 {
96  const size_t CHUNK_SIZE = 128*1024;
97  int ret;
98  unsigned have;
99  z_stream strm;
100  unsigned char* in = (unsigned char*)cdata;
101  unsigned char out[CHUNK_SIZE];
102  char* out_ptr = (char*)data_out;
103 
104  strm.zalloc = Z_NULL;
105  strm.zfree = Z_NULL;
106  strm.opaque = Z_NULL;
107  strm.avail_in = 0;
108  strm.next_in = Z_NULL;
109  ret = inflateInit(&strm);
110  if (ret != Z_OK)
111  return false;
112 
113  size_t avail = csize;
114 
115  do
116  {
117  strm.avail_in = std::min(avail, CHUNK_SIZE);
118  if (strm.avail_in == 0)
119  break;
120  avail -= strm.avail_in;
121  strm.next_in = in;
122  in += strm.avail_in;
123 
124  do
125  {
126  strm.avail_out = CHUNK_SIZE;
127  strm.next_out = out;
128 
129  ret = inflate(&strm, Z_NO_FLUSH);
130  VL_CHECK(ret != Z_STREAM_ERROR);
131  switch (ret)
132  {
133  case Z_NEED_DICT:
134  case Z_DATA_ERROR:
135  case Z_MEM_ERROR:
136  inflateEnd(&strm);
137  return false;
138  }
139 
140  have = CHUNK_SIZE - strm.avail_out;
141  // data_out.insert( data_out.end(), out, out + have );
142  memcpy(out_ptr, out, have);
143  out_ptr += have;
144  }
145  while (strm.avail_out == 0);
146 
147  VL_CHECK(strm.avail_in == 0);
148 
149  } while (ret != Z_STREAM_END);
150 
151  inflateEnd(&strm);
152 
153  /*VL_CHECK(ret == Z_STREAM_END)*/
154  return ret == Z_STREAM_END;
155 }
156 
157 namespace
158 {
159 //-----------------------------------------------------------------------------
160  inline int zcompress(FILE *source, FILE *dest, int level)
161  {
162  const int CHUNK_SIZE = 128*1024;
163  int ret, flush;
164  unsigned have;
165  z_stream strm;
166  unsigned char in[CHUNK_SIZE];
167  unsigned char out[CHUNK_SIZE];
168 
169  strm.zalloc = Z_NULL;
170  strm.zfree = Z_NULL;
171  strm.opaque = Z_NULL;
172  ret = deflateInit(&strm, level);
173  if (ret != Z_OK)
174  return ret;
175 
176  do
177  {
178  strm.avail_in = (uInt)fread(in, 1, CHUNK_SIZE, source);
179  if (ferror(source))
180  {
181  deflateEnd(&strm);
182  return Z_ERRNO;
183  }
184  flush = feof(source) ? Z_FINISH : Z_NO_FLUSH;
185  strm.next_in = in;
186 
187  do
188  {
189  strm.avail_out = CHUNK_SIZE;
190  strm.next_out = out;
191 
192  ret = deflate(&strm, flush);
193  VL_CHECK(ret != Z_STREAM_ERROR);
194 
195  have = CHUNK_SIZE - strm.avail_out;
196  if (fwrite(out, 1, have, dest) != have || ferror(dest))
197  {
198  deflateEnd(&strm);
199  return Z_ERRNO;
200  }
201 
202  } while (strm.avail_out == 0);
203 
204  VL_CHECK(strm.avail_in == 0);
205 
206  } while (flush != Z_FINISH);
207 
208  VL_CHECK(ret == Z_STREAM_END);
209 
210  (void)deflateEnd(&strm);
211  return Z_OK;
212  }
213 //-----------------------------------------------------------------------------
214  inline int zdecompress(FILE *source, FILE *dest)
215  {
216  const int CHUNK_SIZE = 128*1024;
217  int ret;
218  unsigned have;
219  z_stream strm;
220  unsigned char in[CHUNK_SIZE];
221  unsigned char out[CHUNK_SIZE];
222 
223  strm.zalloc = Z_NULL;
224  strm.zfree = Z_NULL;
225  strm.opaque = Z_NULL;
226  strm.avail_in = 0;
227  strm.next_in = Z_NULL;
228  ret = inflateInit(&strm);
229  if (ret != Z_OK)
230  return ret;
231 
232  do
233  {
234  strm.avail_in = (uInt)fread(in, 1, CHUNK_SIZE, source);
235  if (ferror(source))
236  {
237  inflateEnd(&strm);
238  return Z_ERRNO;
239  }
240  if (strm.avail_in == 0)
241  break;
242  strm.next_in = in;
243 
244  do
245  {
246  strm.avail_out = CHUNK_SIZE;
247  strm.next_out = out;
248 
249  ret = inflate(&strm, Z_NO_FLUSH);
250  VL_CHECK(ret != Z_STREAM_ERROR);
251  switch (ret)
252  {
253  case Z_NEED_DICT:
254  ret = Z_DATA_ERROR;
255  case Z_DATA_ERROR:
256  case Z_MEM_ERROR:
257  inflateEnd(&strm);
258  return ret;
259  }
260 
261  have = CHUNK_SIZE - strm.avail_out;
262  if (fwrite(out, 1, have, dest) != have || ferror(dest))
263  {
264  inflateEnd(&strm);
265  return Z_ERRNO;
266  }
267  }
268  while (strm.avail_out == 0);
269 
270  VL_CHECK(strm.avail_in == 0);
271 
272  } while (ret != Z_STREAM_END);
273 
274  inflateEnd(&strm);
275  return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
276  }
277 //-----------------------------------------------------------------------------
278  inline int zdecompress(VirtualFile *source, char *dest, unsigned int bytes_to_read)
279  {
280  const unsigned int CHUNK_SIZE = 128*1024;
281  int ret;
282  unsigned have;
283  z_stream strm;
284  unsigned char in[CHUNK_SIZE];
285  unsigned char out[CHUNK_SIZE];
286 
287  strm.zalloc = Z_NULL;
288  strm.zfree = Z_NULL;
289  strm.opaque = Z_NULL;
290  strm.avail_in = 0;
291  strm.next_in = Z_NULL;
292 
293  ret = inflateInit2(&strm, -15);
294  if (ret != Z_OK)
295  return ret;
296 
297  do
298  {
299  unsigned int byte_count = CHUNK_SIZE < bytes_to_read ? CHUNK_SIZE : bytes_to_read;
300  strm.avail_in = (uInt)source->read(in, byte_count);
301  bytes_to_read -= strm.avail_in;
302 
303  if (strm.avail_in == 0)
304  break;
305  strm.next_in = in;
306 
307  do
308  {
309  strm.avail_out = CHUNK_SIZE;
310  strm.next_out = out;
311 
312  ret = inflate(&strm, Z_NO_FLUSH);
313  VL_CHECK(ret != Z_STREAM_ERROR);
314  switch (ret)
315  {
316  case Z_NEED_DICT:
317  ret = Z_DATA_ERROR;
318  case Z_DATA_ERROR:
319  case Z_MEM_ERROR:
320  inflateEnd(&strm);
321  return ret;
322  }
323 
324  have = CHUNK_SIZE - strm.avail_out;
325  memcpy(dest, out, have);
326  dest += have;
327  }
328  while (strm.avail_out == 0);
329 
330  VL_CHECK(strm.avail_in == 0);
331 
332  } while (ret != Z_STREAM_END);
333 
334  inflateEnd(&strm);
335  return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
336  }
337 }
338 //-----------------------------------------------------------------------------
339 // ZippedFile
340 //-----------------------------------------------------------------------------
342 {
343  mReadBytes = -1;
344  mZStream = new z_stream_s;
345  memset(mZStream, 0, sizeof(z_stream_s));
346 }
347 //-----------------------------------------------------------------------------
349 {
350  close();
351  mReadBytes = -1;
352  delete mZStream; mZStream = NULL;
353 }
354 //-----------------------------------------------------------------------------
356 //-----------------------------------------------------------------------------
358 //-----------------------------------------------------------------------------
360 //-----------------------------------------------------------------------------
361 bool ZippedFile::exists() const
362 {
364 }
365 //-----------------------------------------------------------------------------
367 {
368  if ( zippedFileInfo()->versionNeeded() > 20 )
369  {
370  Log::error("ZippedFile::open(): unsupported archive version.\n");
371  return false;
372  }
373 
374  /*if ( zippedFileInfo()->generalPurposeFlag() & 1 )
375  {
376  Log::error("ZippedFile::extract(): encription not supported.\n");
377  return false;
378  }*/
379 
380  if ( zippedFileInfo()->compressionMethod() != 8 && zippedFileInfo()->compressionMethod() != 0 )
381  {
382  Log::error("ZippedFile::open(): unsupported compression method.\n");
383  return false;
384  }
385 
386  if ( isOpen() )
387  {
388  Log::error("ZippedFile::open(): file already open.\n");
389  return false;
390  }
391 
392  if ( mode != OM_ReadOnly )
393  {
394  Log::error("ZippedFile::open(): only OM_ReadOnly mode is supported.\n");
395  return false;
396  }
397 
398  if ( !zippedFileInfo()->sourceZipFile() )
399  {
400  Log::error("ZippedFile::open(): no source zip stream defined.\n");
401  return false;
402  }
403 
404  if ( zippedFileInfo()->sourceZipFile()->isOpen() )
405  {
406  Log::error("ZippedFile::open(): source zip stream is already open. Only one ZippedFile at a time can read from the same source.\n");
407  return false;
408  }
409 
410  if ( !zippedFileInfo()->sourceZipFile()->open(mode) )
411  {
412  Log::error("ZippedFile::open(): could not open source zip stream.\n");
413  return false;
414  }
415 
416  if ( !zippedFileInfo()->sourceZipFile()->seekSet( zippedFileInfo()->zippedFileOffset() ) )
417  {
418  Log::error("ZippedFile::open(): error seeking beginning of compressed file.\n");
420  return false;
421  }
422 
423  /* inflate state */
424  mZStream->zalloc = Z_NULL;
425  mZStream->zfree = Z_NULL;
426  mZStream->opaque = Z_NULL;
427  mZStream->avail_in = 0;
428  mZStream->next_in = Z_NULL;
429  if ( zippedFileInfo()->compressionMethod() == 8 && inflateInit2(mZStream, -15) != Z_OK )
430  {
432  return false;
433  }
434 
435  mReadBytes = 0;
437  mUncompressedBuffer.clear();
438 
439  return true;
440 }
441 //-----------------------------------------------------------------------------
442 bool ZippedFile::isOpen() const { return mReadBytes != -1; }
443 //-----------------------------------------------------------------------------
445 {
446  if ( mZStream->next_in != Z_NULL )
447  inflateEnd(mZStream);
448  memset(mZStream, 0, sizeof(z_stream_s));
449  mReadBytes = -1;
450  if (zippedFileInfo() && zippedFileInfo()->sourceZipFile())
453  mUncompressedBuffer.clear();
454 }
455 //-----------------------------------------------------------------------------
456 long long ZippedFile::size() const
457 {
458  if ( mZippedFileInfo )
459  return mZippedFileInfo->uncompressedSize();
460  else
461  return 0;
462 }
463 //-----------------------------------------------------------------------------
465 {
466  close();
467  open(OM_ReadOnly);
468 }
469 //-----------------------------------------------------------------------------
471 {
472  if (pos<position())
473  resetStream();
474 
475  unsigned char buffer[CHUNK_SIZE];
476  long long remained = pos - position();
477  long long eat_bytes = remained < CHUNK_SIZE ? remained : CHUNK_SIZE;
478  while ( (remained -= read(buffer, eat_bytes)) )
479  eat_bytes = remained < CHUNK_SIZE ? remained : CHUNK_SIZE;
480 
481  return position() == pos;
482 }
483 //-----------------------------------------------------------------------------
484 long long ZippedFile::read_Implementation(void* buffer, long long bytes_to_read)
485 {
486  if ( bytes_to_read < 1 )
487  return 0;
488 
489  if (!isOpen())
490  return 0;
491 
492  if ( mReadBytes >= zippedFileInfo()->uncompressedSize() )
493  return 0;
494 
495  if ( zippedFileInfo()->compressionMethod() == 0 )
496  {
497  long long bytes = zippedFileInfo()->uncompressedSize() - mReadBytes;
498  bytes = bytes < bytes_to_read ? bytes : bytes_to_read;
499  long long read_bytes = zippedFileInfo()->sourceZipFile()->read(buffer, bytes);
500  mReadBytes += read_bytes;
501  return read_bytes;
502  }
503  else
504  if ( zippedFileInfo()->compressionMethod() == 8 )
505  {
506 
507  long long read_bytes = 0;
508 
509  if ( mUncompressedBuffer.empty() )
511 
512  do
513  {
514  long long bytes = bytes_to_read < (int)mUncompressedBuffer.size()-mUncompressedBufferPtr ? bytes_to_read : (int)mUncompressedBuffer.size()-mUncompressedBufferPtr;
515  // copy uncompressed data
517  if (bytes)
518  memcpy((char*)buffer+read_bytes, &mUncompressedBuffer[0]+mUncompressedBufferPtr, (size_t)bytes);
519 
520  mReadBytes += bytes;
521  read_bytes += bytes;
522  mUncompressedBufferPtr += (int)bytes;
523  bytes_to_read -= bytes;
524  // remove read data from the buffer
525  // mUncompressedBuffer.erase( mUncompressedBuffer.begin(), mUncompressedBuffer.begin() + (size_t)bytes );
527  {
528  mUncompressedBuffer.clear();
530  }
531 
532  } while( bytes_to_read && fillUncompressedBuffer() );
533 
534  return read_bytes;
535  }
536  else
537  return 0;
538 }
539 //-----------------------------------------------------------------------------
540 bool ZippedFile::extract(char* destination, bool check_sum)
541 {
542  ZippedFileInfo* zfile_info = zippedFileInfo();
543 
544  if ( zfile_info->mUncompressedSize == 0 )
545  return true;
546 
547  if (isOpen())
548  {
549  Log::error("ZippedFile::extract(): the file is already open.\n");
550  return false;
551  }
552 
553  if ( zfile_info->versionNeeded() > 20 )
554  {
555  Log::error("ZippedFile::extract(): unsupported archive version.\n");
556  return false;
557  }
558 
559  if ( zfile_info->generalPurposeFlag() & 1 )
560  {
561  Log::error("ZippedFile::extract(): encription not supported.\n");
562  return false;
563  }
564 
565  ref<VirtualFile> zip = zfile_info->sourceZipFile();
566 
567  if ( !zip )
568  {
569  Log::error("ZippedFile::extract(): no source zip stream defined.\n");
570  return false;
571  }
572 
573  if ( zip->isOpen() )
574  {
575  Log::error("ZippedFile::extract(): source zip stream is already open. Only one ZippedFile at a time can read from the same source.\n");
576  return false;
577  }
578 
579  if ( !zip->open(OM_ReadOnly) )
580  {
581  Log::error("ZippedFile::extract(): could not open source zip stream.\n");
582  return false;
583  }
584 
585  if ( !zip->seekSet( zfile_info->zippedFileOffset() ) )
586  {
587  Log::error("ZippedFile::extract(): not a seek-able zip stream.\n");
588  zip->close();
589  return false;
590  }
591 
592  switch(zfile_info->mCompressionMethod)
593  {
594  default:
595  Log::error("ZippedFile::extract(): unsupported compression method.\n");
596  break;
597  case 0: // store
598  case 8: // deflate 32K
599  {
600  if (zfile_info->mCompressionMethod == 8)
601  zdecompress( zip.get(), destination, zfile_info->mCompressedSize );
602  else
603  if (zfile_info->mCompressionMethod == 0)
604  zip->read( destination, zfile_info->mUncompressedSize );
605 
606  if (check_sum)
607  {
608  CRC32CheckSum checksum;
609  unsigned int crc = checksum.compute( destination, (int)zfile_info->mUncompressedSize );
610  // printf("crc = 0x%08x | 0x%08x -> %s\n", crc, zfile_info->mCRC32, zfile_info->mCRC32 == crc ? "MATCH" : "ERROR!");
611  VL_CHECK( zfile_info->mCRC32 == crc );
612  if ( zfile_info->mCRC32 != crc )
613  {
614  zip->close();
615  return false;
616  }
617  }
618  }
619  }
620 
621  zip->close();
622  return true;
623 }
624 //-----------------------------------------------------------------------------
626 {
628 
629  VL_CHECK( mUncompressedBuffer.empty() )
630 
632 
633  if (!isOpen())
634  return false;
635 
637  return false;
638 
639  int have = 0;
640  int ret = 0;
641 
642  unsigned int compressed_read_bytes = (int)(zippedFileInfo()->sourceZipFile()->position() - zippedFileInfo()->zippedFileOffset());
643 
644  int bytes_to_read = (unsigned)CHUNK_SIZE < (zippedFileInfo()->compressedSize() - compressed_read_bytes)?
645  (unsigned)CHUNK_SIZE : (zippedFileInfo()->compressedSize() - compressed_read_bytes);
646  mZStream->avail_in = (uInt)zippedFileInfo()->sourceZipFile()->read(mZipBufferIn, bytes_to_read);
647 
648  if (mZStream->avail_in == 0)
649  return false;
650  mZStream->next_in = mZipBufferIn;
651 
652  do
653  {
654  mZStream->avail_out = CHUNK_SIZE;
655  mZStream->next_out = mZipBufferOut;
656 
657  ret = inflate(mZStream, Z_NO_FLUSH);
658  VL_CHECK(ret != Z_STREAM_ERROR);
659  switch (ret)
660  {
661  case Z_NEED_DICT:
662  case Z_DATA_ERROR:
663  case Z_MEM_ERROR:
664  inflateEnd(mZStream);
665  memset(mZStream, 0, sizeof(z_stream_s));
666  Log::error("ZippedFile::read(): error reading zip stream.\n");
667  return false;
668  }
669 
670  have = CHUNK_SIZE - mZStream->avail_out;
671  if (!have)
672  break;
673  int start = (int)mUncompressedBuffer.size();
674  mUncompressedBuffer.resize(start + have);
675  memcpy(&mUncompressedBuffer[0] + start, mZipBufferOut, have);
676  }
677  while ( mZStream->avail_out == 0 );
678 
679  return true;
680 }
681 //-----------------------------------------------------------------------------
683 {
684  ref<ZippedFile> file = new ZippedFile;
685  file->operator=(*this);
686  return file;
687 }
688 //-----------------------------------------------------------------------------
long long read(void *buffer, long long byte_count)
Reads byte_count bytes from a file. Returns the number of bytes actually read.
Definition: VirtualFile.cpp:82
bool decompress(const void *cdata, size_t csize, void *data_out)
Definition: ZippedFile.cpp:94
unsigned int compute(const void *buf, int length)
Computes the a CRC32 checksum of a given buffer or VirtualFile.
const T * get() const
Definition: Object.hpp:128
An abstract class representing a file.
Definition: VirtualFile.hpp:60
Collects the information about a ZippedFile.
Definition: ZippedFile.hpp:46
unsigned char mZipBufferOut[CHUNK_SIZE]
Definition: ZippedFile.hpp:199
bool extract(char *destination, bool check_sum=true)
Definition: ZippedFile.cpp:540
virtual bool exists() const
This returns true if zippedFileInfo() has been properly set up but does not check the existence of th...
Definition: ZippedFile.cpp:361
unsigned short mCompressionMethod
Definition: ZippedFile.hpp:99
virtual bool isOpen() const =0
Returns true if the file has been opened.
static void error(const String &message)
Use this function to provide information about run-time errors: file not found, out of memory...
Definition: Log.cpp:165
ref< ZippedFileInfo > mZippedFileInfo
Definition: ZippedFile.hpp:194
virtual void close()=0
Closes the file.
bool compress(const void *data, size_t size, std::vector< unsigned char > &out, int level)
Definition: ZippedFile.cpp:42
Visualization Library main namespace.
z_stream_s * mZStream
Definition: ZippedFile.hpp:197
void setZippedFileInfo(ZippedFileInfo *info)
Definition: ZippedFile.cpp:359
unsigned int zippedFileOffset() const
Definition: ZippedFile.hpp:90
virtual ref< VirtualFile > clone() const
Creates a clone of this class instance.
Definition: ZippedFile.cpp:682
void resetStream()
Definition: ZippedFile.cpp:464
float min(float a, float b)
Definition: Vector2.hpp:308
unsigned char mZipBufferIn[CHUNK_SIZE]
Definition: ZippedFile.hpp:198
virtual bool open(EOpenMode mode)=0
Opens the file in the specified mode.
virtual bool seekSet_Implementation(long long)
Definition: ZippedFile.cpp:470
unsigned short generalPurposeFlag() const
Definition: ZippedFile.hpp:75
virtual long long size() const
Returns the size of the file in bytes.
Definition: ZippedFile.cpp:456
unsigned int compressedSize() const
Definition: ZippedFile.hpp:78
virtual bool open(EOpenMode mode)
Opens the file in the specified mode.
Definition: ZippedFile.cpp:366
unsigned int uncompressedSize() const
Definition: ZippedFile.hpp:79
#define NULL
Definition: OpenGLDefs.hpp:81
virtual long long read_Implementation(void *buffer, long long bytes_to_read)
Definition: ZippedFile.cpp:484
virtual void close()
Closes the file.
Definition: ZippedFile.cpp:444
bool seekSet(long long offset)
Changes the current read/write position of a file.
int mUncompressedBufferPtr
Definition: ZippedFile.hpp:201
virtual bool isOpen() const
Returns true if the file has been opened.
Definition: ZippedFile.cpp:442
const VirtualFile * sourceZipFile() const
Definition: ZippedFile.hpp:92
The ref<> class is used to reference-count an Object.
Definition: Object.hpp:55
long long position() const
Returns the current position in the file.
Definition: VirtualFile.cpp:98
virtual bool fillUncompressedBuffer()
Definition: ZippedFile.cpp:625
unsigned short versionNeeded() const
Definition: ZippedFile.hpp:74
std::vector< char > mUncompressedBuffer
Definition: ZippedFile.hpp:200
#define VL_CHECK(expr)
Definition: checks.hpp:73
long long mReadBytes
Definition: ZippedFile.hpp:195
unsigned int mCompressedSize
Definition: ZippedFile.hpp:101
unsigned int mCRC32
Definition: ZippedFile.hpp:100
unsigned int mUncompressedSize
Definition: ZippedFile.hpp:102
const ZippedFileInfo * zippedFileInfo() const
Definition: ZippedFile.cpp:355