本文整理汇总了C++中Sector::rmr方法的典型用法代码示例。如果您正苦于以下问题:C++ Sector::rmr方法的具体用法?C++ Sector::rmr怎么用?C++ Sector::rmr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sector
的用法示例。
在下文中一共展示了Sector::rmr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv)
{
if (argc != 2)
{
cout << "USAGE: rm <dir>\n";
return -1;
}
Sector client;
Session s;
s.loadInfo("../conf/client.conf");
if (client.init(s.m_ClientConf.m_strMasterIP, s.m_ClientConf.m_iMasterPort) < 0)
return -1;
if (client.login(s.m_ClientConf.m_strUserName, s.m_ClientConf.m_strPassword, s.m_ClientConf.m_strCertificate.c_str()) < 0)
return -1;
string path = argv[1];
bool wc = WildCard::isWildCard(path);
if (!wc)
{
int r = client.remove(path);
if (r == SectorError::E_NOEMPTY)
{
if (isRecursive(path))
client.rmr(path);
}
else if (r < 0)
cout << "ERROR: " << r << " " << SectorError::getErrorMsg(r) << endl;
}
else
{
string orig = path;
size_t p = path.rfind('/');
if (p == string::npos)
path = "/";
else
{
path = path.substr(0, p);
orig = orig.substr(p + 1, orig.length() - p);
}
vector<SNode> filelist;
int r = client.list(path, filelist);
if (r < 0)
cout << "ERROR: " << r << " " << SectorError::getErrorMsg(r) << endl;
bool recursive = false;
vector<string> filtered;
for (vector<SNode>::iterator i = filelist.begin(); i != filelist.end(); ++ i)
{
if (WildCard::match(orig, i->m_strName))
{
if (recursive)
client.rmr(path + "/" + i->m_strName);
else
{
r = client.remove(path + "/" + i->m_strName);
if (r == SectorError::E_NOEMPTY)
{
recursive = isRecursive(path + "/" + i->m_strName);
if (recursive)
client.rmr(path + "/" + i->m_strName);
}
else if (r < 0)
cout << "ERROR: " << r << " " << SectorError::getErrorMsg(r) << endl;
}
}
}
}
client.logout();
client.close();
return 1;
}