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
bool GuiLog::initialiseParams(string const & data)
{
	istringstream is(data);
	Lexer lex;
	lex.setStream(is);

	string logtype, logfile;
	lex >> logtype;
	if (lex) {
		lex.next(true);
		logfile = lex.getString();
	}
	if (!lex)
		// Parsing of the data failed.
		return false;

	logTypeCO->setEnabled(logtype == "latex");
	logTypeCO->clear();
	
	FileName log(logfile);
	
	if (logtype == "latex") {
		type_ = LatexLog;
		logTypeCO->addItem(qt_("LaTeX"), toqstr(logtype));
		FileName tmp = log;
		tmp.changeExtension("blg");
		if (tmp.exists())
			logTypeCO->addItem(qt_("BibTeX"), QString("bibtex"));
		tmp.changeExtension("ilg");
		if (tmp.exists())
			logTypeCO->addItem(qt_("Index"), QString("index"));
	// FIXME: not sure "literate" still works.
	} else if (logtype == "literate") {
		type_ = LiterateLog;
		logTypeCO->addItem(qt_("Literate"), toqstr(logtype));
	} else if (logtype == "lyx2lyx") {
		type_ = Lyx2lyxLog;
		logTypeCO->addItem(qt_("LyX2LyX"), toqstr(logtype));
	} else if (logtype == "vc") {
		type_ = VCLog;
		logTypeCO->addItem(qt_("Version Control"), toqstr(logtype));
	} else
		return false;

	logfile_ = log;

	updateContents();

	return true;
}
Example #3
0
bool LyXVC::file_not_found_hook(FileName const & fn)
{
	// Check if file is under RCS.
	// This happens if we are trying to load non existent
	// file on disk, but existent in ,v version.
	bool foundRCS = !RCS::findFile(fn).empty();
	bool foundCVS = foundRCS ? false : !CVS::findFile(fn).empty();
	bool foundSVN = (foundRCS || foundCVS) ? false : !SVN::findFile(fn).empty();
	bool foundGIT = (foundRCS || foundCVS || foundSVN) ? false : !GIT::findFile(fn).empty();
	if (foundRCS || foundCVS || foundSVN || foundGIT) {
		docstring const file = makeDisplayPath(fn.absFileName(), 20);
		docstring const text =
			bformat(_("Do you want to retrieve the document"
						   " %1$s from version control?"), file);
		int const ret = Alert::prompt(_("Retrieve from version control?"),
			text, 0, 1, _("&Retrieve"), _("&Cancel"));

		if (ret == 0) {
			// Since the retrieve commands are implemented using
			// more general update commands we need to ensure that
			// we do not change an existing file by accident.
			if (fn.exists())
				return false;
			if (foundRCS)
				return RCS::retrieve(fn);
			else if (foundCVS)
				return CVS::retrieve(fn);
			else if (foundSVN)
				return SVN::retrieve(fn);
			else
				return GIT::retrieve(fn);
		}
	}
	return false;
}
Example #4
0
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.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
}
Example #5
0
CMakeConfig TeaLeafReader::takeParsedConfiguration()
{
    FileName cacheFile = m_parameters.workDirectory;
    cacheFile.appendPath(QLatin1String("CMakeCache.txt"));

    if (!cacheFile.exists())
        return { };

    QString errorMessage;
    CMakeConfig result = BuildDirManager::parseCMakeConfiguration(cacheFile, &errorMessage);

    if (!errorMessage.isEmpty()) {
        emit errorOccured(errorMessage);
        return { };
    }

    const FileName sourceOfBuildDir
            = FileName::fromUtf8(CMakeConfigItem::valueOf("CMAKE_HOME_DIRECTORY", result));
    const FileName canonicalSourceOfBuildDir = FileUtils::canonicalPath(sourceOfBuildDir);
    const FileName canonicalSourceDirectory = FileUtils::canonicalPath(m_parameters.sourceDirectory);
    if (canonicalSourceOfBuildDir != canonicalSourceDirectory) { // Uses case-insensitive compare where appropriate
        emit errorOccured(tr("The build directory is not for %1 but for %2")
                          .arg(canonicalSourceOfBuildDir.toUserOutput(),
                               canonicalSourceDirectory.toUserOutput()));
        return { };
    }
    return result;
}
bool NimCompilerCleanStep::init()
{
    FileName buildDir = buildConfiguration()->buildDirectory();
    bool result = buildDir.exists();
    if (result)
        m_buildDir = buildDir;
    return result;
}
Example #7
0
/// Ask the user what to do if a file already exists
static int checkOverwrite(FileName const & filename)
{
	if (!filename.exists())
		return 1;

	docstring text = bformat(_("The file %1$s already exists.\n\n"
				   "Do you want to overwrite that file?"),
				   makeDisplayPath(filename.absFileName()));
	return Alert::prompt(_("Overwrite file?"),
				text, 0, 3,
				_("&Keep file"), _("&Overwrite"),
				_("Overwrite &all"), _("&Cancel export"));
}
// Produce side info =====================================================
void ProgClassifyCL2DCore::produceSideInfo()
{
    // Get maximum CL2D level
    maxLevel=0;
    FileName fnLevel;
    do
        fnLevel=formatString("%s/level_%02d/%s_classes.xmd",fnODir.c_str(),maxLevel++,fnRoot.c_str());
    while (fnLevel.exists());
    maxLevel-=2;
    if (maxLevel==-1)
        REPORT_ERROR(ERR_ARG_MISSING,"Cannot find any CL2D analysis in the directory given");

    // Read all the blocks available in all MetaData
    StringVector blocksAux;
    CL2DBlock block;
    for (int level=0; level<=maxLevel; level++)
    {
        fnLevel=formatString("%s/level_%02d/%s_classes.xmd",fnODir.c_str(),level,fnRoot.c_str());
        getBlocksInMetaDataFile(fnLevel,blocksAux);
        block.level=level;
        block.fnLevel=fnLevel;
        block.fnLevelCore=fnLevel.insertBeforeExtension("_core");
        for (size_t i=0; i<blocksAux.size(); i++)
        {
            if (blocksAux[i].find("class")!=std::string::npos && 
                blocksAux[i].find("images")!=std::string::npos)
            {
                block.block=blocksAux[i];
                blocks.push_back(block);
            }
        }
    }

    // Create a task file distributor for all blocks
    size_t Nblocks=blocks.size();
    taskDistributor=new MpiTaskDistributor(Nblocks,1,node);

    // Get image dimensions
    if (Nblocks>0)
    {
        size_t Zdim, Ndim;
        getImageSizeFromFilename(blocks[0].block+"@"+blocks[0].fnLevel,Xdim,Ydim,Zdim,Ndim);
    }
}
Example #9
0
FileName GuiClipboard::getPastedGraphicsFileName(Cursor const & cur,
	Clipboard::GraphicsType & type) const
{
	// create file dialog filter according to the existing types in the clipboard
	vector<Clipboard::GraphicsType> types;
	if (hasGraphicsContents(Clipboard::EmfGraphicsType))
		types.push_back(Clipboard::EmfGraphicsType);
	if (hasGraphicsContents(Clipboard::WmfGraphicsType))
		types.push_back(Clipboard::WmfGraphicsType);
	if (hasGraphicsContents(Clipboard::LinkBackGraphicsType))
		types.push_back(Clipboard::LinkBackGraphicsType);
	if (hasGraphicsContents(Clipboard::PdfGraphicsType))
		types.push_back(Clipboard::PdfGraphicsType);
	if (hasGraphicsContents(Clipboard::PngGraphicsType))
		types.push_back(Clipboard::PngGraphicsType);
	if (hasGraphicsContents(Clipboard::JpegGraphicsType))
		types.push_back(Clipboard::JpegGraphicsType);
	
	LASSERT(!types.empty(), /**/);
	
	// select prefered type if AnyGraphicsType was passed
	if (type == Clipboard::AnyGraphicsType)
		type = types.front();
	
	// which extension?
	map<Clipboard::GraphicsType, string> extensions;
	map<Clipboard::GraphicsType, docstring> typeNames;
	
	extensions[Clipboard::EmfGraphicsType] = "emf";
	extensions[Clipboard::WmfGraphicsType] = "wmf";
	extensions[Clipboard::LinkBackGraphicsType] = "linkback";
	extensions[Clipboard::PdfGraphicsType] = "pdf";
	extensions[Clipboard::PngGraphicsType] = "png";
	extensions[Clipboard::JpegGraphicsType] = "jpeg";
	
	typeNames[Clipboard::EmfGraphicsType] = _("Enhanced Metafile");
	typeNames[Clipboard::WmfGraphicsType] = _("Windows Metafile");
	typeNames[Clipboard::LinkBackGraphicsType] = _("LinkBack PDF");
	typeNames[Clipboard::PdfGraphicsType] = _("PDF");
	typeNames[Clipboard::PngGraphicsType] = _("PNG");
	typeNames[Clipboard::JpegGraphicsType] = _("JPEG");
	
	// find unused filename with primary extension
	string document_path = cur.buffer()->fileName().onlyPath().absFileName();
	unsigned newfile_number = 0;
	FileName filename;
	do {
		++newfile_number;
		filename = FileName(addName(document_path,
			to_utf8(_("pasted"))
			+ convert<string>(newfile_number) + "."
			+ extensions[type]));
	} while (filename.isReadableFile());
	
	while (true) {
		// create file type filter, putting the prefered on to the front
		QStringList filter;
		for (size_t i = 0; i != types.size(); ++i) {
			docstring s = bformat(_("%1$s Files"), typeNames[types[i]])
				+ " (*." + from_ascii(extensions[types[i]]) + ")";
			if (types[i] == type)
				filter.prepend(toqstr(s));
			else
				filter.append(toqstr(s));
		}
		filter = fileFilters(filter.join(";;"));
		
		// show save dialog for the graphic
		FileDialog dlg(qt_("Choose a filename to save the pasted graphic as"));
		FileDialog::Result result =
		dlg.save(toqstr(filename.onlyPath().absFileName()), filter,
			 toqstr(filename.onlyFileName()));
		
		if (result.first == FileDialog::Later)
			return FileName();
		
		string newFilename = fromqstr(result.second);
		if (newFilename.empty()) {
			cur.bv().message(_("Canceled."));
			return FileName();
		}
		filename.set(newFilename);
		
		// check the extension (the user could have changed it)
		if (!suffixIs(ascii_lowercase(filename.absFileName()),
			      "." + extensions[type])) {
			// the user changed the extension. Check if the type is available
			size_t i;
			for (i = 1; i != types.size(); ++i) {
				if (suffixIs(ascii_lowercase(filename.absFileName()),
					     "." + extensions[types[i]])) {
					type = types[i];
					break;
				}
			}
			
			// invalid extension found, or none at all. In the latter
			// case set the default extensions.
			if (i == types.size()
			    && filename.onlyFileName().find('.') == string::npos) {
				filename.changeExtension("." + extensions[type]);
			}
		}
		
		// check whether the file exists and warn the user
		if (!filename.exists())
			break;
		int ret = frontend::Alert::prompt(
			_("Overwrite external file?"),
			bformat(_("File %1$s already exists, do you want to overwrite it?"),
			from_utf8(filename.absFileName())), 1, 1, _("&Overwrite"), _("&Cancel"));
		if (ret == 0)
			// overwrite, hence break the dialog loop
			break;
		
		// not overwrite, hence show the dialog again (i.e. loop)
	}
	
	return filename;
}
Example #10
0
/* Delete  file exists -------------------------------------------------- */
void FileName::deleteFile() const
{
    FileName temp = this->removeFileFormat().removeAllPrefixes();
    if (temp.exists())
        unlink(temp.c_str());
}