예제 #1
0
void txCommonParameters::createNeededFiles() {

    QDir dir;
    QFileInfo fileInfo;
    QString absPath;

    if ( !dir.exists(m_commonDirName) ) {

        if ( !dir.mkdir(m_commonDirName) ) {
            throw txError("Can not create directory " + m_commonDirName);
        }
    }

    fileInfo.setFile(m_srcFileNameEU3);
    absPath = fileInfo.absoluteDir().absolutePath();

    if ( !dir.exists(absPath) ) {

        if ( !dir.mkdir(absPath) ) {
            throw txError("Can not create directory " + absPath);
        }
    }

    fileInfo.setFile(m_srcFileNameEU0);
    absPath = fileInfo.absoluteDir().absolutePath();

    if ( !dir.exists(absPath) ) {

        if ( !dir.mkdir(absPath) ) {
            throw txError("Can not create directory " + absPath);
        }
    }

    fileInfo.setFile(m_srcFileNamePoints);
    absPath = fileInfo.absoluteDir().absolutePath();

    if ( !dir.exists(absPath) ) {

        if ( !dir.mkdir(absPath) ) {
            throw txError("Can not create directory " + absPath);
        }
    }

    fileInfo.setFile(m_srcFileNameRedPwr);
    absPath = fileInfo.absoluteDir().absolutePath();

    if ( !dir.exists(absPath) ) {

        if ( !dir.mkdir(absPath) ) {
            throw txError("Can not create directory " + absPath);
        }
    }

    if ( !dir.exists(m_reportsDirName) ) {

        if ( !dir.mkdir(m_reportsDirName) ) {
            throw txError("Can not create directory " + m_reportsDirName);
        }
    }
}
예제 #2
0
Experiment::Experiment(const QFileInfo fi, QObject * parent)
	: QObject(parent),fi(fi), name(fi.absoluteDir().dirName()), 
	dir(fi.absoluteDir()), sps1(fi.absolutePath() + "/myBlockList.txt", this),
	sps2(fi.absolutePath() + "/myTrialListParameters.txt", this),
	sps3(fi.absolutePath() + "/otherParameters.txt", this)
{
	qDebug() << "Experiment construction";
	qDebug() << this->name;
}
예제 #3
0
QString Notepadqq::extensionsPath()
{
    QSettings settings;

    QFileInfo f = QFileInfo(settings.fileName());
    return f.absoluteDir().absoluteFilePath("extensions");
}
예제 #4
0
파일: settings.cpp 프로젝트: woronin/kumir2
QString Settings::locationDirectory() const
{
    mutex_->lock();
    const QFileInfo fileInfo(qsettings_->fileName());
    mutex_->unlock();
    return fileInfo.absoluteDir().absolutePath();
}
예제 #5
0
파일: FormMain.cpp 프로젝트: masakra/adel
void
FormMain::save()	// slot
{
	const QFileInfo fileInfo( m_editPath->text() );

	const QString xmlText = buildXmlFile( fileInfo );

	if ( xmlText.isEmpty() )
		return;

	QFile xmlFile( fileInfo.absoluteDir().filePath("ADEL_Metadata.xml") );

	if ( ! xmlFile.open( QIODevice::WriteOnly | QIODevice::Text ) ) {
		QMessageBox::critical( this, "Ошибка записи", QString("Открыть файл %1 на запись нет никакой возможности.")
				.arg( xmlFile.fileName() ) );
		return;
	}

	QTextStream out( &xmlFile );

	out << xmlText;

	xmlFile.close();

	QMessageBox::information( this, "Успех", QString("Файл %1 создан и сохранён").arg( xmlFile.fileName() ) );
}
void NimRunConfiguration::updateConfiguration()
{
    auto buildConfiguration = qobject_cast<NimBuildConfiguration*>(activeBuildConfiguration());
    Q_ASSERT(buildConfiguration);
    Utils::FileName outFile = buildConfiguration->outFilePath();
    QFileInfo outFileInfo = outFile.toFileInfo();
    setExecutable(outFileInfo.absoluteFilePath());
    setWorkingDirectory(outFileInfo.absoluteDir().absolutePath());
}
예제 #7
0
 KUrl url ( QString const& filename )
 {
   QFileInfo fi ( filename );
   QDir const& parent = fi.absoluteDir();
   if ( parent.exists() )
   {
     return KUrl ( filename );
   }
   return KUrl ( fi.fileName() );
 }
