void ZipLocalFileHeader::parse(std::istream& inp, bool assumeHeaderRead) { if (!assumeHeaderRead) { inp.read(_rawHeader, ZipCommon::HEADER_SIZE); } else { std::memcpy(_rawHeader, HEADER, ZipCommon::HEADER_SIZE); } poco_assert (std::memcmp(_rawHeader, HEADER, ZipCommon::HEADER_SIZE) == 0); // read the rest of the header inp.read(_rawHeader + ZipCommon::HEADER_SIZE, FULLHEADER_SIZE - ZipCommon::HEADER_SIZE); poco_assert (_rawHeader[VERSION_POS + 1]>= ZipCommon::HS_FAT && _rawHeader[VERSION_POS + 1] < ZipCommon::HS_UNUSED); poco_assert (getMajorVersionNumber() <= 2); poco_assert (ZipUtil::get16BitValue(_rawHeader, COMPR_METHOD_POS) < ZipCommon::CM_UNUSED); parseDateTime(); Poco::UInt16 len = getFileNameLength(); Poco::Buffer<char> buf(len); inp.read(buf.begin(), len); _fileName = std::string(buf.begin(), len); if (hasExtraField()) { len = getExtraFieldLength(); Poco::Buffer<char> xtra(len); inp.read(xtra.begin(), len); _extraField = std::string(xtra.begin(), len); } if (!searchCRCAndSizesAfterData()) { _crc32 = getCRCFromHeader(); _compressedSize = getCompressedSizeFromHeader(); _uncompressedSize = getUncompressedSizeFromHeader(); } }
void ZipLocalFileHeader::parse(std::istream& inp, bool assumeHeaderRead) { if (!assumeHeaderRead) { inp.read(_rawHeader, ZipCommon::HEADER_SIZE); } else { std::memcpy(_rawHeader, HEADER, ZipCommon::HEADER_SIZE); } poco_assert (std::memcmp(_rawHeader, HEADER, ZipCommon::HEADER_SIZE) == 0); // read the rest of the header inp.read(_rawHeader + ZipCommon::HEADER_SIZE, FULLHEADER_SIZE - ZipCommon::HEADER_SIZE); poco_assert (_rawHeader[VERSION_POS + 1]>= ZipCommon::HS_FAT && _rawHeader[VERSION_POS + 1] < ZipCommon::HS_UNUSED); poco_assert (getMajorVersionNumber() <= 4); // Allow for Zip64 version 4.5 poco_assert (ZipUtil::get16BitValue(_rawHeader, COMPR_METHOD_POS) < ZipCommon::CM_UNUSED); parseDateTime(); Poco::UInt16 len = getFileNameLength(); Poco::Buffer<char> buf(len); inp.read(buf.begin(), len); _fileName = std::string(buf.begin(), len); if (!searchCRCAndSizesAfterData()) { _crc32 = getCRCFromHeader(); _compressedSize = getCompressedSizeFromHeader(); _uncompressedSize = getUncompressedSizeFromHeader(); } if (hasExtraField()) { len = getExtraFieldLength(); Poco::Buffer<char> xtra(len); inp.read(xtra.begin(), len); _extraField = std::string(xtra.begin(), len); char* ptr = xtra.begin(); while (ptr <= xtra.begin() + len - 4) { Poco::UInt16 id = ZipUtil::get16BitValue(ptr, 0); ptr +=2; Poco::UInt16 size = ZipUtil::get16BitValue(ptr, 0); ptr += 2; if (id == ZipCommon::ZIP64_EXTRA_ID) { poco_assert(size >= 8); if (getUncompressedSizeFromHeader() == ZipCommon::ZIP64_MAGIC) { setUncompressedSize(ZipUtil::get64BitValue(ptr, 0)); size -= 8; ptr += 8; } if (size >= 8 && getCompressedSizeFromHeader() == ZipCommon::ZIP64_MAGIC) { setCompressedSize(ZipUtil::get64BitValue(ptr, 0)); size -= 8; ptr += 8; } } else { ptr += size; } } } }
/** Return total size of a list, including size of all nodes */ static size_t list_xtra_all(xtra_f *xtra, void const *v) { size_t rv = 0; sdp_list_t const *l; for (l = v; l; l = l->l_next) { rv += STRUCT_ALIGN(rv); rv += xtra(l); } return rv; }
QVector<double> QxrdAcquisitionExtraInputsChannel::readChannel() { QxrdAcquisitionExtraInputsPtr xtra(m_ExtraInputs); if (xtra) { QxrdNIDAQPluginInterfacePtr nidaq = xtra->nidaqPlugin(); if (nidaq) { return nidaq->readContinuousInputChannel(get_PhysicalChannel()); } } return QVector<double>(); }
int QxrdAcquisitionExtraInputsChannel::endIndex() { int res = 0; QxrdAcquisitionExtraInputsPtr xtra(m_ExtraInputs); if (xtra) { QxrdNIDAQPluginInterfacePtr nidaq = xtra->nidaqPlugin(); if (nidaq) { int nSamples = nidaq->countContinuousInput(); int endOffset = xtra->get_SampleRate()*(0.1 + xtra->get_ExposureTime() - get_End()); if (endOffset > nSamples) { res = nSamples; } else if (endOffset > 0) { res = endOffset; } } } return res; }
int QxrdAcquisitionExtraInputsChannel::startIndex() { int res = 0; QxrdAcquisitionExtraInputsPtr xtra(m_ExtraInputs); if (xtra) { QxrdNIDAQPluginInterfacePtr nidaq = xtra->nidaqPlugin(); if (nidaq) { int nSamples = nidaq->countContinuousInput(); int startOffset = xtra->get_SampleRate()*(0.1 + get_Start()); if (startOffset > nSamples) { res = nSamples; } else if (startOffset > 0) { res = startOffset; } } } return res; }