forked from pocoproject/poco
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathZipDataInfo.cpp
More file actions
93 lines (70 loc) · 2 KB
/
ZipDataInfo.cpp
File metadata and controls
93 lines (70 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//
// ZipDataInfo.cpp
//
// $Id: //poco/1.4/Zip/src/ZipDataInfo.cpp#1 $
//
// Library: Zip
// Package: Zip
// Module: ZipDataInfo
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Zip/ZipDataInfo.h"
#include <istream>
#include <cstring>
namespace Poco {
namespace Zip {
const char ZipDataInfo::HEADER[ZipCommon::HEADER_SIZE] = {'\x50', '\x4b', '\x07', '\x08'};
ZipDataInfo::ZipDataInfo():
_rawInfo(),
_valid(true)
{
std::memcpy(_rawInfo, HEADER, ZipCommon::HEADER_SIZE);
std::memset(_rawInfo+ZipCommon::HEADER_SIZE, 0, FULLHEADER_SIZE - ZipCommon::HEADER_SIZE);
_valid = true;
}
ZipDataInfo::ZipDataInfo(std::istream& in, bool assumeHeaderRead):
_rawInfo(),
_valid(false)
{
if (assumeHeaderRead)
std::memcpy(_rawInfo, HEADER, ZipCommon::HEADER_SIZE);
else
in.read(_rawInfo, ZipCommon::HEADER_SIZE);
poco_assert (std::memcmp(_rawInfo, HEADER, ZipCommon::HEADER_SIZE) == 0);
// now copy the rest of the header
in.read(_rawInfo+ZipCommon::HEADER_SIZE, FULLHEADER_SIZE - ZipCommon::HEADER_SIZE);
_valid = (!in.eof() && in.good());
}
ZipDataInfo::~ZipDataInfo()
{
}
const char ZipDataInfo64::HEADER[ZipCommon::HEADER_SIZE] = {'\x50', '\x4b', '\x07', '\x08'};
ZipDataInfo64::ZipDataInfo64():
_rawInfo(),
_valid(true)
{
std::memcpy(_rawInfo, HEADER, ZipCommon::HEADER_SIZE);
std::memset(_rawInfo+ZipCommon::HEADER_SIZE, 0, FULLHEADER_SIZE - ZipCommon::HEADER_SIZE);
_valid = true;
}
ZipDataInfo64::ZipDataInfo64(std::istream& in, bool assumeHeaderRead):
_rawInfo(),
_valid(false)
{
if (assumeHeaderRead)
std::memcpy(_rawInfo, HEADER, ZipCommon::HEADER_SIZE);
else
in.read(_rawInfo, ZipCommon::HEADER_SIZE);
poco_assert (std::memcmp(_rawInfo, HEADER, ZipCommon::HEADER_SIZE) == 0);
// now copy the rest of the header
in.read(_rawInfo+ZipCommon::HEADER_SIZE, FULLHEADER_SIZE - ZipCommon::HEADER_SIZE);
_valid = (!in.eof() && in.good());
}
ZipDataInfo64::~ZipDataInfo64()
{
}
} } // namespace Poco::Zip