//--------------------------------------------------------------------------------------------------
/// Returns the InputProperties pointing to the same file as \a fileName
//--------------------------------------------------------------------------------------------------
std::vector<RimInputProperty*> RimInputPropertyCollection::findInputProperties(QString fileName)
{
    QFileInfo fileInfo(fileName);
    std::vector<RimInputProperty*> result;
    for (size_t i = 0; i < this->inputProperties.size(); ++i)
    {
        if (!inputProperties[i]) continue;

        QFileInfo propFile(inputProperties[i]->fileName());
        if (fileInfo == propFile) result.push_back(inputProperties[i]);
    }

    return result;
}
Exemple #2
0
void getProps(char *propFileName){
  std::ifstream propFile(propFileName);
	
	if (!propFile) {
		std::cout  << "propertyfile " << propFileName << " not found" << std::endl;
		exit(1);
	}
	//const char *delim = "=";
	char prop[150],val[150];
	while (!propFile.eof()) {
		propFile.getline(prop,150,'=');
		propFile.getline(val,150,'\n');
		if ((prop!=NULL) && (val!=NULL)) {
			setProp(prop,val);
			std::cout << prop << " = " << val << std::endl;
		}
	}
}
int Utils::GetPiVersion(const QString &propFilePath)
{
    int version = 0;

    // open devices proc file
    QFile propFile(propFilePath);
    if (!propFile.exists())
    {
        SendMessage("Device Property file missing " + propFilePath);
        return 0;
    }
    if (!propFile.open(QFile::ReadOnly | QFile::Text))
    {
        SendMessage("Could not open device property file " + propFilePath);
        return 0;
    }
    QString deviceDesc = propFile.readAll();
    propFile.close();

    // Extract Pi ver from text
    QRegExp regEx("Pi (\\d+)");
    if (regEx.indexIn(deviceDesc))
    {
        QStringList versionList = regEx.capturedTexts();

        if (versionList.count() > 1)
        {
            bool ok;
            QString versionStr = versionList.at(1);
            SendMessage("version = " + versionStr);
            version = versionStr.toInt(&ok);
            if (ok)
            {
                return version;
            }
        }
    }

    if (!version)
    {
        SendMessage("Version not found from " + propFilePath);
    }
    return version;
}