本文整理汇总了C++中boost::filesystem::path::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ path::clear方法的具体用法?C++ path::clear怎么用?C++ path::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::filesystem::path
的用法示例。
在下文中一共展示了path::clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: string
bool
resolveLink(const bfs::path& path,
bfs::path& target)
{
bool rval = false;
int cfd = -1;
bfs::path linkVal = readLink(path);
try {
if (!linkVal.empty()) {
bfs::path parent = path.parent_path();
if (!parent.empty()) {
cfd = ::open(".", O_RDONLY, 0);
if (cfd < 0) {
throw string("unable to open .");
}
if (::chdir(parent.c_str()) < 0) {
throw string("unable to chdir to ") + parent.c_str();
}
}
char buf[PATH_MAX+1];
if (::realpath(path.c_str(), buf) == NULL) {
throw string("realpath failed");
}
target = buf;
rval = pathExists(target);
}
} catch (const string&) {
rval = false;
}
if (!rval) {
target.clear();
}
if (cfd >= 0) {
::fchdir(cfd);
::close(cfd);
}
return rval;
}
示例2: dirPath
/**
\todo Introduce a tree structure to improve the efficiency of searching matched directories
*/
bool ParametricPathProcessorImpl::findSubDirectoryOfDirectoryVariable
(const filesystem::path& path, std::string& out_varName, filesystem::path& out_relativePath)
{
out_relativePath.clear();
int maxMatchSize = 0;
filesystem::path relativePath;
Mapping::const_iterator p;
for(p = variables->begin(); p != variables->end(); ++p){
Listing* paths = p->second->toListing();
if(paths){
for(int i=0; i < paths->size(); ++i){
filesystem::path dirPath(paths->at(i)->toString());
int n = findSubDirectory(dirPath, path, relativePath);
if(n > maxMatchSize){
maxMatchSize = n;
out_relativePath = relativePath;
out_varName = fromUTF8(p->first);
}
}
}
}
return (maxMatchSize > 0);
}