Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

RageFileDriverDeflate.h

Go to the documentation of this file.
00001 /* RageFileObjInflate - decompress streams compressed with "deflate" compression. */ 00002 00003 #ifndef RAGE_FILE_DRIVER_DEFLATE_H 00004 #define RAGE_FILE_DRIVER_DEFLATE_H 00005 00006 #include "RageFileBasic.h" 00007 00008 typedef struct z_stream_s z_stream; 00009 00010 class RageFileObjInflate: public RageFileObj 00011 { 00012 public: 00013 /* By default, pFile will not be freed. To implement GetFileSize(), the 00014 * container format must store the file size. */ 00015 RageFileObjInflate( RageFileBasic *pFile, int iUncompressedSize ); 00016 RageFileObjInflate( const RageFileObjInflate &cpy ); 00017 ~RageFileObjInflate(); 00018 int ReadInternal( void *pBuffer, size_t iBytes ); 00019 int WriteInternal( const void *pBuffer, size_t iBytes ) { SetError( "Not implemented" ); return -1; } 00020 int SeekInternal( int iOffset ); 00021 int GetFileSize() const { return m_iUncompressedSize; } 00022 RageFileBasic *Copy() const; 00023 00024 void DeleteFileWhenFinished() { m_bFileOwned = true; } 00025 00026 private: 00027 int m_iUncompressedSize; 00028 RageFileBasic *m_pFile; 00029 int m_iFilePos; 00030 bool m_bFileOwned; 00031 00032 z_stream *m_pInflate; 00033 enum { INBUFSIZE = 1024*4 }; 00034 char decomp_buf[INBUFSIZE], *decomp_buf_ptr; 00035 int decomp_buf_avail; 00036 }; 00037 00038 class RageFileObjDeflate: public RageFileObj 00039 { 00040 public: 00041 /* By default, pFile will not be freed. */ 00042 RageFileObjDeflate( RageFileBasic *pOutput ); 00043 ~RageFileObjDeflate(); 00044 00045 int GetFileSize() const { return m_pFile->GetFileSize(); } 00046 void DeleteFileWhenFinished() { m_bFileOwned = true; } 00047 00048 protected: 00049 int ReadInternal( void *pBuffer, size_t iBytes ) { SetError( "Not implemented" ); return -1; } 00050 int WriteInternal( const void *pBuffer, size_t iBytes ); 00051 int FlushInternal(); 00052 00053 RageFileBasic *m_pFile; 00054 z_stream *m_pDeflate; 00055 bool m_bFileOwned; 00056 }; 00057 00058 class RageFileObjGzip: public RageFileObjDeflate 00059 { 00060 public: 00061 RageFileObjGzip( RageFileBasic *pFile ); 00062 int Start(); 00063 int Finish(); 00064 00065 private: 00066 int m_iDataStartOffset; 00067 }; 00068 00069 RageFileBasic *GunzipFile( RageFileBasic &file, CString &sError, uint32_t *iCRC32 ); 00070 00071 #endif 00072 00073 /* 00074 * Copyright (c) 2003-2004 Glenn Maynard 00075 * All rights reserved. 00076 * 00077 * Permission is hereby granted, free of charge, to any person obtaining a 00078 * copy of this software and associated documentation files (the 00079 * "Software"), to deal in the Software without restriction, including 00080 * without limitation the rights to use, copy, modify, merge, publish, 00081 * distribute, and/or sell copies of the Software, and to permit persons to 00082 * whom the Software is furnished to do so, provided that the above 00083 * copyright notice(s) and this permission notice appear in all copies of 00084 * the Software and that both the above copyright notice(s) and this 00085 * permission notice appear in supporting documentation. 00086 * 00087 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00088 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00089 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 00090 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS 00091 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT 00092 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00093 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00094 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00095 * PERFORMANCE OF THIS SOFTWARE. 00096 */ 00097

Generated on Thu Jan 27 20:57:28 2005 for StepMania by doxygen 1.3.7