本文整理汇总了C++中Argv::startGroup方法的典型用法代码示例。如果您正苦于以下问题:C++ Argv::startGroup方法的具体用法?C++ Argv::startGroup怎么用?C++ Argv::startGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Argv
的用法示例。
在下文中一共展示了Argv::startGroup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
loginit(LEVEL_TRACE);
/* parse command line */
std::string indir;
Argv opts;
opts.addBoolOption("recusive,r","recursive the directory");
opts.startGroup("Hidden",false);
opts.addTextOption("inputdir,d","directory for scan").setOptionPostion("inputdir,d",1);
opts.stopGroup();
if (!opts.parse(argc,argv))
{
/* command options parsing error */
opts.showHelp(std::cout);
LOG(error)<< "Input error";
return 1;
}
else
{
indir=opts.getTextOption("inputdir","");
}
if (indir.size()<1)
{
/* inputdir isnot specified */
opts.showHelp(std::cout,true);
LOG(error)<< "Directory must be specified";
return 1;
}
LOG(trace)<< "Current Path:"<<bfs::current_path().generic_string();
LOG(trace)<< "Input directory:"<<indir;
bfs::path p(indir);
bfs::path fullp;
/* checek input directory */
if (!bfs::exists(p))
{
LOG(error)<<"Not exists";
return 1;
}
else
{
if (!bfs::is_directory(p))
{
LOG(error)<<"Not a directory";
return 1;
}
else
{
/* bfs::absolute will remain '..' or '.' */
fullp=bfs::canonical(p);
LOG(trace)<<"Full path:"<<fullp.generic_string();
}
}
/* list files */
walk(fullp,item_action,opts.getBoolOption("recusive"));
/* generate a unique filename, used for temperary file */
std::cout<<bfs::unique_path().generic_string()<<std::endl;
/* make dir */
bfs::path tmpfile("temp/abc/def");
/* path.parent_path() must exist for bfs::create_directory(path) */
/* makedirs(path) will call create_directory() repeatly until path is created */
makedirs(tmpfile);
/* create a temperary file */
tmpfile/=bfs::unique_path();
LOG(trace)<<tmpfile.generic_string();
std::ofstream ofs(tmpfile.generic_string());
ofs<<"test\n";
ofs.close();
/* remove directory */
bfs::remove_all("temp");
/* other file operation:
* copy, copy_directory, copy_file, copy_symlink
* copy will automaticall choose copy_directory/copy_file/copy_symlink
* remove, remove_all
* remove for file, remove_all for directory
* rename
*/
std::vector<bfs::path> vec;
findInPath("vim",{"."},vec);
std::copy(vec.cbegin(),vec.cend(),std::ostream_iterator<bfs::path>(std::cout,"\n"));
return 0;
}