Example #1
1
QString AndroidToolChain::makeCommand(const Environment &env) const
{
    FileName makePath = AndroidConfigurations::currentConfig().makePath();
    if (makePath.exists())
        return makePath.toString();
    const Utils::FileNameList extraDirectories
            = Utils::transform(AndroidConfigurations::currentConfig().makeExtraSearchDirectories(),
                               [](const QString &s) { return Utils::FileName::fromString(s); });
    if (HostOsInfo::isWindowsHost()) {
        makePath = env.searchInPath("ma-make.exe", extraDirectories);
        if (!makePath.isEmpty())
            return makePath.toString();
        makePath = env.searchInPath("mingw32-make", extraDirectories);
        return makePath.isEmpty() ? QLatin1String("mingw32-make") : makePath.toString();
    }

    makePath = env.searchInPath("make", extraDirectories);
    return makePath.isEmpty() ? "make" : makePath.toString();
}
Example #2
0
static PortInfo getPortInfo(const FileName & filename){
	PortInfo info;
	
	const auto parts = split(filename.getFile(),':');
	
	info.portName  = parts.empty() ? "" : parts[0];
#ifdef _WIN32
	info.internalPortName =  "\\\\.\\" + info.portName;
#else
	info.internalPortName = info.portName;
#endif
	info.baudRate = 9600;
	info.bytesize = serial::eightbits;
	info.stopbits = serial::stopbits_one;
	info.flowcontrol = serial::flowcontrol_none;
	info.parity = serial::parity_none;
for(auto& s:parts)
//	std::cout << ">"<<s<<"\n";

	if(parts.size()>1){
		info.baudRate = StringUtils::toNumber<uint32_t>(parts[1]);
		if(parts.size()>2){
			switch(StringUtils::toNumber<uint32_t>(parts[2])){
				case 5:	info.bytesize = serial::fivebits;	break;
				case 6:	info.bytesize = serial::sixbits;	break;
				case 7:	info.bytesize = serial::sevenbits;	break;
				case 0:// empty -> default
				case 8:	info.bytesize = serial::eightbits;	break;
				default:
					throw std::invalid_argument("SerialProvider: invalid bytesize :"+filename.toString());
			}
			if(parts.size()<=3 || parts[3].empty() || parts[3]=="n"){
				info.parity = serial::parity_none;
			}else if(parts[3]=="o"){
				info.parity = serial::parity_odd;
			}else if(parts[3]=="e"){
				info.parity = serial::parity_even;
			}else{
				throw std::invalid_argument("SerialProvider: invalid parity :"+filename.toString());
			}
			if(parts.size()<=4 || parts[4].empty() || parts[4]=="1"){
				info.stopbits = serial::stopbits_one;
			}else if(parts[4]=="2"){
				info.stopbits = serial::stopbits_two;
			}else{
				throw std::invalid_argument("SerialProvider: invalid stopbits :"+filename.toString());
			}
			if(parts.size()<=5 || parts[5].empty() || parts[5]=="n"){
				info.flowcontrol = serial::flowcontrol_none;
			}else if(parts[5]=="h"){
				info.flowcontrol = serial::flowcontrol_hardware;
			}else if(parts[5]=="s"){
				info.flowcontrol = serial::flowcontrol_software;
			}else{
				throw std::invalid_argument("SerialProvider: invalid flowcontrol :"+filename.toString());
			}
		}
	}
	return info;
}
// Find Qt installation by running qmake
static QString findQtInstallPath(const FileName &qmakePath)
{
    if (qmakePath.isEmpty())
        return QString();
    QProcess proc;
    QStringList args;
    args.append(QLatin1String("-query"));
    args.append(QLatin1String("QT_INSTALL_HEADERS"));
    proc.start(qmakePath.toString(), args);
    if (!proc.waitForStarted()) {
        qWarning("%s: Cannot start '%s': %s", Q_FUNC_INFO, qPrintable(qmakePath.toString()),
           qPrintable(proc.errorString()));
        return QString();
    }
    proc.closeWriteChannel();
    if (!proc.waitForFinished()) {
        SynchronousProcess::stopProcess(proc);
        qWarning("%s: Timeout running '%s'.", Q_FUNC_INFO, qPrintable(qmakePath.toString()));
        return QString();
    }
    if (proc.exitStatus() != QProcess::NormalExit) {
        qWarning("%s: '%s' crashed.", Q_FUNC_INFO, qPrintable(qmakePath.toString()));
        return QString();
    }
    const QByteArray ba = proc.readAllStandardOutput().trimmed();
    QDir dir(QString::fromLocal8Bit(ba));
    if (dir.exists() && dir.cdUp())
        return dir.absolutePath();
    return QString();
}
DirectoryNode::DirectoryNode(const FileName &folderPath): Node(DirectoryNodeType,folderPath)
{
    _fileWatcher.addPath(folderPath.toString());
    connect(&_fileWatcher,SIGNAL(directoryChanged(QString)), this, SLOT(refresh()));

    _dirObject = QDir(folderPath.toString());

    setText(_dirObject.dirName());

    setIcon(QIcon(":/drawable/nodes/folder"));

    refresh();
}
QString AndroidToolChain::makeCommand(const Environment &env) const
{
    QStringList extraDirectories = AndroidConfigurations::currentConfig().makeExtraSearchDirectories();
    if (HostOsInfo::isWindowsHost()) {
        FileName tmp = env.searchInPath(QLatin1String("ma-make.exe"), extraDirectories);
        if (!tmp.isEmpty())
            return QString();
        tmp = env.searchInPath(QLatin1String("mingw32-make"), extraDirectories);
        return tmp.isEmpty() ? QLatin1String("mingw32-make") : tmp.toString();
    }

    QString make = QLatin1String("make");
    FileName tmp = env.searchInPath(make, extraDirectories);
    return tmp.isEmpty() ? make : tmp.toString();
}
Example #6
0
  /**
   * Writes a list of files to a file.
   *
   * @param list The name of the file to create. The method will overwrite any
   * existing files.
   *
   * @throws Isis::iException::Io File could not be created.
   */
  void FileList::write(FileName outputFileList) {
    // Open the file
    ofstream ostm;
    ostm.open(outputFileList.toString().toAscii().data(), std::ios::out);
    if (!ostm) {
      QString message = Message::FileOpen(outputFileList.toString());
      throw IException(IException::Io, message, _FILEINFO_);
    }

    // Internalize
    write(ostm);

    // Close the file
    ostm.close();
  }
