std::string OutputDirectoryFifoQueue::CreateNextDir(const std::string& rSubdirectoryName)
{
    std::string subdirectory_full_name = mBaseDirectory + "/" + rSubdirectoryName;

    if (mQueue.size() == mQueueMaxSize)
    {
        FileFinder dir_to_remove(mBaseDirectory + "/" + mQueue.front(), RelativeTo::ChasteTestOutput);
        if (PetscTools::AmMaster())
        {
            ABORT_IF_THROWS(dir_to_remove.Remove());
        }
        PetscTools::Barrier("OutputDirectoryFifoQueue::CreateNextDir");

        mQueue.pop();
    }

    mQueue.push(rSubdirectoryName);
    OutputFileHandler handler(subdirectory_full_name);

    assert(mQueue.size() <= mQueueMaxSize);

    return subdirectory_full_name;
}
Exemple #2
0
MainWindow::MainWindow(QWidget *parent) :
	QMainWindow(parent),
	ui(new Ui::MainWindow)
{
	progression = new QProgressBar(this);
	progression->setValue(0);
	progression->setRange(0, 100);

	ui->setupUi(this);
	setFixedSize(1200,200);
	setWindowTitle("Updater");
    welcome_string=new QLabel("<h2>Welcome on XEML Updater</h2>");
    welcome_string->setAlignment(Qt::AlignCenter);
	update_string=new QLabel("");
	QSplitter * rightSplitter = new QSplitter(Qt::Vertical);
	rightSplitter->addWidget(welcome_string);
	rightSplitter->addWidget(progression);
	rightSplitter->addWidget(update_string);

	setCentralWidget(rightSplitter);

	this->show();


	QNetworkAccessManager manager;
	manager.setNetworkAccessible(QNetworkAccessManager::Accessible);

//#if defined(Q_OS_WIN)
	//reply = manager.get(QNetworkRequest(QUrl("https://raw.githubusercontent.com/cbib/XEML-Lab/master/bin/Windows_dist/current/XEML-Lab.zip")));
//dep_reply = manager.get(QNetworkRequest(QUrl("https://github.com/cbib/XEML-Lab/tree/master/bin/Windows_dist/current/XEML-Lab.zip")));

#if defined(Q_OS_WIN)
	QEventLoop loop;
	//reply = manager.get(QNetworkRequest(QUrl("https://raw.githubusercontent.com/cbib/XEML-Lab/master/bin/Windows_dist/current/XEML-Lab.zip")));
    reply = manager.get(QNetworkRequest(QUrl("http://github.com/cbib/XEML-Lab/tree/master/bin/Windows_dist/current/XEML-Lab.zip")));
	QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
    connect(reply, SIGNAL(finished()), this, SLOT(enregistrer_for_windows()));
	connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(downloadProgress(qint64, qint64)));
	//QCoreApplication::processEvents();
	//updateSoftware->setEnabled(false);
	//QString error= reply->errorString();
	//std::cerr << "error" << error.toStdString() << std::endl;


	loop.exec();

#elif defined(Q_OS_MACX)
	//https://github.com/cbib/XEML-Lab/tree/master/bin/Mac-dist/current/XEML-Lab/Updater/updater.app

	//reply = manager.get(QNetworkRequest(QUrl("https://raw.githubusercontent.com/cbib/XEML-Lab/master/bin/Mac-dist/current/XEML-Lab.zip")));

	dep_reply = manager.get(QNetworkRequest(QUrl("https://raw.githubusercontent.com/cbib/XEML-Lab/master/bin/Mac-dist/dependencies.txt")));
	QEventLoop dep_loop;
	QObject::connect(dep_reply, SIGNAL(finished()), &dep_loop, SLOT(quit()));
	dep_loop.exec();

	QDir dir(QCoreApplication::applicationFilePath());
	QDir my_dir=dir;
	//std::cerr << my_dir.path().toStdString() << std::endl;
	while (! my_dir.path().endsWith("updater.app")){
		my_dir.cdUp();
	}
	my_dir.cdUp();
	my_dir.cdUp();
	std::cerr << my_dir.path().toStdString() << std::endl;
	QString pathTest = my_dir.path()+ "/XemlDesigner.app";
	QDir dir_to_remove(pathTest);
	dir_to_remove.removeRecursively();
	my_dir.mkdir("XemlDesigner.app");
	QString dependencies_list = dep_reply->readAll();
	QStringList dependencies=dependencies_list.split("\n");
	foreach (QString var, dependencies) {
		QEventLoop loop;
		//std::cerr <<"-------" <<  var.toStdString() << std::endl;
		this->url="https://raw.githubusercontent.com/cbib/XEML-Lab/master/"+var;
		//std::cerr << "https://raw.githubusercontent.com/cbib/XEML-Lab/master/"+var.toStdString() << std::endl;
		reply = manager.get(QNetworkRequest(QUrl(this->url)));
		QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
		connect(reply, SIGNAL(finished()), this, SLOT(enregistrer_for_mac()));
		connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(downloadProgress(qint64, qint64)));
		//QCoreApplication::processEvents();
		//updateSoftware->setEnabled(false);
		//QString error= reply->errorString();
		//std::cerr << "error" << error.toStdString() << std::endl;


		loop.exec();

	}