예제 #8
0
void NimRunConfiguration::updateConfiguration()
{
    auto buildConfiguration = qobject_cast<NimBuildConfiguration *>(activeBuildConfiguration());
    QTC_ASSERT(buildConfiguration, return);
    setActiveBuildConfiguration(buildConfiguration);
    const QFileInfo outFileInfo = buildConfiguration->outFilePath().toFileInfo();
    extraAspect<ExecutableAspect>()->setExecutable(FileName::fromString(outFileInfo.absoluteFilePath()));
    const QString workingDirectory = outFileInfo.absoluteDir().absolutePath();
    extraAspect<WorkingDirectoryAspect>()->setDefaultWorkingDirectory(FileName::fromString(workingDirectory));
}
예제 #9
0
void
AtticaResolverAccount::loadIcon()
{
    const QFileInfo fi( m_resolver.data()->filePath() );
    QDir codeDir = fi.absoluteDir();
    codeDir.cd( "../images" );

    if ( codeDir.exists() && codeDir.exists( "icon.png" ) )
        m_icon.load( codeDir.absoluteFilePath( "icon.png" ) );

}
예제 #10
0
void Importer::importTextureFile( const QFileInfo& textureFile, const QString& targetFileName )
{
	QFileInfo target = QFileInfo(m_targetResourcePath, targetFileName);
	if (!target.absoluteDir().exists())
		m_targetResourcePath.mkpath(target.absolutePath());

	const CopyJob job(textureFile, target);
	if (!job.exec() && !m_filesToOverwrite.contains(job) && !m_alreadyCopied.contains(job))
		m_filesToOverwrite.append(job);		
	else
		m_alreadyCopied.append(job);
}
예제 #11
0
	void RenameDialog::Rename (const QList<QPair<QString, QString>>& pairs)
	{
		for (const auto& pair : pairs)
		{
			const QFileInfo sourceInfo (pair.first);
			auto sourceDir = sourceInfo.absoluteDir ();
			if (!sourceDir.rename (sourceInfo.fileName (), pair.second))
				qWarning () << Q_FUNC_INFO
						<< "failed to rename"
						<< sourceInfo.fileName ()
						<< "to"
						<< pair.second;
		}
	}
예제 #12
0
void Recorder::deleteDirectory(QFileInfo fileList)
{

    if(fileList.isDir()){
        int childCount =0;
        QString dir = fileList.filePath();
        QDir thisDir(dir);
        childCount = thisDir.entryInfoList().count();
        QFileInfoList newFileList = thisDir.entryInfoList();
        if(childCount>2){
            for(int i=0;i<childCount;i++){
                if(newFileList.at(i).fileName().operator ==(".")|newFileList.at(i).fileName().operator ==("..")){
                    continue;
                }
                deleteDirectory(newFileList.at(i));
            }
        }
        fileList.absoluteDir().rmpath(fileList.fileName());
    }else if(fileList.isFile()){
        fileList.absoluteDir().remove(fileList.fileName());
    }

}
예제 #13
0
AutotoolsProject::AutotoolsProject(AutotoolsManager *manager, const QString &fileName) :
    m_fileWatcher(new Utils::FileSystemWatcher(this))
{
    setId(Constants::AUTOTOOLS_PROJECT_ID);
    setProjectManager(manager);
    setDocument(new AutotoolsProjectFile(fileName));
    setRootProjectNode(new AutotoolsProjectNode(projectFilePath()));
    setProjectContext(Core::Context(Constants::PROJECT_CONTEXT));
    setProjectLanguages(Core::Context(ProjectExplorer::Constants::LANG_CXX));

    const QFileInfo fileInfo = projectFilePath().toFileInfo();
    m_projectName = fileInfo.absoluteDir().dirName();
    rootProjectNode()->setDisplayName(m_projectName);
}
예제 #14
0
void FileUtils::delDir(QFileInfo rmFile)
{
	if(rmFile.isDir())
	{
		int childCount =0;
		QString dir = rmFile.filePath();
		QDir thisDir(dir);
		childCount = thisDir.entryInfoList().count();
		QFileInfoList newFileList = thisDir.entryInfoList();
		if(childCount>2){
			for(int i=0;i<childCount;i++){
				if(newFileList.at(i).fileName() == "." || newFileList.at(i).fileName() == ".."){
					continue;
				}
				delDir(newFileList.at(i));
			}
		}
		rmFile.absoluteDir().rmpath(rmFile.fileName());
	}
	else if(rmFile.isFile())
	{
		rmFile.absoluteDir().remove(rmFile.fileName());
	}
}
예제 #15
0
/**
 * Shows a browser dialog to open a query file
 */
