当前位置: 首页>>代码示例>>C++>>正文


C++ QTemporaryFile::remove方法代码示例

本文整理汇总了C++中QTemporaryFile::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ QTemporaryFile::remove方法的具体用法?C++ QTemporaryFile::remove怎么用?C++ QTemporaryFile::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QTemporaryFile的用法示例。


在下文中一共展示了QTemporaryFile::remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: replyFinished

void BrisaControlPoint::replyFinished(QNetworkReply *reply) {
    QTemporaryFile *rootXml = new QTemporaryFile();
    if (!rootXml->open()) {
        qWarning() << "Brisa Control Point: Failed to open file for writing root XML.";
    } else {
        rootXml->write(reply->readAll());
        rootXml->seek(0);
        QUrl *urlBase = new QUrl(reply->url());

        BrisaControlPointDevice *device = new BrisaControlPointDevice(rootXml, urlBase);

        /* Fix embedded devices host/port attributes */
        QList<BrisaControlPointService*> serviceList = device->getServiceList();
        foreach(BrisaControlPointService *s, serviceList) {
                s->setAttribute(BrisaControlPointService::Host, urlBase->host());
                s->setAttribute(BrisaControlPointService::Port,
                        QString().setNum(urlBase->port()));
        }

        rootXml->remove();
        delete rootXml;
        delete urlBase;
        // deleteLater as per Qt documentation (see Detailed Description section of
        // QNetworkAccessManager class documentation for more details;
        reply->deleteLater();

        emit deviceFound(device);
    }
开发者ID:MIRAvzw,项目名称:qt-brisa,代码行数:28,代码来源:brisacontrolpoint.cpp

示例2:

QString WebPuppeteerTab::printBase64() {
	QTemporaryFile t;
	if (!t.open()) return QString();
	if (!print(t.fileName())) return QString();
	QByteArray data = t.readAll();
	t.remove();
	return QString::fromLatin1(data.toBase64());
}
开发者ID:,项目名称:,代码行数:8,代码来源:

示例3: GetTemporaryName

	QString GetTemporaryName (const QString& pattern)
	{
		QTemporaryFile file (QDir::tempPath () + "/" + pattern);
		file.open ();
		QString name = file.fileName ();
		file.close ();
		file.remove ();
		return name;
	}
开发者ID:ForNeVeR,项目名称:leechcraft,代码行数:9,代码来源:paths.cpp

示例4: tmpf

void
ProcessInputChannel::initialize()
{
    _backgroundOutputPipe = new QLocalSocket();
    QObject::connect( _backgroundOutputPipe, SIGNAL(connected()), this, SLOT(onOutputPipeConnectionMade()) );
    _backgroundOutputPipe->connectToServer(_mainProcessServerName,QLocalSocket::ReadWrite);
    std::cout << "Attempting connection to " << _mainProcessServerName.toStdString() << std::endl;

    _backgroundIPCServer = new QLocalServer();
    QObject::connect( _backgroundIPCServer,SIGNAL(newConnection()),this,SLOT(onNewConnectionPending()) );


    QString tmpFileName;
#if defined(Q_OS_WIN)
    tmpFileName += QString::fromUtf8("//./pipe");
    tmpFileName += QLatin1Char('/');
    tmpFileName += QString::fromUtf8(NATRON_APPLICATION_NAME);
    tmpFileName += QString::fromUtf8("_INPUT_SOCKET");
#endif

    {
#if defined(Q_OS_UNIX)
        QTemporaryFile tmpf(tmpFileName);
        tmpFileName = tmpf.fileName();
        tmpf.remove();
#else
        QTemporaryFile tmpf;
        tmpf.open();
        QString tmpFilePath = tmpf.fileName();
        QString baseName;
        int lastSlash = tmpFilePath.lastIndexOf(QLatin1Char('/'));
        if (lastSlash != -1 && lastSlash < tmpFilePath.size() - 1) {
            baseName = tmpFilePath.mid(lastSlash + 1);
        } else {
            baseName = tmpFilePath;
        }
        tmpFileName += baseName;
        tmpf.remove();
#endif
    }
    _backgroundIPCServer->listen(tmpFileName);

    if ( !_backgroundOutputPipe->waitForConnected(5000) ) { //< blocking, we wait for the server to respond
        std::cout << "WARNING: The GUI application failed to respond, canceling this process will not be possible"
            " unless it finishes or you kill it." << std::endl;
    }
    writeToOutputChannel( QString::fromUtf8(kBgProcessServerCreatedShort) + tmpFileName );

    ///we wait for the GUI app to connect its socket to this server, we let it 5 sec to reply
    _backgroundIPCServer->waitForNewConnection(5000);

    ///since we're still not returning the event loop, just process them manually in case
    ///Qt didn't caught the new connection pending.
    QCoreApplication::processEvents();
}
开发者ID:JamesLinus,项目名称:Natron,代码行数:55,代码来源:ProcessHandler.cpp

示例5: temporaryFileName

  QString QTAIMCriticalPointLocator::temporaryFileName()
  {
    QTemporaryFile temporaryFile;
    temporaryFile.open();
    QString temporaryFileName=temporaryFile.fileName();
    temporaryFile.close();
    temporaryFile.remove();

    // wait for temporary file to be deleted
    QDir dir;
    do
    {
      // Nothing
    } while ( dir.exists(temporaryFileName) );

    return temporaryFileName;
  }
开发者ID:AlbertDeFusco,项目名称:avogadro,代码行数:17,代码来源:qtaimcriticalpointlocator.cpp

示例6: testParserWithBadData

void CMakeParserTest::testParserWithBadData()
{
    QFETCH( QString, text );
    QTemporaryFile tempFile;
    tempFile.setAutoRemove( false );
    tempFile.open();
    if ( !QFile::exists( tempFile.fileName() ) )
        QFAIL( "Unable to open temporary file" );

    tempFile.write( text.toUtf8() );
    QString tempName = tempFile.fileName();
    tempFile.close(); //hacks to the get name of the file
//    CMakeAst* ast = new CMakeAst;
//    bool parseError = CMakeListsParser::parseCMakeFile( ast, qPrintable( tempName ) );
//    delete ast;
//    QVERIFY( parseError == true );
    tempFile.remove();
}
开发者ID:portaloffreedom,项目名称:kdev-golang-plugin,代码行数:18,代码来源:cmakeparsertest.cpp

示例7: testLexerWithFile

void CMakeParserTest::testLexerWithFile()
{
    QTemporaryFile tempFile;
    tempFile.setAutoRemove( false );
    tempFile.open();
    if ( !QFile::exists( tempFile.fileName() ) )
         QFAIL( "Unable to open temporary file" );

    QString tempName = tempFile.fileName();
    tempFile.close(); //hacks to the get name of the file

    cmListFileLexer* lexer = cmListFileLexer_New();
    if ( !lexer )
        QFAIL( "unable to create lexer" );
    QVERIFY( cmListFileLexer_SetFileName( lexer, qPrintable( tempName ) ) );
    cmListFileLexer_Delete( lexer );
    tempFile.remove();
}
开发者ID:portaloffreedom,项目名称:kdev-golang-plugin,代码行数:18,代码来源:cmakeparsertest.cpp

示例8: extract

bool SevenZip::extract()
{
    m_sevenz.setProgram(m_sevenZip);

    QTemporaryFile progress;
    progress.open();

    QStringList args;
    args << "x" << "-y"
         << m_archiveFile
         << m_outputDir
#ifndef Q_OS_MAC
         << "-bsp2";
#else
         ;
#endif

    QStringList env = QProcess::systemEnvironment();
    env << "VDPAU_DRIVER=va_gl";

    m_sevenz.setArguments(args);
    m_sevenz.setStandardErrorFile(progress.fileName());

    qDebug() << m_sevenz.program() << m_sevenz.arguments().join(" ");
    m_sevenz.start();
    m_sevenz.waitForStarted(-1);

#ifdef Q_OS_LINUX
    QProcess::execute(QString("ionice -c3 -p %1").arg(m_sevenz.pid()));
#endif

    m_szpp->setProgressName(progress.fileName());
    m_szpp->start();
    m_sevenz.waitForFinished(-1);
    m_szpp->wait();

    progress.close();
    progress.remove();

    qDebug() << m_sevenz.exitStatus() << m_sevenz.exitCode();

    return (m_sevenz.exitStatus() == QProcess::NormalExit) &&
           (0 == m_sevenz.exitCode());
}
开发者ID:linuxdeepin,项目名称:deepin-boot-maker,代码行数:44,代码来源:sevenzip.cpp

示例9: removeAndReOpen

void tst_QTemporaryFile::removeAndReOpen()
{
    QString fileName;
    {
        QTemporaryFile file;
        file.open();
        fileName = file.fileName();
        QVERIFY(QFile::exists(fileName));

        file.remove();
        QVERIFY(!QFile::exists(fileName));

        QVERIFY(file.open());
        QCOMPARE(QFileInfo(file.fileName()).path(), QFileInfo(fileName).path());
        fileName = file.fileName();
        QVERIFY(QFile::exists(fileName));
    }
    QVERIFY(!QFile::exists(fileName));
}
开发者ID:MarianMMX,项目名称:MarianMMX,代码行数:19,代码来源:tst_qtemporaryfile.cpp

示例10: build

void ArchivBuilder::build( QByteArray stubData, QString fileName ) {
    QTemporaryFile tmpArchiv;
    tmpArchiv.open();
    qDebug() << "Will create temporarty file: " << tmpArchiv.fileName();
    QDataStream ds( &tmpArchiv );
    ds.writeRawData( stubData, stubData.size() );

    // Set dataMarker
    for( uint i = 0; i < ArchivBuilder::DATA_MARKER_LENGTH - 1; i++ ) {
        ds.writeRawData( ArchivBuilder::DATA_MARKER + i , 1 );
    }

    // qDebug() << "Marker size: " << ArchivBuilder::DATA_MARKER_LENGTH;
    ds.writeRawData( ArchivBuilder::DATA_MARKER_REPLACECHAR + 0 , 1 );
    QByteArray indexData = _index->compressedIndexData();
    int indexSize = indexData.size();
    qDebug() << "Index size: " << indexSize;
    QString indexSizeString;
    indexSizeString.setNum( indexSize );
    ds.writeRawData( indexSizeString.toAscii(), indexSizeString.toAscii().size() );
    ds.writeRawData( "\n", 1 );
    // qDebug() << "Wrote size string: " << indexSizeString.toAscii();
    ds.writeRawData( indexData, indexData.size() );
    QByteArray archivData = _data->data();
    ds.writeRawData( archivData, archivData.size() );
    qDebug() << "Wrote data section of size: " <<  archivData.size();

    if ( QFileInfo( fileName ).exists() ) {
        QFile( fileName ).remove();
        // QFile( fileName ).rename( QString( "%1_back_%2" ).arg( fileName ).arg( RedBullPlayer::Tools::UuidCreator::create() ) );
    }

    if(  tmpArchiv.copy( fileName ) ) {
        qDebug() << "Created Archive at: " << QFileInfo( fileName ) .absoluteFilePath();
    } else {
        qWarning() << "Could not copy archiv file to: " <<  QFileInfo( fileName ) .absoluteFilePath();
    }

    qDebug() << "Will create temporarty file: " << tmpArchiv.fileName();
    tmpArchiv.close();
    tmpArchiv.remove();
}
开发者ID:baoping,项目名称:Red-Bull-Media-Player,代码行数:42,代码来源:ArchivBuilder.cpp

示例11: serializeEntryToOutbox

QString System::serializeEntryToOutbox (Entry * entry) {
    if (entry == 0) {
        qWarning() << "Null entry not accepted";
        return "";
    }

    // Create path if needed
    QDir dir;
    if(!(dir.exists(entryOutputPath ()))) {
        if(!dir.mkpath(entryOutputPath ())) {
            qCritical() << "Could not create path" << dir.absolutePath();
            return "";
        }
    }

    // Start with template
    QString entryPath = entryOutputPath () + "/entry_XXXXXX.xml";

    // Make temp file
    QTemporaryFile tempFile (entryPath);
    tempFile.setAutoRemove (false);
    if (tempFile.open()) {
        entryPath = tempFile.fileName();
        tempFile.close();
    } else {
        qWarning() << "Can't create temp file" << tempFile.fileName();
        return "";
    }

    // Try to serialize
    if (entry->serialize(entryPath)) {
        qDebug() << "Entry serialized to" << entryPath;
        return entryPath;
    } else {
        qCritical() << "Failed to serialize entry to" << entryPath;
        // Clean out temp file left behind
        tempFile.remove ();
        return "";
    }
}
开发者ID:nemomobile-graveyard,项目名称:webupload-engine,代码行数:40,代码来源:system.cpp

示例12: getNewConsole

QString KCExecutor::getNewConsole()
{
    /*
     * For more information about xTerm, please visit:
     * http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.cmds/doc/aixcmds6/xterm.htm
     *
     * Use a temp file to receive tty destination.
     *
     */
    QTemporaryFile ttyReceiver;
    if(ttyReceiver.open())
    {
        QStringList args;
        //Reset console.
        QSharedPointer<QProcess> console;
        console.reset(new QProcess);
        //Get default terminal.
        Terminal terminal=KCRunner::getDefaultTerminal();
        args<<"-hold"<<"-e"<<"tty>" + ttyReceiver.fileName() +"; while :;do sleep 3600;done";
        console->start(QLatin1String(terminal.terminal_name), args);
        QTextStream _textIn(&ttyReceiver);
        QString tty;
        tty.clear();
        while(tty.length()==0)
        {
            tty=QString(_textIn.readAll());
        }
        tty.remove("\n");
        ttyReceiver.close();
        ttyReceiver.remove();
        //Save console.
        KCExecutor::getInstance()->consoles[tty]=QSharedPointer<QProcess>(console);
        return QString(tty);
    }
    return QString("");
}
开发者ID:Kreogist,项目名称:Cuties,代码行数:36,代码来源:kcexecutor.cpp

示例13: run

void ExportThread::run()
{
    QList< QStringList > archived_books;
    QHash<QString, QList<QStringList> > archive_map; // archive_name => book_info
    QStringList books_ids;
    QPair<QString, QString> pair;
    QStringList bi;
    QString basename;

    foreach (int book_id, p->books) {
        pair = Eclibrus::Db::archivedBookFile(book_id);
        basename = Eclibrus::Plain::bookFileName(book_id);
        if (!archive_map.contains(pair.first)) {
            archive_map[pair.first] = QList<QStringList>();
        }
        bi.clear();
        bi << pair.second << basename;
        archive_map[pair.first] << bi;
    }

    int total_books = p->books.size();
    QString library_path = Eclibrus::Config::librusecLibraryPath() + QDir::separator();
    QString archive_path;
    QString output_path;
    QFileInfo fi;

    const int INITIAL_PROGRESS = 2;
    emit progress(INITIAL_PROGRESS);
    float ppf = (100 - INITIAL_PROGRESS) / total_books;
    int n = 0;
    int percent = 0;

    switch (p->di.devType) {
        case Eclibrus::DeviceInfo::MSD: {
            // copy books to mass storage devuce
            foreach (const QString & archive, archive_map.keys()) {
                archive_path = library_path + archive;

                foreach (const QStringList & book_info, archive_map[archive]) {
                    ++n;
                    output_path = p->outputDir + QDir::separator() + book_info[1] + ".fb2.zip";
                    fi.setFile(output_path);
                    if (true/*!fi.exists()*/) {
                        FB2::exportBookToArchive(archive_path, book_info[0], output_path);
                    } else {
                        qDebug() << "file already exists:" << output_path;
                    }
                    percent = (int)(ppf*n);
                    emit progress(percent+INITIAL_PROGRESS);
                }
            }
            break;
        }

        case Eclibrus::DeviceInfo::WEBDAV: {
            QWebDav wd;
            QUrl uri(p->di.uri);

            QString host = uri.host();
            int port = uri.port();
            if (port == -1) {
                port = 80;
            }

            wd.connectToHost(host, port, uri.path(), uri.userName(), uri.password());
            if (QWebDav::NoError != wd.lastError()) {
                qWarning() << "Failed to init WebDav link: " << p->di.uri;
                return;
            }

            // upload books to WEBDAV device
            // p->outputDir is a collection path on webdav device, files should be placed there
            foreach (const QString & archive, archive_map.keys()) {
                archive_path = library_path + archive;
                foreach (const QStringList & book_info, archive_map[archive]) {
                    ++n;

                    // export to temporary file
                    QTemporaryFile tf;
                    tf.setAutoRemove(false);
                    tf.open();
                    output_path = tf.fileName();
                    qDebug() << "filename:" << output_path;
                    tf.close();
                    FB2::exportBookToArchive(archive_path, book_info[0], output_path);

                    // now copy file "output_path" to the device
                    QString webdavName = p->outputDir + "/" + book_info[1] + ".fb2.zip";
                    qDebug() << "webdav name" << webdavName;
                    wd.put(output_path, webdavName);
                    if (QWebDav::NoError != wd.lastError()) {
                        qWarning() << "Failed to copy local file to WebDav device";
                    }
                    tf.remove();
                }
            }
            break;
        }
开发者ID:sigsergv,项目名称:eclibrus,代码行数:98,代码来源:exportbooksthread.cpp

示例14: sendNotification

// Convienence function to send notifications.  This function does some processing
// of the arguments.  In these functions:
//    expire_timeout: The amount of time in milliseconds the message is shown.
//                    A value of -1 means timeout is based on server's settings.
//    overwrite     : Will overwrite the previous message sent from this function.
//                    It will not overwrite notifications sent by other programs. 
//
//
// Show notification with summary, app_name, and body text
void NotifyClient::sendNotification ()
{
  // make sure we have a connection we can send the notification to.
  if (! b_validconnection) return;  
  
  // variables
  QString app_name = s_app_name;  
  quint32 replaces_id = 0;
  QString app_icon = "";
  QString body = ""; 
  QString summary = s_summary;
  QStringList actions = QStringList();
  QVariantMap hints;
  int expire_timeout = i_expire_timeout;
  
  // set replaces_id
  if (b_overwrite) replaces_id = current_id;
  
  // assemble the hints
  hints.clear();
  hints.insert("urgency", QVariant::fromValue(static_cast<uchar>(i_urgency)) );
  //if (! app_icon.isEmpty() ) hints.insert("image-path", QVariant::fromValue(app_icon));
  
  // make sure we can display the text on this server
  if (sl_capabilities.contains("body", Qt::CaseInsensitive) ) {
    body = s_body;
    if (! sl_capabilities.contains ("body-markup", Qt::CaseInsensitive) ) {
      QTextDocument td;
      td.setHtml(body);
      body = td.toPlainText();
    } // if server cannot display markup
  } // if capabilities contains body
  
  // process the icon, if we are using a fallback icon create a temporary file to hold it
    QTemporaryFile*  tempfileicon = NULL; 
    if (! s_icon.isEmpty() ) {   
			if (QFile::exists(s_icon) ) {
				tempfileicon = new QTemporaryFile(this);
				tempfileicon->setAutoRemove(false);
				if (tempfileicon->open() ) {
					QPixmap px = QPixmap(s_icon);
					px.save(tempfileicon->fileName(),"PNG");
					app_icon =  tempfileicon->fileName().prepend("file://");
				} // if tempfileicon could be opened
			} // if s_icon exists as a disk file

			// assume s_icon exists as a theme icon, don't check it here.  That
			// check needs to be done in the calling program.
			else app_icon = s_icon;
		} // if s_icon is not empty
    
  QDBusReply<quint32> reply = notifyclient->call(QLatin1String("Notify"), app_name, replaces_id, app_icon, summary, body, actions, hints, expire_timeout);
  
  if (reply.isValid() ) {
		current_id = reply.value();
    if (file_map.contains(current_id) && tempfileicon != NULL) {
			if (b_overwrite) {
				file_map.value(current_id)->remove();
				delete file_map.value(current_id);
				file_map.remove(current_id);				
			}	// if
			else {
				tempfileicon->remove();
				delete tempfileicon;
				tempfileicon = NULL;
			}	// else
		}	// if contains current_id and not NULL
		if (tempfileicon != NULL) file_map[current_id] = tempfileicon;
  }	// if reply is valid
  
  else
	#if QT_VERSION >= 0x050400 
		qCritical("CMST - Error reply received to the Notify method: %s", qUtf8Printable(reply.error().message()) );
  #else
    qCritical("CMST - Error reply received to the Notify method: %s", qPrintable(reply.error().message()) );
  #endif
  
  return;
} 
开发者ID:andrew-bibb,项目名称:cmst,代码行数:88,代码来源:notify.cpp

示例15: tmpf

ProcessHandler::ProcessHandler(const QString & projectPath,
                               const NodePtr& writer)
    : _process(new QProcess)
    , _writer(writer)
    , _ipcServer(0)
    , _bgProcessOutputSocket(0)
    , _bgProcessInputSocket(0)
    , _earlyCancel(false)
    , _processLog()
    , _processArgs()
{
    ///setup the server used to listen the output of the background process
    _ipcServer = new QLocalServer();
    QObject::connect( _ipcServer, SIGNAL(newConnection()), this, SLOT(onNewConnectionPending()) );
    QString tmpFileName;
#if defined(Q_OS_WIN)
    tmpFileName += QString::fromUtf8("//./pipe");
    tmpFileName += QLatin1Char('/');
    tmpFileName += QString::fromUtf8(NATRON_APPLICATION_NAME);
    tmpFileName += QString::fromUtf8("_INPUT_SOCKET");
#endif

    {
#if defined(Q_OS_UNIX)
        QTemporaryFile tmpf(tmpFileName);
        tmpf.open();
        tmpFileName = tmpf.fileName();
        tmpf.remove();
#else
        QTemporaryFile tmpf;
        tmpf.open();
        QString tmpFilePath = tmpf.fileName();
        QString baseName;
        int lastSlash = tmpFilePath.lastIndexOf( QLatin1Char('/') );
        if ( (lastSlash != -1) && (lastSlash < tmpFilePath.size() - 1) ) {
            baseName = tmpFilePath.mid(lastSlash + 1);
        } else {
            baseName = tmpFilePath;
        }
        tmpFileName += baseName;
        tmpf.remove();
#endif
    }
    _ipcServer->listen(tmpFileName);


    _processArgs << QString::fromUtf8("-b") << QString::fromUtf8("-w") << QString::fromUtf8( writer->getScriptName_mt_safe().c_str() );
    _processArgs << QString::fromUtf8("--IPCpipe") <<  tmpFileName;
    _processArgs << projectPath;

    ///connect the useful slots of the process
    QObject::connect( _process, SIGNAL(readyReadStandardOutput()), this, SLOT(onStandardOutputBytesWritten()) );
    QObject::connect( _process, SIGNAL(readyReadStandardError()), this, SLOT(onStandardErrorBytesWritten()) );
    QObject::connect( _process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(onProcessError(QProcess::ProcessError)) );
    QObject::connect( _process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(onProcessEnd(int,QProcess::ExitStatus)) );


    ///start the process
    _processLog.push_back( tr("Starting background rendering: %1 %2")
                           .arg( QCoreApplication::applicationFilePath() )
                           .arg( _processArgs.join( QString::fromUtf8(" ") ) ) );
}
开发者ID:kcotugno,项目名称:Natron,代码行数:62,代码来源:ProcessHandler.cpp


注:本文中的QTemporaryFile::remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。