Exemplo n.º 1
0
void FileChannel::setProperty(const std::string& name, const std::string& value)
{
	FastMutex::ScopedLock lock(_mutex);

	if (name == PROP_TIMES)
	{
		_times = value;

		if (!_rotation.empty())
			setRotation(_rotation);

		if (!_archive.empty())
			setArchive(_archive);
	}
	else if (name == PROP_PATH)
		_path = value;
	else if (name == PROP_ROTATION)
		setRotation(value);
	else if (name == PROP_ARCHIVE)
		setArchive(value);
	else if (name == PROP_COMPRESS)
		setCompress(value);
	else if (name == PROP_PURGEAGE)
		setPurgeAge(value);
	else if (name == PROP_PURGECOUNT)
		setPurgeCount(value);
	else
		Channel::setProperty(name, value);
}
Exemplo n.º 2
0
ArchiveListItem::ArchiveListItem(ArchivePtr archive)
    : _widget(new QWidget), _useSIPrefixes(false)
{
    QSettings settings;
    _useSIPrefixes = settings.value("app/si_prefixes", false).toBool();

    _ui.setupUi(_widget);
    _widget->addAction(_ui.actionInspect);
    _widget->addAction(_ui.actionRestore);
    _widget->addAction(_ui.actionDelete);
    _ui.inspectButton->setDefaultAction(_ui.actionInspect);
    _ui.jobButton->setDefaultAction(_ui.actionGoToJob);
    _ui.restoreButton->setDefaultAction(_ui.actionRestore);
    _ui.deleteButton->setDefaultAction(_ui.actionDelete);
    connect(_ui.actionDelete, &QAction::triggered, this,
            &ArchiveListItem::requestDelete);
    connect(_ui.actionInspect, &QAction::triggered, this,
            &ArchiveListItem::requestInspect);
    connect(_ui.actionRestore, &QAction::triggered, this,
            &ArchiveListItem::requestRestore);
    connect(_ui.actionGoToJob, &QAction::triggered, this,
            &ArchiveListItem::requestGoToJob);

    setArchive(archive);
}
Exemplo n.º 3
0
Error QTar::extract()
{
	//ifstream ofstream to seekg()
	QArchive::extract();

	if(!exists()) return Archive::OpenError;
	char buff[Header::RecordSize];
	//QFile outFile;
	//FILE* f;
	size_t bytes_read;
	unsigned int filesize;

#if ARCREADER_QT4
	if(!open(QIODevice::ReadOnly)) {
		error();
#else
	if(open(IO_ReadOnly)) {
		qDebug("open error");
#endif //ARCREADER_QT4
		return Archive::OpenError;
	}
	Q_D(QArchive);
	for (;;) {
#if ARCREADER_QT4
		bytes_read = read(buff,Header::RecordSize);
#else
		bytes_read = readBlock(buff,Header::RecordSize);
#endif //ARCREADER_QT4
		//put them here
		emit byteProcessed(d->processedSize+=Header::RecordSize);
		d->current_fileName=QFileInfo(buff).fileName();

		if (bytes_read < Header::RecordSize) {
			fprintf(stderr,"Short read. expected 512, got %d\n", bytes_read);
			return Archive::ReadError;
		}
		if (isEndBuff(buff)) {
#if USE_SLOT
			emit byteProcessed(d->processedSize+=Header::RecordSize);  //header;
#else
			estimate();
			progressHandler->Progress(d->current_fileName, d->size, d->processedSize+=Header::RecordSize, d->totalSize, d->speed, d->elapsed, d->left);
#endif
			finishMessage();
			return End;
		}
		if (!verifyChecksum(buff)) {
			fprintf(stderr, "Checksum failure\n");
			return ChecksumError;
		}

		switch (buff[156]) {
		case Header::LinkFlag::kLink :			printf(" Ignoring hardlink %s\n", buff); break;
		case Header::LinkFlag::kSymbolicLink :	printf(" Ignoring symlink %s\n", buff); break; /////////////////////////
		case Header::LinkFlag::kCharacter:		printf(" Ignoring character device %s\n", buff); break;
		case Header::LinkFlag::kBlock:			printf(" Ignoring block device %s\n", buff); break;
		case Header::LinkFlag::kDirectory:
			createDir(QString::fromLocal8Bit(buff), parseOct(buff + 100, 8));
			filesize = 0;
			break;
		case Header::LinkFlag::kFIFO:			printf(" Ignoring FIFO %s\n", buff); break;
		default:
			createFile(QString::fromLocal8Bit(buff), parseOct(buff + 100, 8));
			break;
		}

		++d->numFiles;
		filesize = parseOct(buff + 124, 12);
		d->size = filesize;
#if USE_SLOT
		updateMessage();
#endif
		while (filesize > 0) {
			checkTryPause();
#if ARCREADER_QT4
			bytes_read = read(buff,Header::RecordSize);
#else
			bytes_read = readBlock(buff,Header::RecordSize);
#endif //ARCREADER_QT4
			if (bytes_read < Header::RecordSize) {
				fprintf(stderr,"Short read. Expected 512, got %d\n",bytes_read);
				return Archive::ReadError;
			}
			if (filesize < Header::RecordSize) bytes_read = filesize;
			if (d->outFile.isOpen()) {
#if CONFIG_QT4
				if(d->outFile.write(buff,bytes_read)!=bytes_read) {
					fprintf(stderr, "[%s] %s @%d: Failed to write %s\n",__FILE__,__PRETTY_FUNCTION__,__LINE__,qPrintable(d->outFile.fileName()));
#else
				if(d->outFile.writeBlock(buff,bytes_read)!=bytes_read) {
					fprintf(stderr, "[%s] %s @%d: Failed to write %s\n",__FILE__,__PRETTY_FUNCTION__,__LINE__,qPrintable(d->outFile.name()));
#endif
					d->outFile.close();
				}
				/*if (fwrite(buff, 1, bytes_read, f)!= bytes_read) {
					fprintf(stderr, "Failed write\n");
					fclose(f);
					f = NULL;
				}*/
			}
#if USE_SLOT
			forceShowMessage(1000);
			emit byteProcessed(d->processedSize+=Header::RecordSize);//bytes_read);
#else
			estimate();
			progressHandler->Progress(d->current_fileName, d->size, d->processedSize+=Header::RecordSize, d->totalSize, d->speed, d->elapsed, d->left);
#endif
			filesize -= bytes_read;
		}
		//emit byteProcessed(processedSize+=size);
		if(d->outFile.isOpen()) d->outFile.close();
	}
	close();
}

Archive::Error QTar::extract(const QString& archive,const QString& dir)
{
	setArchive(archive);
	setOutDir(dir);

	return extract();
}
Exemplo n.º 4
0
void ArchiveListItem::update()
{
    setArchive(_archive);
}
//----------------------------------------------------------------------------//
MinizipResourceProvider::MinizipResourceProvider(const String& archive,
                                                 bool loadLocal) :
    d_pimpl(new Impl(loadLocal))
{
    setArchive(archive);
}