本文整理汇总了C++中NameSpace::RmDir方法的典型用法代码示例。如果您正苦于以下问题:C++ NameSpace::RmDir方法的具体用法?C++ NameSpace::RmDir怎么用?C++ NameSpace::RmDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NameSpace
的用法示例。
在下文中一共展示了NameSpace::RmDir方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReturnStatus
ReturnStatus
FileMetaDAO::rmdirRecursive(const std::string &path, uint64_t *pDelta)
{
Channel* pDataChannel = ChannelManager::getInstance()->Mapping(m_BucketId);
NameSpace *DataNS = pDataChannel->m_DataNS;
int rt = 0;
ReturnStatus rs;
int error = 0;
std::string entryName;
std::string npath;
Args st;
rt = DataNS->OpenDir(path.c_str(), &st);
if (rt < 0) {
error = errno;
ERROR_LOG("path %s, opendir() error, %s.",
path.c_str(), strerror(errno));
if (ENOTDIR == error) {
ERROR_LOG("path %s, opendir() error, no directory");
return ReturnStatus(MU_FAILED, NOT_DIRECTORY);
} else if (ENOENT == error) {
return checkPrefix(path);
}
}
// delete its children
Dirent dirent;
while(DataNS->ReadDirNext(&st, &dirent)){
entryName = dirent.filename;
// omit "." and ".."
// omit user info file in user root dir
if (entryName == DENTRY_CURRENT_DIR
|| entryName == DENTRY_PARENT_DIR
|| entryName == USER_INFO_FILE_NAME) {
continue;
}
npath = path + PATH_SEPARATOR_STRING + entryName;
if (MU_DIRECTORY == dirent.filetype) {
// directory, call myself to delete it
rs = rmdirRecursive(npath, pDelta);
if (!rs.success()) {
ERROR_LOG("path %s, rmdirRecursive() error", npath.c_str());
return rs;
}
} else {
// add file size to changed user quota
addFileSizeToDelta(npath, pDelta);
// delete it directly
rt = DataNS->Unlink(npath.c_str());
if (-1 == rt) {
ERROR_LOG("path %s, unlink() error, %s.",
npath.c_str(), strerror(errno));
return ReturnStatus(MU_FAILED, MU_UNKNOWN_ERROR);
}
}
}
// delete path
// do not delete user root
if (path.substr(path.length() - 1) == ROOT_PATH) {
return ReturnStatus(MU_SUCCESS);
}
rt = DataNS->RmDir(path.c_str());
if (-1 == rt) {
ERROR_LOG("path %s, rmdir() error, %s.",
path.c_str(), strerror(errno));
return ReturnStatus(MU_FAILED, MU_UNKNOWN_ERROR);
}
return ReturnStatus(MU_SUCCESS);
}