Esempio n. 1
0
bool CompilerFactory::profile_existing(const std::string &prof, const std::string &additional_path) 
{
  std::string profile_file(prof);
  if (profile_file.length()>4 && (strcasecmp(profile_file.substr(profile_file.length()-4).c_str(),".exe")==0))
    profile_file = profile_file.substr(0,profile_file.length()-4);
  profile_file+=".cspro";
  { // Search directly
    if (additional_path.length()>0)
    {
      std::string prof_path=additional_path+FILE_SEPARATOR_CHAR+profile_file;
      FILE *f=fopen(prof_path.c_str(),"r");
      if (f)
      {
        fclose(f);
        return true;
      }
    }
  }

  { // Search in path
    std::string found_file=findFileInPath(profile_file,0);
    if (!found_file.empty())
      return true;
  }
  return false;
}
Esempio n. 2
0
QStringList Nicookie::firefoxGetProfileList(const QString &profile_ini)
{
    QStringList list;
    QFile profile_file(profile_ini);
    if (!profile_file.exists()) {
        setError(Nicookie::FailedParseProfileError);
        return list;
    }

    QTemporaryFile profile_temp;
    QString profile_temp_path = profile_temp.fileTemplate();
    if (profile_file.copy(profile_temp_path)) {
        setError(Nicookie::FailedParseProfileError);
        return list;
    }

    QSettings profile_settings(profile_temp_path, QSettings::IniFormat);
    if (profile_settings.status() != QSettings::NoError) {
        setError(Nicookie::FailedParseProfileError);
        return list;
    }

    for (auto &group: profile_settings.childGroups()) {
        if (group.startsWith("Profile")) {
            profile_settings.beginGroup(group);
            QString path;
            if (profile_settings.value("IsRelative", 1).toInt() == 1) {
                path = QFileInfo(profile_file).dir().filePath(
                            profile_settings.value("Path").toString());
            } else {
                path = profile_settings.value("Path").toString();
            }
            if (profile_settings.value("Default", 0).toInt() == 1) {
                list.prepend(path);
            } else {
                list.append(path);
            }
            profile_settings.endGroup();
        }
    }

    if (list.isEmpty()) {
        setError(Nicookie::FailedParseProfileError);
    }
    return list;
}