本文整理汇总了C++中NameSpace::readn方法的典型用法代码示例。如果您正苦于以下问题:C++ NameSpace::readn方法的具体用法?C++ NameSpace::readn怎么用?C++ NameSpace::readn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NameSpace
的用法示例。
在下文中一共展示了NameSpace::readn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReturnStatus
ReturnStatus
FileMetaDAO::updateFile(const std::string &path, const FileMeta &meta,
FileMeta *pMeta, int *pDelta)
{
Channel* pDataChannel = ChannelManager::getInstance()->Mapping(m_BucketId);
NameSpace *DataNS = pDataChannel->m_DataNS;
int rt = 0;
Args fd;
ReturnStatus rs;
rs = isfile(path);
if (!rs.success()) {
return rs;
}
fd = DataNS->Open(path.c_str(), O_RDWR);
if (-1 == rt) {
ERROR_LOG("path %s, open() error, %s.", path.c_str(), strerror(errno));
// already check path errors in isfile()
return ReturnStatus(MU_FAILED, MU_UNKNOWN_ERROR);
}
// check file version
FileAttr attr;
rt = DataNS->readn(&fd, &attr, sizeof(attr));
if (sizeof(attr) != rt) {
ERROR_LOG("readn() error");
DataNS->Close(&fd);
return ReturnStatus(MU_FAILED, MU_UNKNOWN_ERROR);
}
if (meta.m_Attr.m_Version != attr.m_Version + 1) {
ERROR_LOG("version outdated, current version %" PRIu64 ", "
"received version %" PRIu64,
attr.m_Version, meta.m_Attr.m_Version);
DataNS->Close(&fd);
pMeta->m_Attr = attr;
return ReturnStatus(MU_FAILED, VERSION_OUTDATED);
}
// write metadata
rs = writeFileMeta(&fd, meta);
DataNS->Close(&fd);;
// return file size delta
*pDelta = meta.m_Attr.m_Size - attr.m_Size;
return rs;
}
示例2: open
void
FileMetaDAO::addFileSizeToDelta(const std::string &path, uint64_t *pDelta)
{
Channel* pDataChannel = ChannelManager::getInstance()->Mapping(m_BucketId);
NameSpace *DataNS = pDataChannel->m_DataNS;
int rt = 0;
Args fd;
// read file size
fd = DataNS->Open(path.c_str(), O_RDONLY);
if (false == fd.valid) {
ERROR_LOG("path %s, open() error, %s", path.c_str(), strerror(errno));
return ;
}
//int fd = rt;
FileAttr attr;
rt = DataNS->readn(&fd, &attr, sizeof(attr));
DataNS->Close(&fd);
if (sizeof(attr) != rt) {
ERROR_LOG("path %s, readn() error", path.c_str());
return ;
}
*pDelta += attr.m_Size;
}