本文整理汇总了C++中BlobDataItem::offset方法的典型用法代码示例。如果您正苦于以下问题:C++ BlobDataItem::offset方法的具体用法?C++ BlobDataItem::offset怎么用?C++ BlobDataItem::offset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BlobDataItem
的用法示例。
在下文中一共展示了BlobDataItem::offset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readFileSync
int BlobResourceHandle::readFileSync(const BlobDataItem& item, char* buf, int length)
{
ASSERT(isMainThread());
ASSERT(!m_async);
if (!m_fileOpened) {
long long bytesToRead = m_itemLengthList[m_readItemCount] - m_currentItemReadSize;
if (bytesToRead > m_totalRemainingSize)
bytesToRead = m_totalRemainingSize;
bool success = m_stream->openForRead(item.file->path(), item.offset() + m_currentItemReadSize, bytesToRead);
m_currentItemReadSize = 0;
if (!success) {
m_errorCode = notReadableError;
return 0;
}
m_fileOpened = true;
}
int bytesRead = m_stream->read(buf, length);
if (bytesRead < 0) {
m_errorCode = notReadableError;
return 0;
}
if (!bytesRead) {
m_stream->close();
m_fileOpened = false;
m_readItemCount++;
} else
m_totalRemainingSize -= bytesRead;
return bytesRead;
}
示例2: readDataAsync
void BlobResourceHandle::readDataAsync(const BlobDataItem& item)
{
ASSERT(isMainThread());
ASSERT(m_async);
Ref<BlobResourceHandle> protect(*this);
long long bytesToRead = item.length() - m_currentItemReadSize;
if (bytesToRead > m_totalRemainingSize)
bytesToRead = m_totalRemainingSize;
consumeData(item.data->data() + item.offset() + m_currentItemReadSize, static_cast<int>(bytesToRead));
m_currentItemReadSize = 0;
}
示例3: readFileAsync
void BlobResourceHandle::readFileAsync(const BlobDataItem& item)
{
ASSERT(isMainThread());
ASSERT(m_async);
if (m_fileOpened) {
m_asyncStream->read(m_buffer.data(), m_buffer.size());
return;
}
long long bytesToRead = m_itemLengthList[m_readItemCount] - m_currentItemReadSize;
if (bytesToRead > m_totalRemainingSize)
bytesToRead = static_cast<int>(m_totalRemainingSize);
m_asyncStream->openForRead(item.file->path(), item.offset() + m_currentItemReadSize, bytesToRead);
m_fileOpened = true;
m_currentItemReadSize = 0;
}
示例4: readDataSync
int BlobResourceHandle::readDataSync(const BlobDataItem& item, char* buf, int length)
{
ASSERT(isMainThread());
ASSERT(!m_async);
long long remaining = item.length() - m_currentItemReadSize;
int bytesToRead = (length > remaining) ? static_cast<int>(remaining) : length;
if (bytesToRead > m_totalRemainingSize)
bytesToRead = static_cast<int>(m_totalRemainingSize);
memcpy(buf, item.data->data() + item.offset() + m_currentItemReadSize, bytesToRead);
m_totalRemainingSize -= bytesToRead;
m_currentItemReadSize += bytesToRead;
if (m_currentItemReadSize == item.length()) {
m_readItemCount++;
m_currentItemReadSize = 0;
}
return bytesToRead;
}