本文整理汇总了C++中NameSpace::Lseek方法的典型用法代码示例。如果您正苦于以下问题:C++ NameSpace::Lseek方法的具体用法?C++ NameSpace::Lseek怎么用?C++ NameSpace::Lseek使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NameSpace
的用法示例。
在下文中一共展示了NameSpace::Lseek方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReturnStatus
ReturnStatus
FileMetaDAO::writeFileMeta(Args *fd, const FileMeta &meta)
{
Channel* pDataChannel = ChannelManager::getInstance()->Mapping(m_BucketId);
NameSpace *DataNS = pDataChannel->m_DataNS;
int rt = 0;
rt = DataNS->Lseek(fd, 0, SEEK_SET);
if (-1 == rt) {
ERROR_LOG("lseek() error, %s.", strerror(errno));
return ReturnStatus(MU_FAILED, MU_UNKNOWN_ERROR);
}
int blocks = meta.m_BlockList.size();
int attrLen = sizeof(FileAttr);
char *pBuf = new char[
attrLen + FIXED_BLOCK_CHECKSUM_LEN * blocks];
int bufIdx = 0;
memcpy(pBuf + bufIdx, &(meta.m_Attr), attrLen);
bufIdx += attrLen;
for (std::list<BlockMeta>::const_iterator it = meta.m_BlockList.begin();
it != meta.m_BlockList.end(); ++it) {
memcpy(pBuf + bufIdx,
it->m_Checksum.c_str(),
FIXED_BLOCK_CHECKSUM_LEN);
bufIdx += FIXED_BLOCK_CHECKSUM_LEN;
}
rt = DataNS->writen(fd, pBuf, bufIdx);
delete [] pBuf;
pBuf = NULL;
if (bufIdx != rt) {
ERROR_LOG("writen() error");
return ReturnStatus(MU_FAILED, MU_UNKNOWN_ERROR);
}
//int iovcnt = blocks + 1;
//struct iovec iov[iovcnt];
//int iovIdx = 0;
//iov[iovIdx].iov_base = const_cast<FileAttr *>(&(meta.m_Attr));
//iov[iovIdx].iov_len = sizeof(meta.m_Attr);
//++iovIdx;
//for (std::list<BlockMeta>::const_iterator it = meta.m_BlockList.begin();
//it != meta.m_BlockList.end(); ++it) {
//iov[iovIdx].iov_base = const_cast<char *>(it->m_Checksum.c_str());
//iov[iovIdx].iov_len = FIXED_BLOCK_CHECKSUM_LEN;
//++iovIdx;
//}
//rt = ::writev(fd, iov, iovcnt);
//if (sizeof(meta.m_Attr) + blocks * FIXED_BLOCK_CHECKSUM_LEN != rt) {
//ERROR_LOG("writev() error, %s.", strerror(errno));
//return ReturnStatus(MU_FAILED, MU_UNKNOWN_ERROR);
//}
return ReturnStatus(MU_SUCCESS);
}