ZipLocalFileHeader::ZipLocalFileHeader(std::istream& inp, bool assumeHeaderRead, ParseCallback& callback): _forceZip64(false), _rawHeader(), _startPos(inp.tellg()), _endPos(-1), _fileName(), _lastModifiedAt(), _extraField(), _crc32(0), _compressedSize(0), _uncompressedSize(0) { poco_assert_dbg( (EXTRA_FIELD_POS+EXTRA_FIELD_LENGTH) == FULLHEADER_SIZE); if (assumeHeaderRead) _startPos -= ZipCommon::HEADER_SIZE; parse(inp, assumeHeaderRead); bool ok = callback.handleZipEntry(inp, *this); if (ok) { if (searchCRCAndSizesAfterData()) { char header[ZipCommon::HEADER_SIZE]={'\x00', '\x00', '\x00', '\x00'}; inp.read(header, ZipCommon::HEADER_SIZE); if (std::memcmp(header, ZipDataInfo64::HEADER, sizeof(header)) == 0) { ZipDataInfo64 nfo(inp, true); setCRC(nfo.getCRC32()); setCompressedSize(nfo.getCompressedSize()); setUncompressedSize(nfo.getUncompressedSize()); } else { ZipDataInfo nfo(inp, true); setCRC(nfo.getCRC32()); setCompressedSize(nfo.getCompressedSize()); setUncompressedSize(nfo.getUncompressedSize()); } } } else { poco_assert_dbg(!searchCRCAndSizesAfterData()); ZipUtil::sync(inp); } _endPos = _startPos + getHeaderSize() + _compressedSize; // exclude the data block! }
void ZipLocalFileHeader::setFileName(const std::string& fileName, bool isDirectory) { poco_assert (!fileName.empty()); Poco::Path aPath(fileName); if (isDirectory) { aPath.makeDirectory(); setCRC(0); setCompressedSize(0); setUncompressedSize(0); setCompressionMethod(ZipCommon::CM_STORE); setCompressionLevel(ZipCommon::CL_NORMAL); } else { aPath.makeFile(); } _fileName = aPath.toString(Poco::Path::PATH_UNIX); if (_fileName[0] == '/') _fileName = _fileName.substr(1); if (isDirectory) { poco_assert_dbg (_fileName[_fileName.size()-1] == '/'); } setFileNameLength(static_cast<Poco::UInt16>(_fileName.size())); }
TEST(PELCO_CRC, TST_ROTATE_ST2) { PelcoCamera::PELCO_MSG msg = PelcoCamera::PELCO_MSG(); begin(msg); setNumStation(msg, 1); setRotateSpeed(msg, -0x3F, 0); setCRC(msg); EXPECT_EQ(msg, msg6); }
void PelcoCamera::rotateContinues(const double pan, const double tilt) { PelcoCamera::PELCO_MSG msg = PelcoCamera::PELCO_MSG(); begin(msg); setNumStation(msg, m_num); const int pan_pelco = fabs(pan) > 1.0 ? (fabs(pan) > 0 ? 0xFF : -0xFF) : fabs(pan) * 0x3F; const int tilt_pelco = fabs(tilt) > 1.0 ? (fabs(tilt) > 0 ? 0xFF : -0xFF) : fabs(tilt) * 0x3F; setRotateSpeed(msg, pan_pelco, tilt_pelco); setCRC(msg); send(msg); }