Exemple #1
0
/*
Strips the path out of [fileWithPath]
*/
QString getFileName(const QString &fileWithPath)
{
  QString tmp = charReplace(fileWithPath, '\\', "/");
  int pos = tmp.findRev('/');
  if (pos == -1)
    return tmp;
  return tmp.mid(pos + 1);
}
Exemple #2
0
bool CConfig::exists(const QString &name, const QString &path)
{
#ifdef DEBUG
  qDebug("static CConfig::exists('%s', '%s')", debug_string(name), debug_string(path));
#endif
  
  QString f = getRootConfigPath();
  if (!path.isEmpty())
    f += path + "/";
  f += charReplace(name, ':', ";");
  return QFile::exists(f);
}
Exemple #3
0
void createPath(char* pathToCreate)
{
    charReplace(pathToCreate,'/','\\');

    DIR* dir = opendir(pathToCreate);

    if (dir)
    {
        closedir(dir);
    }
    else
    {
        char* mdCommand = (char*) malloc(strlen("md \"%s\"") + strlen(pathToCreate) + 1);
        sprintf(mdCommand,"md \"%s\"",pathToCreate);
        //printf("\n%s\n",mdCommand);
        system(mdCommand);
        free (mdCommand);
    }
}
Exemple #4
0
void CConfig::list(QStringList &list, const QString &path)
{
#ifdef DEBUG
  qDebug("static CConfig::list(QStringList &, '%s')", debug_string(path));
#endif
  
  QDir dir = QDir(getRootConfigPath() + path);
  if (!dir.exists())
    return;
  const QFileInfoList *filist = dir.entryInfoList( QDir::DefaultFilter, QDir::DirsFirst | QDir::Name );
  QFileInfoListIterator it( *filist );
  QFileInfo *fi;    
  while ( ( fi = it.current() ) != 0 )
  {
    ++it;
    if ( fi && fi->fileName() != ".." && fi->fileName() != ".")
      list.append(charReplace(fi->fileName(), ';', ":"));      
  }  
}
Exemple #5
0
void CConfig::setConfigName(const QString &name, const QString &path)
{
#ifdef DEBUG
  qDebug("CConfig::setConfigName('%s', '%s')", debug_string(name), debug_string(path));
#endif
  
  QString tmpFile;
  if (name.isNull())  
    tmpFile = QString(EXENAME) + ".cfg";
  else
    tmpFile = name;  
  
  QString tmpPath = QString::null;
  if (!path.isNull())    
    tmpPath = path + "/";
  
  absoluteConfigPath = getRootConfigPath() + tmpPath;
  
  if (!tmpPath.isNull())
    createDirectory(absoluteConfigPath);
  
  absoluteConfigFileName = absoluteConfigPath + charReplace(tmpFile, ':', ";");
}