/** * @dataProvider setupData */ void KArchiveTest::testTarReadWrite() { QFETCH(QString, fileName); // testCreateTar must have been run first. KTar tar(fileName); QVERIFY(tar.open(QIODevice::ReadWrite)); testReadWrite(&tar); testFileData(&tar); QVERIFY(tar.close()); // Reopen it and check it { KTar tar(fileName); QVERIFY(tar.open(QIODevice::ReadOnly)); testFileData( &tar ); const KArchiveDirectory* dir = tar.directory(); const KArchiveEntry* e = dir->entry("newfile"); QVERIFY(e && e->isFile()); const KArchiveFile* f = (KArchiveFile*)e; QCOMPARE(f->data().size(), 8); } // NOTE This is the last test for this dataset. so cleanup here QFile::remove(fileName); }
void KArchiveTest::testEmptyFilename() { QTest::ignoreMessage(QtWarningMsg, "KArchive: No file name specified"); KTar tar(QLatin1String("")); QVERIFY(!tar.open(QIODevice::ReadOnly)); QCOMPARE(tar.errorString(), tr("No filename or device was specified")); }
/** * @dataProvider testCreateTar_data */ void KArchiveTest::testCreateTar() { QFETCH(QString, fileName); // With tempfile: 0.7-0.8 ms, 994236 instr. loads // Without tempfile: 0.81 ms, 992541 instr. loads // Note: use ./karchivetest 2>&1 | grep ms // to avoid being slowed down by the kDebugs. QBENCHMARK { KTar tar(fileName); QVERIFY(tar.open(QIODevice::WriteOnly)); writeTestFilesToArchive(&tar); QVERIFY(tar.close()); QFileInfo fileInfo(QFile::encodeName(fileName)); QVERIFY(fileInfo.exists()); // We can't check for an exact size because of the addLocalFile, whose data is system-dependent QVERIFY(fileInfo.size() > 450); } // NOTE The only .tar test, cleanup here QFile::remove(fileName); }
bool KTheme::load( const KURL & url ) { kdDebug() << "Loading theme from URL: " << url << endl; QString tmpFile; if ( !KIO::NetAccess::download( url, tmpFile, 0L ) ) return false; kdDebug() << "Theme is in temp file: " << tmpFile << endl; // set theme's name setName( QFileInfo( url.fileName() ).baseName() ); // unpack the tarball QString location = m_kgd->saveLocation( "themes", m_name + "/" ); KTar tar( tmpFile ); tar.open( IO_ReadOnly ); tar.directory()->copyTo( location ); tar.close(); // create the DOM QFile file( location + m_name + ".xml" ); file.open( IO_ReadOnly ); m_dom.setContent( file.readAll() ); file.close(); // remove the temp file KIO::NetAccess::removeTempFile( tmpFile ); return true; }
int main(int argc, char **argv) { if (argc != 2) { printf("\n" " Usage :\n" " ./ktartest /path/to/existing_file.tar.gz tests listing an existing tar.gz\n"); return 1; } KTar tar(argv[1]); if (!tar.open(QIODevice::ReadOnly)) { printf("Could not open %s for reading\n", argv[1]); return 1; } const KArchiveDirectory *dir = tar.directory(); //printf("calling recursive_print\n"); recursive_print(dir, QLatin1String("")); //printf("recursive_print called\n"); tar.close(); return 0; }
/** * TODO: unit test channel_pow_stats::update_pbs_avg */ bool channel_pow_stats::update_bps_avg( uint64_t bytes_recv, const pow_hash& msg_pow ) { // normalize the proof of work for the message size fc::bigint msg( &msg_pow, sizeof(msg_pow) ); msg *= ( (bytes_recv / 1024) + 1); // give the average work per kb // for the purposes of this calculation, there is no such thing as a message less than // 1 KB in size. if( bytes_recv < 1024 ) bytes_recv = 1024; // first check the work, if it is valid we can work it into our // POW average, otherwise we will ignore it. if( msg_pow > target_pow ) return false; // how much time has elapsed since the last bytes that passed auto ellapsed_us = (fc::time_point::now() - last_recv).count(); last_recv = fc::time_point::now(); // prevent long delays between message from biasing the average too much // also protects against OS time changes if( ellapsed_us > BITCHAT_BANDWIDTH_WINDOW_US ) { ellapsed_us = BITCHAT_BANDWIDTH_WINDOW_US/32; } // calculate the weighted average for the bitrate auto total = avg_bits_per_usec*BITCHAT_BANDWIDTH_WINDOW_US + (8 * bytes_recv * ellapsed_us); avg_bits_per_usec = total / (BITCHAT_BANDWIDTH_WINDOW_US + ellapsed_us); // use the same weighting factors to weight the update to the average POW fc::bigint avg( &average_pow, sizeof(average_pow) ); fc::bigint wsum = (avg * BITCHAT_BANDWIDTH_WINDOW_US + msg*ellapsed_us) / (BITCHAT_BANDWIDTH_WINDOW_US+ellapsed_us); fc::bigint tar( &target_pow, sizeof(target_pow) ); if( avg_bits_per_usec >= target_bits_per_usec ) { tar *= wsum * bigint( 990000ll); tar /= bigint(1000000ll); } else { // increase target (making it easier to get under) tar = wsum * bigint(1010000ll); tar /= bigint(1000000ll); } std::vector<char> tarw(tar); std::vector<char> avgw(wsum); target_pow = pow_hash(); memcpy( (char*)&target_pow + sizeof(pow_hash)-tarw.size(), tarw.data(), tarw.size() ); memcpy( (char*)&average_pow + sizeof(pow_hash)-avgw.size(), avgw.data(), avgw.size() ); return true; }
TEST(Tar, read) { File folder = File(__FILE__).getParent(); File file = File(folder, "test.tar"); FileInputStream fis = FileInputStream(file); UnTarStream tar(&fis); unsigned int cnt = 0; while (tar.hasNext()) { UnTarEntry ute = tar.next(); std::cout << ute.header.getTimestamp() << std::endl; // read to vector std::vector<uint8_t> vec = ute.stream.readCompletely(); ASSERT_EQ(ute.header.getSize(), vec.size()); if (cnt == 2) { std::string str((char*)vec.data(), vec.size()); ASSERT_EQ("hallo!\n", str); } ++cnt; } ASSERT_EQ(3, cnt); }
void KArchiveTest::testTarPrefix() { KTar tar(QFINDTESTDATA(QLatin1String("tar_prefix_test.tar.gz"))); QVERIFY2(tar.open(QIODevice::ReadOnly), "tar_prefix_test.tar.gz"); const KArchiveDirectory *dir = tar.directory(); QVERIFY(dir != nullptr); const QStringList listing = recursiveListEntries(dir, QLatin1String(""), WithUserGroup); QCOMPARE(listing[0], QString("mode=40775 user=root group=root path=Test type=dir")); QCOMPARE(listing[1], QString("mode=40775 user=root group=root path=Test/qt-jambi-qtjambi-4_7 type=dir")); QCOMPARE(listing[2], QString("mode=40775 user=root group=root path=Test/qt-jambi-qtjambi-4_7/examples type=dir")); QCOMPARE(listing[3], QString("mode=40775 user=root group=root path=Test/qt-jambi-qtjambi-4_7/examples/generator type=dir")); QCOMPARE(listing[4], QString("mode=40775 user=root group=root path=Test/qt-jambi-qtjambi-4_7/examples/generator/trolltech_original type=dir")); QCOMPARE(listing[5], QString("mode=40775 user=root group=root path=Test/qt-jambi-qtjambi-4_7/examples/generator/trolltech_original/java type=dir")); QCOMPARE(listing[6], QString("mode=40775 user=root group=root path=Test/qt-jambi-qtjambi-4_7/examples/generator/trolltech_original/java/com type=dir")); QCOMPARE(listing[7], QString("mode=40775 user=root group=root path=Test/qt-jambi-qtjambi-4_7/examples/generator/trolltech_original/java/com/trolltech type=dir")); QCOMPARE(listing[8], QString("mode=40775 user=root group=root path=Test/qt-jambi-qtjambi-4_7/examples/generator/trolltech_original/java/com/trolltech/examples type=dir")); QCOMPARE(listing[9], QString("mode=664 user=root group=root path=Test/qt-jambi-qtjambi-4_7/examples/generator/trolltech_original/java/com/trolltech/examples/GeneratorExample.html type=file size=43086")); QCOMPARE(listing.count(), 10); QVERIFY(tar.close()); }
ModelManager::ModelManager(QObject* parent) : QObject(parent), inGroup(false), modelChangedFlag(false) { connect (ScenarioManager::getInstance(), SIGNAL(scenariosChanged()), this, SLOT(modelHasChanged())); connect (ScenarioManager::getInstance(), SIGNAL(shadowVocabularyChanged()), this, SLOT(modelHasChanged())); connect (ScenarioManager::getInstance(), SIGNAL(baseModelChanged()), this, SLOT(modelHasChanged())); connect (TrainingManager::getInstance(), SIGNAL(trainingDataChanged()), this, SLOT(modelHasChanged())); connect (TrainingManager::getInstance(), SIGNAL(trainingSettingsChanged()), this, SLOT(modelHasChanged())); // read active model and build blacklistedTranscriptions QString activePath = KStandardDirs::locate("appdata", "model/active.sbm"); if (QFile::exists(activePath)) { KTar tar(activePath, "application/x-gzip"); ModelMetadata *data = metaData(tar); if (data) { updateBlacklistedTranscriptions(data); delete data; } } }
void KArchiveTest::testNullDevice() { QIODevice *nil = nullptr; QTest::ignoreMessage(QtWarningMsg, "KArchive: Null device specified"); KTar tar(nil); QVERIFY(!tar.open(QIODevice::ReadOnly)); QCOMPARE(tar.errorString(), tr("No filename or device was specified")); }
int main(int argc, char *argv[]) { if(argc < 2 || strlen(argv[1]) != 1) usage(); switch(argv[1][0]) { case 'c': if(argc < 3) usage(); while(argc-- >= 3) if(c(argv[argc])) return EXIT_FAILURE; return EXIT_SUCCESS; case 'x': if(argc == 2) return tar(x); case 't': if(argc == 2) return tar(t); default: usage(); } return EXIT_FAILURE; }
void tar(vector<int> *e, int w){ sta[++top] = w; low[w] = dfn[w] = ++num; v[w] = 1; rep (i, sz(e[w]) ) { int j = e[w][i]; if(v[j] == 2) continue; if( dfn[j] == -1) tar(e, j); low[w] = min(low[w], low[j]); }
void SightLightScene::onTouchMoved(cocos2d::Touch *touch,cocos2d::Event* event) { Point tar(0,0); //光线的端点 Point cur(0,0); //光线与线段的交点 float distance = 0; //光源与交点的距离 _touchDraw->clear(); auto pos = touch->getLocation(); //_touchDraw->drawDot(pos,5,Color4F::RED); //计算极角,并添加两个偏移1e-4的极角 initAngles(pos); //极角排序 std::sort(_angles.begin(), _angles.end(), [](float x,float y){ return x < y; }); std::vector<cocos2d::Vec2> vertex; //找最近的交点 // std::vector<Point> vertex; for (auto angle:_angles) { Vec2 dlt(cos(angle),sin(angle)); float closest = -1; for (auto s:_segments) { if (getIntersection(Line(pos,pos + dlt),s,cur,distance)) { if (closest == -1 || closest > distance) { closest = distance; tar = cur; } } } if (closest != -1) { vertex.push_back(tar); } } //画三角形 //下面2个循环第3个参数可以写为vertex[(i+1) % vertex.size()],合并成1个循环 //但是显然,取余操作效率太低,分开写更好一些 int limit = vertex.size() - 1; for (int i = 0; i < limit; i++) { _touchDraw->drawTriangle(pos, vertex[i], vertex[i + 1], Color4F::WHITE); } if(limit > 0) { _touchDraw->drawTriangle(pos, vertex[limit], vertex[0], Color4F::WHITE); } // 画三角形的边,Debug用 // for(auto v : vertex) { // _touchDraw->drawSegment(pos, v, 0.5f, Color4F::RED); // _touchDraw->drawDot(v, 3, Color4F::RED); // } }
/** * @dataProvider setupData */ void KArchiveTest::testReadTar() // testCreateTarGz must have been run first. { QFETCH( QString, fileName ); // 1.6-1.7 ms per interaction, 2908428 instruction loads // After the "no tempfile when writing fix" this went down // to 0.9-1.0 ms, 1689059 instruction loads. // I guess it finds the data in the kernel cache now that no KTempFile is // used when writing. QBENCHMARK { KTar tar( fileName ); QVERIFY( tar.open( QIODevice::ReadOnly ) ); const KArchiveDirectory* dir = tar.directory(); QVERIFY( dir != 0 ); const QStringList listing = recursiveListEntries( dir, "", WithUserGroup ); QFileInfo localFileData("test3"); #ifndef Q_WS_WIN QCOMPARE( listing.count(), 15 ); #else QCOMPARE( listing.count(), 14 ); #endif QCOMPARE( listing[ 0], QString("mode=40755 user=user group=group path=aaaemptydir type=dir") ); QCOMPARE( listing[ 1], QString("mode=40777 user=%1 group=%2 path=dir type=dir").arg(localFileData.owner()).arg(localFileData.group()) ); QCOMPARE( listing[ 2], QString("mode=40777 user=%1 group=%2 path=dir/subdir type=dir").arg(localFileData.owner()).arg(localFileData.group()) ); QCOMPARE( listing[ 3], QString("mode=100644 user=user group=group path=dir/subdir/mediumfile2 type=file size=100") ); QCOMPARE( listing[ 4], QString("mode=100644 user=weis group=users path=empty type=file size=0") ); QCOMPARE( listing[ 5], QString("mode=100644 user=user group=group path=hugefile type=file size=20000") ); QCOMPARE( listing[ 6], QString("mode=100644 user=user group=group path=mediumfile type=file size=100") ); QCOMPARE( listing[ 7], QString("mode=40777 user=%1 group=%2 path=my type=dir").arg(localFileData.owner()).arg(localFileData.group()) ); QCOMPARE( listing[ 8], QString("mode=40777 user=%1 group=%2 path=my/dir type=dir").arg(localFileData.owner()).arg(localFileData.group()) ); QCOMPARE( listing[ 9], QString("mode=100644 user=dfaure group=hackers path=my/dir/test3 type=file size=29") ); QCOMPARE( listing[10], QString("mode=100440 user=weis group=users path=test1 type=file size=5") ); QCOMPARE( listing[11], QString("mode=100644 user=weis group=users path=test2 type=file size=8") ); QCOMPARE( listing[12], QString("mode=40777 user=%1 group=%2 path=z type=dir").arg(localFileData.owner()).arg(localFileData.group()) ); // This one was added with addLocalFile, so ignore mode/user/group. QString str = listing[13]; str.replace(QRegExp("mode.*path"), "path" ); QCOMPARE( str, QString("path=z/test3 type=file size=13") ); #ifndef Q_OS_WIN str = listing[14]; str.replace(QRegExp("mode.*path"), "path" ); QCOMPARE( str, QString("path=z/test3_symlink type=file size=0 symlink=test3") ); #endif QVERIFY( tar.close() ); } }
/** * @dataProvider setupData */ void KArchiveTest::testTarCopyTo() { QFETCH(QString, fileName); // testCreateTar must have been run first. KTar tar(fileName); QVERIFY(tar.open(QIODevice::ReadOnly)); testCopyTo(&tar); QVERIFY(tar.close()); }
void bug(int q, int bcount) { int j = 0; int outgo = 0; while(j != -1) { outgo++; if (outgo > q-1) outgo = q-1; j = tar (outgo*bcount); } }
void TilesetGroupEditor::on_Open_clicked() { QString f = QFileDialog::getOpenFileName(this, tr("Select Tileset Group"), m_configs->config_dir + "group_tilesets/", QString("PGE Tileset Group (*.tsgrp.ini)")); if(f.isEmpty()) return; if(!f.startsWith(m_configs->config_dir + "group_tilesets/")) { QFile file(f); QFile tar(f = (m_configs->config_dir + "group_tilesets/" + f.section("/", -1, -1))); if(tar.exists()) { QMessageBox msgBox; msgBox.setText(tr("There is already a file called '%1'!\nImport anyway and overwrite?").arg(tar.fileName())); msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Cancel); if(msgBox.exec() == QMessageBox::Ok) tar.remove(); else return; } file.copy(f); } SimpleTilesetGroup t; if(OpenSimpleTilesetGroup(f, t)) { tilesets.clear(); ui->tilesetGroupName->setText(t.groupName); ui->category->setText(t.groupCat); for(QString &tarName : t.tilesets) { QString rootTilesetDir = m_configs->config_dir + "tilesets/"; SimpleTileset st; if(tileset::OpenSimpleTileset(rootTilesetDir + tarName, st)) tilesets << qMakePair<QString, SimpleTileset>(tarName, st); } redrawAll(); } else { QMessageBox::warning(this, tr("Failed to load tileset group!"), tr("Failed to load tileset group!\nData may be corrupted!")); } }
rvector ZRangeWeaponHitDice::ReturnShotDir() { MakeHitProbability(); rvector vTargetPos = m_TargetPosition; float fRandX=0.0f, fRandY=0.0f; float fRandMaxX = m_fTargetWidth+50.0f; float fRandMaxY = m_fTargetHeight+20.0f; if (RandomNumber(0.0f, 1.0f) <= m_fHitProbability) { float fHeight = m_fTargetHeight * 0.6f * 0.5f; float fWidth = m_fTargetWidth * 0.6f * 0.5f; // ИэСп fRandX = RandomNumber(-fWidth, fWidth); fRandY = RandomNumber(-fHeight, fHeight); } else { float fHeight = m_fTargetHeight * 0.8f * 0.5f; float fWidth = m_fTargetWidth * 0.8f * 0.5f; fRandX = RandomNumber(fWidth, fRandMaxX); fRandY = RandomNumber(fHeight, fRandMaxY); int dice = Dice(1, 2, 0); if (dice == 1) fRandX = -fRandX; dice = Dice(1, 2, 0); if (dice == 1) fRandY = -fRandY; } rmatrix mat; rvector modelDir = vTargetPos - m_SourcePosition; Normalize(modelDir); rvector tar(0,0,0); tar.x += fRandX; tar.y += fRandY; MakeWorldMatrix(&mat, m_TargetPosition, modelDir, rvector(0,0,1)); tar = TransformCoord(tar, mat); rvector dir = tar - m_SourcePosition; Normalize(dir); return dir; }
void QNewDocStuff::installResource() { bool ok = true; KTar tar(m_tarName, "application/x-gzip"); if (tar.open(IO_ReadOnly)) { const KArchiveDirectory *directory = tar.directory(); QString docDir =KGlobal::dirs()->saveLocation("data") + resourceDir + "doc/"; directory->copyTo(docDir, true); tar.close(); } else ok = false; if (!ok) KMessageBox::error(parentWidget(), i18n("There was an error with the downloaded script tarball file. Possible causes are damaged archive or invalid directory structure in the archive."), i18n("Documentation Installation Error")); }
void KArchiveTest::testTarGlobalHeader() { KTar tar(QFINDTESTDATA(QLatin1String("global_header_test.tar.gz"))); QVERIFY2(tar.open(QIODevice::ReadOnly), "global_header_test.tar.gz"); const KArchiveDirectory *dir = tar.directory(); QVERIFY(dir != nullptr); const QStringList listing = recursiveListEntries(dir, QLatin1String(""), WithUserGroup); QCOMPARE(listing.count(), 2); QCOMPARE(listing[0], QString("mode=40775 user=root group=root path=Test type=dir")); QCOMPARE(listing[1], QString("mode=664 user=root group=root path=Test/test.txt type=file size=0")); QVERIFY(tar.close()); }
TEST(Tar, open) { File folder = File(__FILE__).getParent(); File file = File(folder, "test.tar"); FileInputStream fis = FileInputStream(file); UnTarStream tar(&fis); unsigned int cnt = 0; while (tar.hasNext()) { tar.next(); ++cnt; } ASSERT_EQ(3, cnt); }
void RestoreThread::run() { m_success = false; KTar tar(m_tarFile, "application/x-gzip"); tar.open(QIODevice::ReadOnly); if (tar.isOpen()) { const KArchiveDirectory *directory = tar.directory(); if (directory->entries().contains(backupMagicFolder)) { const KArchiveEntry *entry = directory->entry(backupMagicFolder); if (entry->isDirectory()) { ((const KArchiveDirectory*) entry)->copyTo(m_destFolder); m_success = true; } } tar.close(); } }
void BackupThread::run() { KTar tar(m_tarFile, "application/x-gzip"); tar.open(QIODevice::WriteOnly); tar.addLocalDirectory(m_folderToBackup, backupMagicFolder); // KArchive does not add hidden files. Basket description files (".basket") are hidden, we add them manually: QDir dir(m_folderToBackup + "baskets/"); QStringList baskets = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); for (QStringList::Iterator it = baskets.begin(); it != baskets.end(); ++it) { tar.addLocalFile( m_folderToBackup + "baskets/" + *it + "/.basket", backupMagicFolder + "/baskets/" + *it + "/.basket" ); } // We finished: tar.close(); }
void KArchiveTest::testTarDirectoryTwice() // bug 206994 { KTar tar(QFINDTESTDATA(QLatin1String("tar_directory_twice.tar.gz"))); QVERIFY(tar.open(QIODevice::ReadOnly)); const KArchiveDirectory *dir = tar.directory(); QVERIFY(dir != nullptr); const QStringList listing = recursiveListEntries(dir, QLatin1String(""), WithUserGroup); //qDebug() << listing.join("\n"); QVERIFY(listing[0].contains("path=d")); QVERIFY(listing[1].contains("path=d/f1.txt")); QVERIFY(listing[2].contains("path=d/f2.txt")); QCOMPARE(listing.count(), 3); }
void KArchiveTest::testTarRootDir() // bug 309463 { KTar tar(QFINDTESTDATA(QLatin1String("tar_rootdir.tar.gz"))); QVERIFY2(tar.open(QIODevice::ReadOnly), qPrintable(tar.fileName())); const KArchiveDirectory *dir = tar.directory(); QVERIFY(dir != nullptr); const QStringList listing = recursiveListEntries(dir, QLatin1String(""), WithUserGroup); //qDebug() << listing.join("\n"); QVERIFY(listing[0].contains("%{APPNAME}.cpp")); QVERIFY(listing[1].contains("%{APPNAME}.h")); QVERIFY(listing[5].contains("main.cpp")); QCOMPARE(listing.count(), 10); }
void KArchiveTest::testTarDirectoryForgotten() { KTar tar(QFINDTESTDATA(QLatin1String("tar_directory_forgotten.tar.gz"))); QVERIFY2(tar.open(QIODevice::ReadOnly), "tar_directory_forgotten.tar.gz"); const KArchiveDirectory *dir = tar.directory(); QVERIFY(dir != nullptr); const QStringList listing = recursiveListEntries(dir, QLatin1String(""), WithUserGroup); QVERIFY(listing[9].contains("trolltech/examples/generator")); QVERIFY(listing[10].contains("trolltech/examples/generator/GeneratorExample.html")); QCOMPARE(listing.count(), 11); QVERIFY(tar.close()); }
/** * @dataProvider testTarMaxLength_data */ void KArchiveTest::testTarMaxLength() { QFETCH( QString, fileName ); KTar tar( fileName ); QVERIFY( tar.open( QIODevice::WriteOnly ) ); // Generate long filenames of each possible length bigger than 98... // Also exceed 512 byte block size limit to see how well the ././@LongLink // implementation fares for (int i = 98; i < 514 ; i++ ) { QString str, num; str.fill( 'a', i-10 ); num.setNum( i ); num = num.rightJustified( 10, '0' ); tar.writeFile( str+num, "testu", "testg", "hum", 3 ); } // Result of this test : works perfectly now (failed at 482 formerly and // before that at 154). QVERIFY( tar.close() ); QVERIFY( tar.open( QIODevice::ReadOnly ) ); const KArchiveDirectory* dir = tar.directory(); QVERIFY( dir != 0 ); const QStringList listing = recursiveListEntries( dir, "", WithUserGroup ); QCOMPARE( listing[ 0], QString("mode=100644 user=testu group=testg path=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000098 type=file size=3") ); QCOMPARE( listing[ 3], QString("mode=100644 user=testu group=testg path=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000101 type=file size=3") ); QCOMPARE( listing[ 4], QString("mode=100644 user=testu group=testg path=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000102 type=file size=3") ); // TODO: // ################################################# BUG! ########################### // There seems to be a bug (which is in kde3 too), we miss 512 and 513. // But note that tar tvzf says "skipping next header" (and it skips 511), // so the bug is probably during writing... QCOMPARE( listing.count(), 414 ); // TODO investigate 514 - 98 QVERIFY( tar.close() ); // NOTE Cleanup here QFile::remove( fileName ); }
bool QTarGzFileType::exist() const { // get informations about the archive QFileInfo archInfo(fileInfo.archivePath()); // if the archive exit if (archInfo.isFile()) { // open the archive QTar tar(QSharedPointer<QIODevice>(new QuaGzipFile(fileInfo.archivePath()))); // try to open the file if (tar.open(QTar::mdUntar)) { // if the file is in the archive -> it exist return tar.getFileNameList().contains(fileInfo.inArchivePath()); } } return false; }
void Preprocessor::run() { cout<<"Work begins!"<<endl; if(pre_type == 1){ tar(); }else if(pre_type == 2){ montage(); }else if(pre_type == 3){ groupProject(); }else if(pre_type == 4){ resize(); }else if(pre_type == 5){ crop(); }else if(pre_type == 6){ autoWork(); } cout<<"Work Has Been Done!"<<endl; }
int main() { person p("ola"); std::cout << p << '\n'; foo(p); std::cout << p << '\n'; bar(p); std::cout << p << '\n'; var(&p); std::cout << p << '\n'; tar(&p); std::cout << p << '\n'; return 0; }