Logo Search packages:      
Sourcecode: icemc version File versions  Download package

QString IceFileSearch::lookupExecutable ( QString  name,
const QString  path = 0 
) [protected, virtual]

Searches for an executable file. This method duplicates some code (lookupFile is quite similar).

Definition at line 131 of file IceFileSearch.cpp.

                                                                        {
  QString fullPath;
  QString s = path;
  uint sLen = s.length();
  fInfo->setFile(name);
  uint pos = 0;

  if (fInfo->isExecutable()) // name == correct absolute filename
    fullPath = name;
  else { // analyse path
    do {
      pos = 0;
      while ((pos<sLen) && (s.at(pos) != ':'))
      pos++;   
      
      fullPath = s.left(pos);
      
      if ((pos > 0) && (fullPath.at(pos-1) != '/'))
      fullPath += '/';
      fullPath += name;
      
      if (sLen>pos)
      s = s.right(sLen-(pos+1));
      else
      s = "";
      sLen = s.length();
      
      // test if exists
      fInfo->setFile(fullPath);
      if (fInfo->isExecutable()) {
      sLen = 0; // break
      } else 
      fullPath = "";      
    } while (sLen > 0);
  }
  return fullPath; // might also return a relative path!
}  


Generated by  Doxygen 1.6.0   Back to index