ClangCodeModelConnectionClient::ClangCodeModelConnectionClient( ClangCodeModelClientInterface *client) : serverProxy_(client, ioDevice()) { stdErrPrefixer().setPrefix("clangbackend.stderr: "); stdOutPrefixer().setPrefix("clangbackend.stdout: "); }
ClangPchManager::PchManagerConnectionClient::PchManagerConnectionClient( ClangBackEnd::PchManagerClientInterface *client) : ConnectionClient(Utils::TemporaryDirectory::masterDirectoryPath() + QStringLiteral("/ClangPchManagerBackEnd-") + currentProcessId()), m_serverProxy(client, ioDevice()) { m_processCreator.setTemporaryDirectoryPattern("clangpchmanagerbackend-XXXXXX"); QDir pchsDirectory(Core::ICore::cacheResourcePath()); pchsDirectory.mkdir("pchs"); pchsDirectory.cd("pchs"); m_processCreator.setArguments({connectionName(), Core::ICore::cacheResourcePath() + "/symbol-experimental-v1.db", pchsDirectory.absolutePath()}); stdErrPrefixer().setPrefix("PchManagerConnectionClient.stderr: "); stdOutPrefixer().setPrefix("PchManagerConnectionClient.stdout: "); }
bool TarImpl::removeFiles( const QStringList& _files ) { if ( !ensureInMode( ArchiveImpl::Remove ) ) { qDebug( "Couldn't change mode for removeFile" ); return false; } Q_ASSERT( m_mode == ArchiveImpl::Remove ); // need to cut out the sections which apply to // files which need are to be removed. no // api on QIODevice to do this, so read into a // QByteArray, modify it, and write it back. QIODeviceCloser ioDevice( m_ioDevice, QIODevice::ReadOnly, m_ioDevice->openMode() ); // first gather the positions and sizes of any files to be removed std::vector< std::pair<int,int> > removals; if ( !firstFile() ) { // The archive is empty return false; } unsigned int toremove(0); QStringList files( _files ); while( true ) { const int index = files.indexOf( m_dev->fileName() ); if ( index != -1 ) { const tar::TarHeader& curInfo = tarDevice()->headerInfo(); // start position const int pos = curInfo.pos(); // size of entry (header+data+block padding) const int size = curInfo.totalSize(); removals.push_back( std::pair< int, int >(pos, size ) ); toremove += size; files.removeAt( index ); } // stop if there's nothing left to find if ( files.isEmpty() ) { break; } // Move on to the next file if ( !nextFile() ) { // We're out of files break; } } if ( removals.empty() ) { qWarning( "No matching files were found to be removed" ); return false; } ioDevice->reset(); QByteArray data = ioDevice->readAll(); ioDevice->close(); // \todo better to copy the files we want to keep into a new QByteArray or // cut out the files we don't want? could compare size of archive with amount to be // removed // track how much has been removed as this modifies the start pos for // each removal block unsigned int removed(0); std::vector< std::pair<int,int> >:: const_iterator I = removals.begin(); std::vector< std::pair<int,int> >:: const_iterator E = removals.end(); for ( ; I!=E; ++I ) { data.remove( I->first - removed, I->second ); removed += I->second; } Q_ASSERT( toremove == removed ); ioDevice->open( QIODevice::WriteOnly | QIODevice::Truncate ); ioDevice->write( data ); return true; }