void MainWindow::openQuery()
{
  QString f = QFileDialog::getOpenFileName( this,
                           tr( "Select a query to open" ),
                           AbstractTabWidget::lastDir.path(),
                           tr( "Query file (*.sql);;All files (*.*)" ) );

  if(f.isNull())
    return;

  QueryEditorWidget *w = newQuery();
  w->open(f);

  QFileInfo fi = QFileInfo(f);
  AbstractTabWidget::lastDir = fi.absoluteDir();
}
예제 #16
0
void AutotoolsProject::makefileParsingFinished()
{
    // The finished() signal is from a previous makefile-parser-thread
    // and can be skipped. This can happen, if the thread has emitted the
    // finished() signal during the execution of AutotoolsProject::loadProjectTree().
    // In this case the signal is in the message queue already and deleting
    // the thread of course does not remove the signal again.
    if (sender() != m_makefileParserThread)
        return;

    QApplication::restoreOverrideCursor();

    if (m_makefileParserThread->isCanceled()) {
        // The parsing has been cancelled by the user. Don't show any
        // project data at all.
        m_makefileParserThread->deleteLater();
        m_makefileParserThread = 0;
        return;
    }

    if (m_makefileParserThread->hasError())
        qWarning("Parsing of makefile contained errors.");

    // Remove file watches for the current project state.
    // The file watches will be added again after the parsing.
    foreach (const QString& watchedFile, m_watchedFiles)
        m_fileWatcher->removeFile(watchedFile);

    m_watchedFiles.clear();

    // Apply sources to m_files, which are returned at AutotoolsProject::files()
    const QFileInfo fileInfo = projectFilePath().toFileInfo();
    const QDir dir = fileInfo.absoluteDir();
    QStringList files = m_makefileParserThread->sources();
    foreach (const QString& file, files)
        m_files.append(dir.absoluteFilePath(file));

    // Watch for changes of Makefile.am files. If a Makefile.am file
    // has been changed, the project tree must be reparsed.
    const QStringList makefiles = m_makefileParserThread->makefiles();
    foreach (const QString &makefile, makefiles) {
        files.append(makefile);

        const QString watchedFile = dir.absoluteFilePath(makefile);
        m_fileWatcher->addFile(watchedFile, Utils::FileSystemWatcher::WatchAllChanges);
        m_watchedFiles.append(watchedFile);
    }
예제 #17
0
void MainWindow::on_btnSave_clicked()
{

    //QImage qCaptureImg((uchar*)cvmCurrentFrame.data, cvmCurrentFrame.cols, cvmCurrentFrame.rows, cvmCurrentFrame.step, QImage::Format_Indexed8);

    QImage qCaptureImg = MatToQImage(cvmCurrentFrame);

    stopCapture();

    if (filePath.isNull()) {
        filePath = QDir::currentPath();
    }

    QString filename = QFileDialog::getSaveFileName(
        this,
        tr("Save Capture"),
        filePath,
        tr("PNG (*.png);;TIF (*.tif);;JPG (*.jpg)"),
        &fileExtension);

    if( !filename.isNull() )
    {
        // save current path to set selected path in next save action
        QFileInfo fi = QFileInfo(filename);
        filePath = fi.absoluteDir().absolutePath();

        // Generate file path + file name without extension
        // this is done because the extension is set below
        // if not it could save file.png.png if a previous
        // file should be overwritten
        filename = filePath + QDir::separator() + fi.baseName();

        if (fileExtension == "PNG (*.png)") {
            filename += ".png";
        }else if(fileExtension == "TIF (*.tif)") {
            filename += ".tif";
        }else{
            filename += ".jpg";
        }
        qCaptureImg.save(filename);
    }
    startCapture();
}
예제 #18
0
int XmlParser::read(const char * filePath)
{
	QFileInfo pathInfo = QFileInfo(QString(filePath));
	QDir dirPath = pathInfo.absoluteDir();

	if (!dirPath.exists())
	{
		return XmlParser::ERR::NO_DIRECTORY;
	}

	if(!pathInfo.exists())
	{
		return XmlParser::ERR::NO_FILE;
	}

	QFile file(pathInfo.absoluteFilePath());

	if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
	{
		return XmlParser::ERR::NO_READ_ACCESS;
	}

	m_doc.setContent(&file);
	file.close();

	QDomElement menu = m_doc.firstChildElement("menu");
	QDomElement theme = m_doc.firstChildElement("Theme");

	if(!menu.isNull())
	{
		return fillGamesList(menu);
	}
	else if (!theme.isNull())
	{
		return fillThemeMap(theme);
	}
	else
	{
		return XmlParser::ERR::UNKNOWN_FILE;
	}
}
예제 #19
0
void ImpedanceLog::setSaveLocation(QString fname, bool overrideExistingFile) {

    if (!fname.endsWith(".json")){
        fname.append(".json");
    }

    QFileInfo f = QFileInfo(fname);

    if (!QDir(f.absoluteDir()).exists() ) {
        cout << "Selected log file save directory does not exist: " + f.path().toStdString() << endl;
        return;
    }

    if (!overrideExistingFile && f.exists() && f.isFile()) {
        string overwrite;
        cout << "Selected log file already exists. Overwrite (y/n)?" << endl;
        cin >> overwrite;
        if (!(overwrite == "Y" || overwrite == "y")) {
            return;
        }
    }
예제 #20
0
QString UsefulGUIFunctions::generateBackupName( const QFileInfo& finfo )
{
	QDir dir = finfo.absoluteDir();
	QFileInfoList list = dir.entryInfoList(QDir::Files);
	QString oldnm = finfo.fileName();
	oldnm.replace('.',"\\.");
	QRegExp oldexp(oldnm + "\\.old(\\d+)");
	int max = 0;
	for (int ii = 0;ii < list.size();++ii)
	{
		if (list[ii].fileName().contains(oldexp))
		{
			QRegExp num("\\d+");
			list[ii].suffix().indexOf(num);
			int ver = num.cap().toInt();
			if (ver > max)
				max = ver;
		}
	}
	return QString(finfo.absolutePath() + "/" + finfo.fileName() + ".old" + QString::number(max + 1));
}
예제 #21
0
bool GeneratedFile::write(QString *errorMessage) const
{
    // Ensure the directory
    const QFileInfo info(m_d->path);
    const QDir dir = info.absoluteDir();
    if (!dir.exists()) {
        if (!dir.mkpath(dir.absolutePath())) {
            *errorMessage = BaseFileWizard::tr("Unable to create the directory %1.").arg(dir.absolutePath());
            return false;
        }
    }

    // Write out
    QIODevice::OpenMode flags = QIODevice::WriteOnly|QIODevice::Truncate;
    if (!isBinary())
        flags |= QIODevice::Text;

    Utils::FileSaver saver(m_d->path, flags);
    saver.write(m_d->contents);
    return saver.finalize(errorMessage);
}
예제 #22
0
// Helper for recursively removing files.
static void removeFileRecursion(const QFileInfo &f, QString *errorMessage)
{
    // The version control system might list files/directory in arbitrary
    // order, causing files to be removed from parent directories.
    if (!f.exists())
        return;
    if (f.isDir()) {
        const QDir dir(f.absoluteFilePath());
        foreach(const QFileInfo &fi, dir.entryInfoList(QDir::AllEntries|QDir::NoDotAndDotDot|QDir::Hidden))
            removeFileRecursion(fi, errorMessage);
        QDir parent = f.absoluteDir();
        if (!parent.rmdir(f.fileName()))
            errorMessage->append(VCSBase::CleanDialog::tr("The directory %1 could not be deleted.").
                                 arg(QDir::toNativeSeparators(f.absoluteFilePath())));
        return;
    }
    if (!QFile::remove(f.absoluteFilePath())) {
        if (!errorMessage->isEmpty())
            errorMessage->append(QLatin1Char('\n'));
        errorMessage->append(VCSBase::CleanDialog::tr("The file %1 could not be deleted.").
                             arg(QDir::toNativeSeparators(f.absoluteFilePath())));
    }
}
예제 #23
0
파일: TcFile.cpp 프로젝트: jonixfu/tianchi
QString TcFile::uniqueFileName(const QString& dir, const QString& fileTemplate, const QString& suffix)
{
    QString fileDir    = dir;
    QString filePrefix = fileTemplate;
    QString fileSuffix = suffix;

    QFileInfo f;
    if ( fileDir == "" )
    {
        f.setFile(fileTemplate);
        fileDir    = f.absoluteDir().absolutePath();
        fileSuffix = f.suffix();
        if ( ! fileSuffix.isEmpty() )
        {
            filePrefix = filePrefix.mid(0, filePrefix.length()-fileSuffix.length()-1);
        }
    }
    if ( fileSuffix == "" )
    {
        f.setFile(fileTemplate);
        fileSuffix = f.suffix();
        if ( ! fileSuffix.isEmpty() )
        {
            filePrefix = filePrefix.mid(0, filePrefix.length()-fileSuffix.length()-1);
        }
    }
    QString ret = fileDir + QDir::separator() + filePrefix + "." + fileSuffix;
    f.setFile(ret);
    int index = 2;
    while(f.exists())
    {
        ret = fileDir + QDir::separator() + filePrefix + "("+QString::number(index++)+")."+fileSuffix;
        f.setFile(ret);
    }
    return ret;
}
예제 #24
0
void FileBackend::initFromSingleFile(const QFileInfo &file)
{
	bool foundCurrent = false;
	for (const QFileInfo& entry : file.absoluteDir().entryInfoList(QDir::NoFilter, QDir::Name | QDir::LocaleAware)) {
		if (!entry.isFile()) {
			continue;
		}
		reader.setFileName(entry.absoluteFilePath());
		if (!reader.canRead()) {
			// Not an image or file type not supported
			continue;
		}
		files.push_back(std::unique_ptr<File>(new File(entry.absoluteFilePath())));
		if (!foundCurrent && entry == file) {
			foundCurrent = true;
			auto last = this->files.end();
			last--;
			this->currentFile = last;
		}
	}
	if (!foundCurrent) {
		this->currentFile = this->files.begin();
	}
}
예제 #25
0
bool QtZLFSManager::removeFile(const std::string &path) const
{
    const QFileInfo info = QString::fromStdString(path);

    return info.absoluteDir().remove(info.fileName());
}
예제 #26
0
bool CHyperSpin::scanPlatformMedias(QFileInfo oPlatformDirectory)
{
	bool l_bIsImagesDirectoryFound = false;
	bool l_bIsSoundDirectoryFound = false;
	bool l_bIsThemesDirectoryFound = false;
	bool l_bIsVideoDirectoryFound = false;

	bool l_bIsMainMenuDirectory = (oPlatformDirectory.baseName() == "Main Menu");
	bool l_bIsFrontendDirectory = (oPlatformDirectory.baseName() == "Frontend");

	if(!l_bIsMainMenuDirectory && !l_bIsFrontendDirectory)
	{
		CPlatform l_oPlatform;
		l_oPlatform.setName(oPlatformDirectory.baseName());

		foreach(const QFileInfo &oMediaDirectory, oPlatformDirectory.absoluteDir().entryInfoList())
		{
			CHyperSpinTheme l_oHyperSpinTheme;

			if(oMediaDirectory.baseName() == "Images")
			{
				l_bIsImagesDirectoryFound = true;

				if(!scanImages(oMediaDirectory))
				{

				}
			}
			else if(oMediaDirectory.baseName() == "Sound")
			{
				l_bIsSoundDirectoryFound = true;

				if(!scanSounds(oMediaDirectory))
				{

				}
			}
			else if(oMediaDirectory.baseName() == "Themes")
			{
				l_bIsThemesDirectoryFound = true;

				if(!scanThemes(oMediaDirectory))
				{

				}
			}
			else if(oMediaDirectory.baseName() == "Video")
			{
				l_bIsVideoDirectoryFound = true;

				if(!scanVideos(oMediaDirectory))
				{

				}
			}
			else
			{

			}
		}
	}
예제 #27
0
/*!
 \brief Change name of an image/dir
 \details Renames image/dir in Photographs storage group, synchronises image database
 and thumbnail cache and notifies clients. A new thumbnail will be generated by next client
 request.
 \param id File/dir id
 \param newBase New filename
 \return QStringList Error message or "OK"
*/
QStringList ImageHandler::HandleRename(QString id, QString newBase)
{
    // Sanity check new name
    if (newBase.isEmpty() || newBase.contains("/") || newBase.contains("\\"))
        return QStringList("ERROR") << "Invalid name";

    // Find image in DB
    ImageDbWriter db;
    ImageList images, dirs;
    db.ReadDbItemsById(images, id);

    // Either single id not found or multiple comma-delimited ids received
    if (images.size() != 1)
    {
        LOG(VB_FILE, LOG_NOTICE,
            QString("Image: Image %1 not found in Db").arg(id));
        qDeleteAll(images);
        return QStringList("ERROR") << "Unknown File";
    }

    // Get filepath for solitary image
    ImageItem *im = images[0];
    QString absFilename = ImageSg::getInstance()->GetFilePath(im);

    if (absFilename.isEmpty())
    {
        delete im;
        return QStringList("ERROR") << "File not found";
    }

    // Rename file
    QFileInfo info = QFileInfo(absFilename);
    QDir dir = info.absoluteDir();
    QString newName = im->IsDirectory()
            ? newBase : QString("%1.%2").arg(newBase, info.suffix());

    if (!dir.rename(im->m_name, newName))
    {
        LOG(VB_FILE, LOG_ERR, QString("Image: Rename of %1 -> %2 failed")
            .arg(im->m_name, newName));
        delete im;
        return QStringList("ERROR") << "Rename failed";
    }

    LOG(VB_FILE, LOG_DEBUG, QString("Image: Renamed %1 -> %2")
        .arg(im->m_fileName, newName));

    ImageList dummy;

    if (im->IsDirectory())
    {
        // Cleanup thumbdir/thumbnails
        // Thumb generator now owns the image object
        QStringList mesg = ImageThumb::getInstance()->DeleteThumbs(dummy, images);

        // Notify clients of deleted ids, images, thumbs
        gCoreContext->SendEvent(MythEvent("IMAGE_DB_CHANGED", mesg));

        // Dir name change affects path of all sub-dirs & files and their thumbs
        QStringList scan;
        scan << "IMAGE_SCAN" << "START";
        return ImageScan::getInstance()->HandleScanRequest(scan);
    }

    // Retain old image for cleanup
    ImageItem *newIm = new ImageItem(*im);

    // Update db
    newIm->m_name = newName;
    newIm->m_fileName = QDir::cleanPath(QDir(newIm->m_path).filePath(newName));
    db.UpdateDbFile(newIm);
    delete newIm;

    // Clean up thumbnail
    // Thumb generator now owns the images objects
    QStringList mesg = ImageThumb::getInstance()->DeleteThumbs(images, dummy);
    // Item is modified, not deleted
    mesg.swap(0,1);

    // New thumbnail will be created by client request

    // Notify clients of changed image & thumbnail
    gCoreContext->SendEvent(MythEvent("IMAGE_DB_CHANGED", mesg));

    return QStringList("OK");
}
예제 #28
0
__declspec(dllexport) QDir MartletProject::projectDir() const
{
    const QFileInfo fi(QString::fromStdString(fileName.name()));
    return fi.absoluteDir();
}
예제 #29
0
void GameHandler::buildFileList(QString directory, GameHandler *handler,
                                int* filecount)
{
    QDir RomDir(directory);

                                // If we can't read it's contents move on
    if (!RomDir.isReadable())
        return;

    RomDir.setSorting( QDir:: DirsFirst | QDir::Name );
    QFileInfoList List = RomDir.entryInfoList();
    for (QFileInfoList::const_iterator it = List.begin();
         it != List.end(); ++it)
    {
        QFileInfo Info = *it;
        QString RomName = Info.fileName();
        QString GameName = Info.completeBaseName();

        if (RomName == "." ||
            RomName == "..")
        {
            continue;
        }

        if (Info.isDir())
        {
            buildFileList(Info.filePath(), handler, filecount);
            continue;
        }
        else
        {

            if (handler->validextensions.count() > 0)
            {
                QRegExp r;

                r.setPattern("^" + Info.suffix() + "$");
                r.setCaseSensitivity(Qt::CaseInsensitive);
                QStringList result;
                for (int x = 0; x < handler->validextensions.size(); x++)
                {
                    QString extension = handler->validextensions.at(x);
                    if (extension.contains(r))
                        result.append(extension);
                }

                if (result.isEmpty())
                    continue;
            }

            m_GameMap[RomName] = GameScan(RomName,Info.filePath(),inFileSystem,
                                 GameName, Info.absoluteDir().path());

            LOG(VB_GENERAL, LOG_INFO, LOC + QString("Found ROM : (%1) - %2")
                    .arg(handler->SystemName()).arg(RomName));

            *filecount = *filecount + 1;
            if (m_progressDlg)
                m_progressDlg->SetProgress(*filecount);

        }
    }
}
예제 #30
0
int prepare(QFileInfo f, QStringList paths) {
	if (paths.isEmpty()) {
		cout << "No -path args were passed :(\n";
		return -1;
	}

	int lastVersion = 0;
	QString lastVersionStr;
	QFileInfo last;
	QFileInfoList l = f.absoluteDir().entryInfoList(QDir::Files);
	for (QFileInfoList::iterator i = l.begin(), e = l.end(); i != e; ++i) {
		QRegularExpressionMatch m = QRegularExpression("/tsetup.((\\d+).(\\d+).(\\d+)).exe$").match(i->absoluteFilePath());
		if (!m.hasMatch()) continue;

		int version = m.captured(2).toInt() * 1000000 + m.captured(3).toInt() * 1000 + m.captured(4).toInt();
		if (version > lastVersion) {
			lastVersion = version;
			lastVersionStr = m.captured(1);
			last = *i;
		}
	}

	if (!lastVersion) {
		cout << "No tsetup.X.Y.Z.exe found :(\n";
		return -1;
	}

	cout << "Last version: " << lastVersionStr.toUtf8().constData() << " (" << lastVersion << "), executing packer..\n";

	QDir dir("deploy/" + lastVersionStr);
	if (dir.exists()) {
		cout << "Version " << lastVersionStr.toUtf8().constData() << " already exists in /deploy..\n";
		return -1;
	}

	QString packer = QString("Packer.exe -version %1").arg(lastVersion);
	for (QStringList::iterator i = paths.begin(), e = paths.end(); i != e; ++i) {
		packer += " -path " + *i;
	}

	int res = system(packer.toUtf8().constData());

	if (res) return res;

	dir.mkpath(".");

	paths.push_back("Telegram.pdb");
	paths.push_back("Updater.pdb");
	paths.push_back("tsetup." + lastVersionStr + ".exe");
	paths.push_back(QString("tupdate%1").arg(lastVersion));
	for (QStringList::iterator i = paths.begin(), e = paths.end(); i != e; ++i) {
		if (!QFile::copy(*i, "deploy/" + lastVersionStr + "/" + *i)) {
			cout << "Could not copy " << i->toUtf8().constData() << " to deploy/" << lastVersionStr.toUtf8().constData() << "\n";
			return -1;
		}
		cout << "Copied " << i->toUtf8().constData() << "..\n";
	}
	for (QStringList::iterator i = paths.begin(), e = paths.end(); i != e; ++i) {
		QFile::remove(*i);
	}

	cout << "Update created in deploy/" << lastVersionStr.toUtf8().constData() << "\n";

	return 0;
}