本文整理汇总了C++中Options::archive方法的典型用法代码示例。如果您正苦于以下问题:C++ Options::archive方法的具体用法?C++ Options::archive怎么用?C++ Options::archive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Options
的用法示例。
在下文中一共展示了Options::archive方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
int AppTar::run(int argc, char **argv)
{
_options.parse(argc, argv);
if (_options.create())
return _createArchive();
FILE *fp = fopen(_options.archive().c_str(), "r");
if (fp == 0)
throw "No such file or directory";
BitInputFile bif;
BitInput2File bif2;
streambuf *bt;
istream *is;
TarStream *ts;
switch (_options.compression())
{
case 3:
bif.open(fp);
bt = new DecStreamBuf(&bif);
break;
case 2:
bif2.open(fp);
bt = new GzipStreamBuf(&bif2);
break;
default:
bt = new buftest(fp);
}
is = new istream(bt);
ts = new TarStream(is);
if (_options.table())
ts->list(_options.verbose());
if (_options.extract())
ts->extract(_options.verbose());
delete ts;
delete is;
delete bt;
fclose(fp);
return 0;
}
示例2: _createArchive
int AppTar::_createArchive()
{
TarWriter t;
ofstream ofs(_options.archive().c_str());
ifstream ifs("yes.cpp");
//ofs << "Onzin\n";
SHeader sh = {};
strcpy(sh.name, "yes.cpp");
strcpy(sh.mode, "0000644");
strcpy(sh.uid, "0001750");
strcpy(sh.gid, "0001750");
strcpy(sh.size, "00000000450");
strcpy(sh.mtime, "12345678123");
strcpy(sh.chksum, "000000");
sh.typeflag = 1;
t.writeFile(ofs, ifs, sh);
ifs.close();
ofs.close();
return 0;
}