Пример #1
0
		void RecentDirs::OnEmuEvent(const Emulator::Event event,const Emulator::Data data)
		{
			switch (event)
			{
				case Emulator::EVENT_LOAD:

					if (menu[IDM_FILE_RECENT_DIR_LOCK].Unchecked())
					{
						HeapString items[MAX_DIRS];
						HeapString curDir( emulator.GetStartPath().Directory() );

						for (uint i=IDM_FILE_RECENT_DIR_1, j=0; i <= IDM_FILE_RECENT_DIR_5 && menu[i].Text() >> items[j]; ++i)
						{
							if (items[j](3) != curDir)
								items[j][1] = ('2' + j), ++j;
						}

						curDir.Insert( 0, "&1 ", 3 );
						Add( IDM_FILE_RECENT_DIR_1, curDir );

						for (uint i=0; i < MAX_DIRS-1 && items[i].Length(); ++i)
							Add( IDM_FILE_RECENT_DIR_2 + i, items[i] );

						menu[IDM_FILE_RECENT_DIR_CLEAR].Enable();
					}
					break;

				case Emulator::EVENT_NETPLAY_MODE:

					menu[IDM_POS_FILE][IDM_POS_FILE_RECENTDIRS].Enable( !data );
					break;
			}
Пример #2
0
void FileUtils::fileCounter(const QString& filePath, int* pCounter)
{
	QFileInfo curFile(filePath);
	if(!curFile.exists()) return;

	if (curFile.isDir())
	{
		QString dir = curFile.filePath();
		QDir curDir(dir);
		int childCount = curDir.entryInfoList().count();
		QFileInfoList newFileList = curDir.entryInfoList();
		if(childCount > 2)
		{
			for(int i = 0;i< childCount; i++)
			{
				if(newFileList.at(i).fileName() == "." || newFileList.at(i).fileName() == "..")
					continue;
				fileCounter(newFileList.at(i).filePath(), pCounter);
			}
		}
	}
	else
	{
		if(pCounter) *pCounter += 1;
	}
}
Пример #3
0
        std::string ResolveIgniteHome(const std::string& path)
        {
            // 1. Check passed argument.
            if (IsValidDirectory(path))
                return path;

            // 2. Check environment variable.
            std::string home = GetEnv(IGNITE_HOME);

            if (IsValidDirectory(home))
                return home;

            // 3. Check current work dir.
            DWORD curDirLen = GetCurrentDirectoryA(0, NULL);

            if (!curDirLen)
                return std::string();

            FixedSizeArray<char> curDir(curDirLen);

            curDirLen = GetCurrentDirectoryA(curDir.GetSize(), curDir.GetData());

            if (!curDirLen)
                return std::string();

            std::string curDirStr(curDir.GetData());

            return ResolveIgniteHome0(curDirStr);
        }
Пример #4
0
Core::GeneratedFiles ROSProjectWizard::generateFiles(const QWizard *w,
                                                         QString *errorMessage) const
{
    Q_UNUSED(errorMessage)

    const ROSProjectWizardDialog *wizard = qobject_cast<const ROSProjectWizardDialog *>(w);
    const QDir wsDir(wizard->workspaceDirectory().toString());
    const QDir srcDir(wizard->sourceDirectory().toString());
    const QDir bldDir(wizard->buildDirectory().toString());

    const QString projectName = wizard->projectName();
    const QString creatorFileName = QFileInfo(wsDir, projectName + QLatin1String(".ros_creator")).absoluteFilePath();
    const QString filesFileName = QFileInfo(wsDir, projectName + QLatin1String(".ros_files")).absoluteFilePath();
    const QString includesFileName = QFileInfo(wsDir, projectName + QLatin1String(".ros_includes")).absoluteFilePath();
    const QString configFileName = QFileInfo(wsDir, projectName + QLatin1String(".ros_config")).absoluteFilePath();

    // Get all file in the workspace source directory
    QStringList workspaceFiles;
    QDirIterator it(srcDir, QDirIterator::Subdirectories);
    while (it.hasNext())
    {
      QDir curDir(it.next());
      QStringList dirFiles = curDir.entryList(QDir::NoDotAndDotDot | QDir::Files);
      curDir.makeAbsolute();
      foreach (const QString &str, dirFiles)
      {
        workspaceFiles.append(curDir.filePath(str));
      }
    }
Пример #5
0
int main(int argc, char *argv[]){
	qInstallMessageHandler(myMessageOutput);
    QCoreApplication a(argc, argv);    

    glb::mainThread = a.thread();	

    std::cout << std::endl << "Oi, mate!";

    qRegisterMetaType<QAbstractSocket::SocketError>();
    qRegisterMetaType<QAbstractSocket::SocketState>();

    //set current working directory to executable path
    //needed if started from within IDE
    boost::filesystem::path curDir(QCoreApplication::applicationDirPath().toStdString());
    boost::filesystem::current_path(curDir);

    srand(time(NULL));

    int alg = 0;

    if (argc < 2){
        std::cout << std::endl << "No algorithm specified -> using Central Mutual Exclusion algorithm";
    }
    else{
        QString inputAlg = argv[1];

        if (inputAlg == "RA"){
            std::cout << std::endl << "Ricart Agrawala algorithm selected";
            alg = 1;
        }
        else if (inputAlg == "CME"){
            std::cout << std::endl << "Central Mutual Exclusion algorithm selected";
        }
        else{
            std::cout << std::endl << "unknown algorithm specified -> using Central Mutual Exclusion algorithm";
        }
    }

    if (alg == 1){

    }
    else{
        //init the Server
        Server* server = new Server();
        server->init();

		Reader* reader = new Reader(server->getClient());
		reader->start();
    }

    return a.exec();
}
void SettingsWindow::addDirToList()
{
    QString currentDir = m_pcurrentDir->text();
    QDir curDir(currentDir);
    if(curDir.exists()){
        if(m_pdirectoryList->findItems(currentDir, Qt::MatchFixedString).isEmpty()){
            m_pdirectoryList->addItem(curDir.path());
        } else {
            QMessageBox::information(this, "Info", "Already in list.");
        }
    } else {
        QMessageBox::warning(this, "Path error", "Path doesn't exist!");
    }
}
Пример #7
0
void GenTool::initPath(const QString& sourcePath)
{
	// check if there is a compilation db file in this directory otherwise we exclude it
	QDir curDir(sourcePath);
	if (!curDir.exists("compile_commands.json"))
	{
		qDebug() << "Ignoring directory" << sourcePath << "because there is no compile_commands.json file";
		return;
	}
	// append to the projects
	projects_ << sourcePath;

	readInFiles(sourcePath);
	setCompilationDbPath(sourcePath);
}
Пример #8
0
static err_t FOG_CDECL FileUtil_createDirectory(const StringW* dir, bool recursive)
{
  if (dir->isEmpty())
    return ERR_RT_INVALID_ARGUMENT;

  if (!recursive)
    return FileUtil_createDirectoryHelper(dir->getData(), dir->getLength());

  StringTmpW<TEMPORARY_LENGTH> dirAbs;
  FOG_RETURN_ON_ERROR(FilePath::toAbsolute(dirAbs, *dir));

  // FilePath::toAbsolute() always normalize directory to '/'; we can imagine
  // that dirAbs is absolute dir, thus it's needed to find first two occurences
  // of '/' - second occurece can be at the end of string.
  if (dirAbs.getLength() == 1 && dirAbs.getAt(0) == '/')
    return ERR_PATH_EXISTS;

  size_t i = dirAbs.indexOf(CharW('/'));
  size_t length = dirAbs.getLength();

  if (i == INVALID_INDEX) return ERR_RT_INVALID_ARGUMENT;
  if (dirAbs.getAt(length-1) == CharW('/')) length--;

  do {
    i++;
    i = dirAbs.indexOf(Range(i, i + length), CharW('/'), CASE_SENSITIVE);

    StubW curDir(dirAbs.getData(), (i == INVALID_INDEX) ? length : i);
    err_t err = FileUtil_createDirectoryHelper(curDir.getData(), curDir.getLength());

    if (err == ERR_PATH_EXISTS)
    {
      if (FileUtil::isDirectory(curDir))
        continue;
      else
        return ERR_PATH_EXISTS;
    }

    if (err != ERR_OK)
      return err;

  } while (i != INVALID_INDEX);

  return ERR_OK;
}
Пример #9
0
    std::string GetCurrentDirectory()
    {
        // Determine the required buffer size to contain the current directory
        const DWORD curDirSize = GetCurrentDirectoryA(0, NULL);

        // GetCurrentDirectoryA returns zero only on an error, and this case is
        // particularily rare, so throw an exception.
        if (curDirSize == 0)
            throw Error::GetLast();

        // Create a buffer of the required size
        // @note: We're using a scoped_array here, instead of a variably sized
        //        array, because MSVC doesn't support variably sized arrays.
        scoped_array<char> curDir(new char[curDirSize]);

        // Retrieve the current directory
        ::GetCurrentDirectoryA(curDirSize, curDir.get());

        // Return the current directory as a STL string
        return std::string(curDir.get());
    }
Пример #10
0
        std::string ResolveIgniteHome(const std::string& path)
        {
            // 1. Check passed argument.
            if (IsValidDirectory(path))
                return path;

            // 2. Check environment variable.
            std::string home = GetEnv(IGNITE_HOME);

            if (IsValidDirectory(home))
                return home;

            // 3. Check current work dir.
            FixedSizeArray<char> curDir(1024 * 16);

            char* res = getcwd(curDir.GetData(), curDir.GetSize());

            if (!res)
				return std::string();

            std::string curDirStr(curDir.GetData());

            return ResolveIgniteHome0(curDirStr);
        }