Example #7
0
bool QMakeStep::init()
{
    QmakeBuildConfiguration *qt4bc = qmakeBuildConfiguration();
    const QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(target()->kit());

    if (!qtVersion)
        return false;

    QString args = allArguments();
    QString workingDirectory;

    if (qt4bc->subNodeBuild())
        workingDirectory = qt4bc->subNodeBuild()->buildDir();
    else
        workingDirectory = qt4bc->buildDirectory().toString();

    FileName program = qtVersion->qmakeCommand();

    QString makefile = workingDirectory;

    if (qt4bc->subNodeBuild()) {
        if (!qt4bc->subNodeBuild()->makefile().isEmpty())
            makefile.append(qt4bc->subNodeBuild()->makefile());
        else
            makefile.append(QLatin1String("/Makefile"));
    } else if (!qt4bc->makefile().isEmpty()) {
        makefile.append(QLatin1Char('/'));
        makefile.append(qt4bc->makefile());
    } else {
        makefile.append(QLatin1String("/Makefile"));
    }

    // Check whether we need to run qmake
    bool makefileOutDated = (qt4bc->compareToImportFrom(makefile) != QmakeBuildConfiguration::MakefileMatches);
    if (m_forced || makefileOutDated)
        m_needToRunQMake = true;
    m_forced = false;

    ProcessParameters *pp = processParameters();
    pp->setMacroExpander(qt4bc->macroExpander());
    pp->setWorkingDirectory(workingDirectory);
    pp->setCommand(program.toString());
    pp->setArguments(args);
    pp->setEnvironment(qt4bc->environment());
    pp->resolveAll();

    setOutputParser(new QMakeParser);

    QmakeProFileNode *node = static_cast<QmakeProject *>(qt4bc->target()->project())->rootQmakeProjectNode();
    if (qt4bc->subNodeBuild())
        node = qt4bc->subNodeBuild();
    QString proFile = node->path();

    m_tasks = qtVersion->reportIssues(proFile, workingDirectory);
    qSort(m_tasks);

    m_scriptTemplate = node->projectType() == ScriptTemplate;

    return AbstractProcessStep::init();
}
Example #8
0
void ProjectTree::updateExternalFileWarning()
{
    Core::IDocument *document = qobject_cast<Core::IDocument *>(sender());
    if (!document || document->filePath().isEmpty())
        return;
    Core::InfoBar *infoBar = document->infoBar();
    Core::Id externalFileId(EXTERNAL_FILE_WARNING);
    if (!document->isModified()) {
        infoBar->removeInfo(externalFileId);
        return;
    }
    if (!infoBar->canInfoBeAdded(externalFileId))
        return;
    const FileName fileName = document->filePath();
    const QList<Project *> projects = SessionManager::projects();
    if (projects.isEmpty())
        return;
    foreach (Project *project, projects) {
        FileName projectDir = project->projectDirectory();
        if (projectDir.isEmpty())
            continue;
        if (fileName.isChildOf(projectDir))
            return;
        // External file. Test if it under the same VCS
        QString topLevel;
        if (Core::VcsManager::findVersionControlForDirectory(projectDir.toString(), &topLevel)
                && fileName.isChildOf(FileName::fromString(topLevel))) {
            return;
        }
    }
Example #9
0
void GccToolChain::addToEnvironment(Environment &env) const
{
    if (!m_compilerCommand.isEmpty()) {
        FileName path = m_compilerCommand.parentDir();
        env.prependOrSetPath(path.toString());
    }
}
void QtVersionManager::triggerQtVersionRestore()
{
    disconnect(ProjectExplorer::ToolChainManager::instance(), SIGNAL(toolChainsLoaded()),
               this, SLOT(triggerQtVersionRestore()));

    bool success = restoreQtVersions();
    m_instance->updateFromInstaller(false);
    if (!success) {
        // We did neither restore our settings or upgraded
        // in that case figure out if there's a qt in path
        // and add it to the Qt versions
        findSystemQt();
    }

    emit m_instance->qtVersionsLoaded();
    emit m_instance->qtVersionsChanged(m_versions.keys(), QList<int>(), QList<int>());
    saveQtVersions();

    const FileName configFileName = globalSettingsFileName();
    if (configFileName.toFileInfo().exists()) {
        m_configFileWatcher = new FileSystemWatcher(m_instance);
        connect(m_configFileWatcher, SIGNAL(fileChanged(QString)),
                m_fileWatcherTimer, SLOT(start()));
        m_configFileWatcher->addFile(configFileName.toString(),
                                     FileSystemWatcher::WatchModifiedDate);
    } // exists
}
FileName PokySDKKitInformation::environmentFile(const Kit *kit)
{
    FileName envFile;
    ToolChain *tc = ToolChainKitInformation::toolChain(kit);
    if (tc)
    {
        envFile = findEnvFromCompiler(tc->compilerCommand());
        if (QFile::exists(envFile.toString()))
            return envFile;
    }

    envFile = findEnvFromSysroot(SysRootKitInformation::sysRoot(kit));
    if (QFile::exists(envFile.toString()))
        return envFile;
    else
        return FileName();
}
void AttachCoreDialog::coreFileChanged(const QString &core)
{
    Kit *k = d->kitChooser->currentKit();
    QTC_ASSERT(k, return);
    FileName cmd = DebuggerKitInformation::debuggerCommand(k);
    bool isCore = false;
    QString exe = readExecutableNameFromCore(cmd.toString(), core, &isCore);
    d->localExecFileName->setFileName(FileName::fromString(exe));
    changed();
}
FileName PokySDKKitInformation::findEnvFromSysroot(const FileName &sysRoot)
{
    const QString sysRootStr = sysRoot.toString();
    int idx = sysRootStr.indexOf(QLatin1String("/sysroots/"));
    if (idx < 0)
        return FileName();
    QString envFile = QString(QLatin1String("%1/environment-setup-%2"))
            .arg(sysRootStr.left(idx), sysRoot.toFileInfo().fileName());
    return FileName::fromString(envFile);
}
Example #14
0
std::unique_ptr<std::iostream> SerialProvider::open(const FileName & filename){
	const PortInfo info = getPortInfo(filename);
	std::unique_ptr<serial::Serial> port( new serial::Serial( info.internalPortName,info.baudRate,
															serial::Timeout(),info.bytesize,info.parity,
															info.stopbits,info.flowcontrol ));
	if(!port->isOpen())
		throw std::runtime_error("SerialProvider::open: Could not open port: "+filename.toString());
	
	return std::unique_ptr<std::iostream> (new SerialIOStream(std::move(port)));
}
void PokySDKKitInformation::addToEnvironment(const Kit *kit, Environment &env) const
{
    FileName pokyEnvFile = environmentFile(kit);
    if (pokyEnvFile.isEmpty())
        return;
    PokyRunner runner(pokyEnvFile.toString());
    QProcessEnvironment pokyEnv = runner.processEnvironment();
    foreach (QString key, pokyEnv.keys())
        env.set(key, pokyEnv.value(key));
}
Example #16
0
QList<HeaderPath> GccToolChain::gccHeaderPaths(const FileName &gcc, const QStringList &args,
                                               const QStringList &env, const FileName &sysrootPath)
{
    QList<HeaderPath> systemHeaderPaths;
    QStringList arguments;
    if (!sysrootPath.isEmpty())
        arguments.append(QString::fromLatin1("--sysroot=%1").arg(sysrootPath.toString()));
    foreach (const QString &a, args) {
        if (a.startsWith(QLatin1String("-stdlib=")))
            arguments << a;
    }

    arguments << QLatin1String("-xc++")
              << QLatin1String("-E")
              << QLatin1String("-v")
              << QLatin1String("-");

    QByteArray line;
    QByteArray data = runGcc(gcc, arguments, env);
    QBuffer cpp(&data);
    cpp.open(QIODevice::ReadOnly);
    while (cpp.canReadLine()) {
        line = cpp.readLine();
        if (line.startsWith("#include"))
            break;
    }

    if (!line.isEmpty() && line.startsWith("#include")) {
        HeaderPath::Kind kind = HeaderPath::UserHeaderPath;
        while (cpp.canReadLine()) {
            line = cpp.readLine();
            if (line.startsWith("#include")) {
                kind = HeaderPath::GlobalHeaderPath;
            } else if (! line.isEmpty() && QChar(QLatin1Char(line.at(0))).isSpace()) {
                HeaderPath::Kind thisHeaderKind = kind;

                line = line.trimmed();

                const int index = line.indexOf(" (framework directory)");
                if (index != -1) {
                    line.truncate(index);
                    thisHeaderKind = HeaderPath::FrameworkHeaderPath;
                }

                systemHeaderPaths.append(HeaderPath(QFile::decodeName(line), thisHeaderKind));
            } else if (line.startsWith("End of search list.")) {
                break;
            } else {
                qWarning("%s: Ignoring line: %s", __FUNCTION__, line.constData());
            }
        }
    }
    return systemHeaderPaths;
}
FileName PokySDKKitInformation::findEnvFromCompiler(const FileName &compilerCmd)
{
    const QString compilerCmdStr = compilerCmd.toString();
    int idx = compilerCmdStr.indexOf(QLatin1String("/sysroots/"));
    if (idx < 0)
        return FileName();
    QString target = compilerCmd.toFileInfo().fileName().remove(QLatin1String("-g++"));
    QString envFile = QString(QLatin1String("%1/environment-setup-%2"))
            .arg(compilerCmdStr.left(idx), target);
    return FileName::fromString(envFile);
}
Example #18
0
void AttachCoreDialog::coreFileChanged(const QString &core)
{
    if (!HostOsInfo::isWindowsHost() && QFile::exists(core)) {
        Kit *k = d->kitChooser->currentKit();
        QTC_ASSERT(k, return);
        FileName cmd = DebuggerKitInformation::debuggerCommand(k);
        GdbCoreEngine::CoreInfo cinfo =
            GdbCoreEngine::readExecutableNameFromCore(cmd.toString(), core);
        if (!cinfo.foundExecutableName.isEmpty())
            d->localExecFileName->setFileName(FileName::fromString(cinfo.foundExecutableName));
        else if (!d->localExecFileName->isValid() && !cinfo.rawStringFromCore.isEmpty())
            d->localExecFileName->setFileName(FileName::fromString(cinfo.rawStringFromCore));
    }
Example #19
0
static bool parseTaskFile(QString *errorString, const FileName &name)
{
    QFile tf(name.toString());
    if (!tf.open(QIODevice::ReadOnly)) {
        *errorString = TaskListPlugin::tr("Cannot open task file %1: %2").arg(
                name.toUserOutput(), tf.errorString());
        return false;
    }

    const FileName parentDir = name.parentDir();
    while (!tf.atEnd()) {
        QStringList chunks = parseRawLine(tf.readLine());
        if (chunks.isEmpty())
            continue;

        QString description;
        QString file;
        Task::TaskType type = Task::Unknown;
        int line = -1;

        if (chunks.count() == 1) {
            description = chunks.at(0);
        } else if (chunks.count() == 2) {
            type = typeFrom(chunks.at(0));
            description = chunks.at(1);
        } else if (chunks.count() == 3) {
            file = chunks.at(0);
            type = typeFrom(chunks.at(1));
            description = chunks.at(2);
        } else if (chunks.count() >= 4) {
            file = chunks.at(0);
            bool ok;
            line = chunks.at(1).toInt(&ok);
            if (!ok)
                line = -1;
            type = typeFrom(chunks.at(2));
            description = chunks.at(3);
        }
        if (!file.isEmpty()) {
            file = QDir::fromNativeSeparators(file);
            QFileInfo fi(file);
            if (fi.isRelative())
                file = FileName(parentDir).appendPath(file).toString();
        }
        description = unescape(description);

        TaskHub::addTask(type, description, Constants::TASKLISTTASK_ID,
                         FileName::fromUserInput(file), line);
    }
    return true;
}
FileName CMakeBuildConfiguration::shadowBuildDirectory(const FileName &projectFilePath,
                                                       const Kit *k,
                                                       const QString &bcName,
                                                       BuildConfiguration::BuildType buildType)
{
    if (projectFilePath.isEmpty())
        return FileName();

    const QString projectName = projectFilePath.parentDir().fileName();
    ProjectMacroExpander expander(projectFilePath.toString(), projectName, k, bcName, buildType);
    QDir projectDir = QDir(Project::projectDirectory(projectFilePath).toString());
    QString buildPath = expander.expand(ProjectExplorerPlugin::buildDirectoryTemplate());
    buildPath.replace(" ", "-");
    return FileName::fromUserInput(projectDir.absoluteFilePath(buildPath));
}
Example #21
0
  /**
   * Opens and loads the list of files from a file.
   *
   * @param list Name of the file to open that contains the list of files.
   *
   * @throws Isis::iException::Io - Cannot open file
   */
  void FileList::read(FileName listFile) {
    // Open the file
    ifstream istm;
    istm.open(listFile.toString().toAscii().data(), std::ios::in);
    if(!istm) {
      QString message = Isis::Message::FileOpen(listFile.toString());
      throw IException(IException::Io, message, _FILEINFO_);
    }

    // Internalize
    try {
      read(istm);

      // Close the file
      istm.close();
    }
    catch (IException &e) {
      printf("debugB\n");
      istm.close();
      QString msg = "File [" + listFile.toString() + "] contains no data";
      throw IException(IException::User, msg, _FILEINFO_);
    }

  }
Example #22
0
bool SubmitEditorFile::save(QString *errorString, const QString &fileName, bool autoSave)
{
    const FileName fName = fileName.isEmpty() ? filePath() : FileName::fromString(fileName);
    FileSaver saver(fName.toString(),
                    QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text);
    saver.write(m_editor->fileContents());
    if (!saver.finalize(errorString))
        return false;
    if (autoSave)
        return true;
    setFilePath(FileName::fromUserInput(fName.toFileInfo().absoluteFilePath()));
    setModified(false);
    if (!errorString->isEmpty())
        return false;
    emit changed();
    return true;
}
Example #23
0
void CMakeCbpParser::parseUnit()
{
    //qDebug()<<stream.attributes().value("filename");
    FileName fileName =
            FileName::fromUserInput(attributes().value(QLatin1String("filename")).toString());

    CMakeTool *tool = CMakeKitInformation::cmakeTool(m_kit);
    if (tool) {
        QString mappedFile = tool->mapAllPaths(m_kit, fileName.toString());
        fileName = FileName::fromUserInput(mappedFile);
    }

    m_parsingCmakeUnit = false;
    m_unitTarget.clear();
    while (!atEnd()) {
        readNext();
        if (isEndElement()) {
            if (!fileName.endsWith(QLatin1String(".rule")) && !m_processedUnits.contains(fileName)) {
                // Now check whether we found a virtual element beneath
                if (m_parsingCmakeUnit) {
                    m_cmakeFileList.append( new ProjectExplorer::FileNode(fileName, ProjectExplorer::ProjectFileType, false));
                } else {
                    bool generated = false;
                    QString onlyFileName = fileName.fileName();
                    if (   (onlyFileName.startsWith(QLatin1String("moc_")) && onlyFileName.endsWith(QLatin1String(".cxx")))
                        || (onlyFileName.startsWith(QLatin1String("ui_")) && onlyFileName.endsWith(QLatin1String(".h")))
                        || (onlyFileName.startsWith(QLatin1String("qrc_")) && onlyFileName.endsWith(QLatin1String(".cxx"))))
                        generated = true;

                    if (fileName.endsWith(QLatin1String(".qrc")))
                        m_fileList.append( new ProjectExplorer::FileNode(fileName, ProjectExplorer::ResourceType, generated));
                    else
                        m_fileList.append( new ProjectExplorer::FileNode(fileName, ProjectExplorer::SourceType, generated));
                }
                if (!m_unitTarget.isEmpty())
                    m_unitTargetMap.insert(fileName, m_unitTarget);
                m_processedUnits.insert(fileName);
            }
            return;
        } else if (name() == QLatin1String("Option")) {
            parseUnitOption();
        } else if (isStartElement()) {
            parseUnknownElement();
        }
    }
}
Example #24
0
void FileUtils::showInGraphicalShell(QWidget *parent, const QString &pathIn)
{
    const QFileInfo fileInfo(pathIn);
    // Mac, Windows support folder or file.
    if (HostOsInfo::isWindowsHost()) {
        const FileName explorer = Environment::systemEnvironment().searchInPath(QLatin1String("explorer.exe"));
        if (explorer.isEmpty()) {
            QMessageBox::warning(parent,
                                 QApplication::translate("Core::Internal",
                                                         "Launching Windows Explorer Failed"),
                                 QApplication::translate("Core::Internal",
                                                         "Could not find explorer.exe in path to launch Windows Explorer."));
            return;
        }
        QStringList param;
        if (!fileInfo.isDir())
            param += QLatin1String("/select,");
        param += QDir::toNativeSeparators(fileInfo.canonicalFilePath());
        QProcess::startDetached(explorer.toString(), param);
    } else if (HostOsInfo::isMacHost()) {
        QStringList scriptArgs;
        scriptArgs << QLatin1String("-e")
                   << QString::fromLatin1("tell application \"Finder\" to reveal POSIX file \"%1\"")
                                         .arg(fileInfo.canonicalFilePath());
        QProcess::execute(QLatin1String("/usr/bin/osascript"), scriptArgs);
        scriptArgs.clear();
        scriptArgs << QLatin1String("-e")
                   << QLatin1String("tell application \"Finder\" to activate");
        QProcess::execute(QLatin1String("/usr/bin/osascript"), scriptArgs);
    } else {
        // we cannot select a file here, because no file browser really supports it...
        const QString folder = fileInfo.isDir() ? fileInfo.absoluteFilePath() : fileInfo.filePath();
        const QString app = UnixUtils::fileBrowser(ICore::settings());
        QProcess browserProc;
        const QString browserArgs = UnixUtils::substituteFileBrowserParameters(app, folder);
        bool success = browserProc.startDetached(browserArgs);
        const QString error = QString::fromLocal8Bit(browserProc.readAllStandardError());
        success = success && error.isEmpty();
        if (!success)
            showGraphicalShellError(parent, app, error);
    }
}
Example #25
0
 void provideData(quint64 block)
 {
     const FileName fn = filePath();
     if (fn.isEmpty())
         return;
     QFile file(fn.toString());
     if (file.open(QIODevice::ReadOnly)) {
         int blockSize = m_widget->dataBlockSize();
         file.seek(block * blockSize);
         QByteArray data = file.read(blockSize);
         file.close();
         const int dataSize = data.size();
         if (dataSize != blockSize)
             data += QByteArray(blockSize - dataSize, 0);
         m_widget->addData(block, data);
     } else {
         QMessageBox::critical(ICore::mainWindow(), tr("File Error"),
                               tr("Cannot open %1: %2").arg(
                                     fn.toUserOutput(), file.errorString()));
     }
 }
Example #26
0
FileStream::FileStream(FileName fileName, bool openReadOnly)
  : d(new FileStreamPrivate(fileName))
{
  // First try with read / write mode, if that fails, fall back to read only.

  if(!openReadOnly)
    d->file = openFile(fileName, false);

  if(d->file != InvalidFileHandle)
    d->readOnly = false;
  else
    d->file = openFile(fileName, true);

  if(d->file == InvalidFileHandle) 
  {
# ifdef _WIN32
    debug("Could not open file " + fileName.toString());
# else
    debug("Could not open file " + String(static_cast<const char *>(d->name)));
# endif 
  }
}
Example #27
0
void TestProject::checkCurrent()
{
  Project* project = SessionManager::startupProject ();
  CustomRunConfiguration* configuration = parse (project);
  if (configuration == NULL)
  {
    return;
  }

  IDocument* document = EditorManager::currentDocument ();
  if (document == NULL)
  {
    return;
  }
  FileName file = document->filePath();
  QStringList files = project->files (Project::ExcludeGeneratedFiles);
  if (!files.contains (file.toString ()))
  {
    return;
  }

  runTestsForFiles (FileNameList () << file, configuration);
}
// Run a build process with merged stdout/stderr and qWarn about errors.
static bool runBuildProcess(QProcess &proc,
                            const FileName &binary,
                            const QStringList &args,
                            int timeoutS,
                            bool ignoreNonNullExitCode,
                            QString *output, QString *errorMessage)
{
    const bool rc = runBuildProcessI(proc, binary, args, timeoutS, ignoreNonNullExitCode, output, errorMessage);
    if (!rc) {
        // Fail - reformat error.
        QString cmd = binary.toString();
        if (!args.isEmpty()) {
            cmd += QLatin1Char(' ');
            cmd += args.join(QLatin1Char(' '));
        }
        *errorMessage =
                QCoreApplication::translate("ProjectExplorer::BuildableHelperLibrary",
                                            "Error running \"%1\" in %2: %3").
                                            arg(cmd, proc.workingDirectory(), *errorMessage);
        qWarning("%s", qPrintable(*errorMessage));
    }
    return rc;
}
Example #29
0
SubversionResponse SubversionPlugin::runSvn(const QString &workingDir,
                          const QStringList &arguments, int timeOut,
                          unsigned flags, QTextCodec *outputCodec) const
{
    const FileName executable = m_settings.binaryPath();
    SubversionResponse response;
    if (executable.isEmpty()) {
        response.error = true;
        response.message =tr("No subversion executable specified.");
        return response;
    }

    const SynchronousProcessResponse sp_resp =
            VcsBasePlugin::runVcs(workingDir, executable, arguments, timeOut,
                                           flags, outputCodec);

    response.error = sp_resp.result != SynchronousProcessResponse::Finished;
    if (response.error)
        response.message = sp_resp.exitMessage(executable.toString(), timeOut);
    response.stdErr = sp_resp.stdErr;
    response.stdOut = sp_resp.stdOut;
    return response;
}
Example #30
0
void PathChooser::setBaseFileName(const FileName &base)
{
    d->m_baseDirectory = base.toString();
    triggerChanged();
}