mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
move zip_file_header to header
This commit is contained in:
parent
2e3d027604
commit
1b32f46639
|
@ -66,25 +66,11 @@ inline void write_int(std::ostream &stream, T value)
|
|||
stream.write(reinterpret_cast<char *>(&value), sizeof(T));
|
||||
}
|
||||
|
||||
struct zip_file_header
|
||||
{
|
||||
std::uint16_t version = 20;
|
||||
std::uint16_t flags = 0;
|
||||
std::uint16_t compression_type = 8;
|
||||
std::uint16_t stamp_date,stamp_time = 0;
|
||||
std::uint32_t crc = 0;
|
||||
std::uint32_t compressed_size = 0;
|
||||
std::uint32_t uncompressed_size = 0;
|
||||
std::string filename;
|
||||
std::string comment;
|
||||
std::vector<std::uint8_t> extra;
|
||||
std::uint32_t header_offset = 0; // local header offset
|
||||
|
||||
zip_file_header()
|
||||
zip_file_header::zip_file_header()
|
||||
{
|
||||
}
|
||||
|
||||
bool read(std::istream& istream,const bool global)
|
||||
bool zip_file_header::read(std::istream& istream,const bool global)
|
||||
{
|
||||
auto sig = read_int<std::uint32_t>(istream);
|
||||
|
||||
|
@ -144,8 +130,9 @@ struct zip_file_header
|
|||
return true;
|
||||
}
|
||||
|
||||
void Write(std::ostream& ostream,const bool global) const
|
||||
{if(global){
|
||||
void zip_file_header::Write(std::ostream& ostream,const bool global) const
|
||||
{
|
||||
if(global){
|
||||
write_int(ostream,(unsigned int)0x02014b50); // header sig
|
||||
write_int(ostream,(unsigned short)00);} // version made by
|
||||
else write_int(ostream,(unsigned int)0x04034b50);
|
||||
|
@ -165,8 +152,8 @@ struct zip_file_header
|
|||
write_int(ostream,(unsigned short)0); // internal file
|
||||
write_int(ostream,(unsigned int)0); // ext final
|
||||
write_int(ostream,(unsigned int)header_offset);} // rel offset
|
||||
for(unsigned int i=0;i<filename.length();i++) write_int(ostream,filename.c_str()[i]);}
|
||||
};
|
||||
for(unsigned int i=0;i<filename.length();i++) write_int(ostream,filename.c_str()[i]);
|
||||
}
|
||||
|
||||
class ZipStreambufDecompress:public std::streambuf
|
||||
{
|
||||
|
|
|
@ -43,7 +43,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|||
namespace xlnt {
|
||||
namespace detail {
|
||||
|
||||
struct zip_file_header;
|
||||
struct zip_file_header
|
||||
{
|
||||
std::uint16_t version = 20;
|
||||
std::uint16_t flags = 0;
|
||||
std::uint16_t compression_type = 8;
|
||||
std::uint16_t stamp_date, stamp_time = 0;
|
||||
std::uint32_t crc = 0;
|
||||
std::uint32_t compressed_size = 0;
|
||||
std::uint32_t uncompressed_size = 0;
|
||||
std::string filename;
|
||||
std::string comment;
|
||||
std::vector<std::uint8_t> extra;
|
||||
std::uint32_t header_offset = 0;
|
||||
|
||||
zip_file_header();
|
||||
|
||||
bool read(std::istream& istream, const bool global);
|
||||
void Write(std::ostream& ostream, const bool global) const;
|
||||
};
|
||||
|
||||
class ZipFileWriter
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user