/src/IO_ZipArchiver/ZipExplorer.h
C Header | 68 lines | 50 code | 17 blank | 1 comment | 0 complexity | 315d92be468f3bb9a25692e439ea1728 MD5 | raw file
Possible License(s): AGPL-3.0, LGPL-2.1, LGPL-3.0, GPL-2.0
1#ifndef _ZIP_FILE_BROWSER_H_ 2#define _ZIP_FILE_BROWSER_H_ 3 4#include "ZipStructures.h" 5#include <Core_EndianAbstractor.h> 6#include <fstream> 7 8#ifdef _MSC_VER 9#if _MSC_VER < 1600 10#include <Core_pstdint.h> 11#endif //_MSC_VER < 1600 12#endif // _MSC_VER 13 14class ZipExplorer 15{ 16 std::fstream stream; 17 EndianAbstractor endian_abstractor; 18 unsigned int central_directory_location; 19 20 ZipCentralDirectoryStructure current_file; 21 int nextfile_pos; //negative if uninitialized; 22 unsigned int current_file_index; 23 24 bool FindCentralDirectory(); 25 bool FindCentralDirectory64(); 26 27 28 //Data from EndOfCentralDirectory 29#ifdef INT64_MAX 30 uint64_t total_entries_in_CD; 31 uint64_t offset_start_CD_wrt_start_disk_number; 32#else 33 uint32_t total_entries_in_CD; 34 uint32_t offset_start_CD_wrt_start_disk_number; 35#endif 36 37public: 38 ZipExplorer() 39 : 40 endian_abstractor(true) 41 { 42 } 43 44 unsigned int GetCurrentFileIndex(); 45 unsigned int GetFileCount(); 46 47 bool SeekToFirstFile(); 48 bool NextFile(); 49 50 unsigned int CurrentReadFilenameOnly(char * dest, unsigned int buffer_size); 51 unsigned int CurrentReadDataParamsOnly(unsigned int & out_compressed_size, unsigned int & out_uncompressed_size, unsigned int & out_compression); 52 53 bool HasReadCurrentHeader(); 54 void ReadCurrentFileHeader(char * filename = 0, unsigned int filename_buffer_size = 0, 55 void * extra_field = 0, unsigned int extra_buffer_size = 0, 56 char * file_comment = 0, unsigned int comment_buffer_size = 0); 57 58 unsigned int GetFileDataOffset(); 59 60 unsigned int CurrentReadData(void * dest, unsigned int buffer_size, unsigned int data_offset, unsigned int uncompressed_length); 61 62 void Open(const char * filename); 63 void Close(); 64 65 bool FindFile(const char * filename, bool case_sensitive); 66}; 67 68#endif