コード例 #1
0
ファイル: config.cpp プロジェクト: KdeOs/pcbsd
bool Config::checkDirectoryStructure(){
 //Check for EasyPBI directory structure and create it if it is not there
  if( !QDir(defaultSettings[1]).exists() ){
    qDebug() << "Creating the EasyPBI directory in current user's home folder:" << defaultSettings[1];
    QDir dir;
    dir.root();
    if( !dir.mkdir(defaultSettings[1]) ){ //Create the program directory
      //Could not create the Program directory
      qDebug() << " - Error with home directory permissions, could not create directory";
      return FALSE;
    }
  }  
  if( !QDir(defaultSettings[3]).exists() ){
    QDir dir;
    dir.root();
    if( !dir.mkdir(defaultSettings[3]) ){ //module directory
      qDebug() << " - Error with directory permissions, could not create directory" << defaultSettings[3];
      return FALSE;
    }
  }  
  if( !QDir(defaultSettings[2]).exists() ){
    QDir dir;
    dir.root();
    if( !dir.mkdir(defaultSettings[2]) ){ // PBI output directory
      qDebug() << " - Error with directory permissions, could not create directory" << defaultSettings[2];
      return FALSE;
    }
  }  
  if( !QDir(defaultSettings[4]).exists() ){
    QDir dir;
    dir.root();
    if( !dir.mkdir(defaultSettings[4]) ){ // pkg cache
      qDebug() << " - Error with directory permissions, could not create directory" << defaultSettings[4];
      return FALSE;
    }
  }  

  //Check for the defaulticons.png file
  if( !QFile(defaultSettings[5]).exists() ){
    //file does not exist, copy the included resource to the file
    qDebug() << " - Copying the default icon to the EasyPBI directory";
    QFile::copy(":/png/icons/defaulticon.png",defaultSettings[5]);
    
    QFile::setPermissions(defaultSettings[5],QFile::ReadGroup | QFile::WriteGroup | QFile::ReadOwner | QFile::WriteOwner | QFile::ReadOther | QFile::WriteOther);
  }
  return TRUE;
}