コード例 #1
0
ファイル: mapperRoomRender.cpp プロジェクト: tmud/tortilla
bool MapperRoomRender::bidirectionalExit(const Room* r, int dir)
{
    const Room *r2 = r->dirs[dir].next_room;
    if (!r2) return false;
    int revert_dir = revertDir(dir);
    const Room* back = r2->dirs[revert_dir].next_room;
    return (r == back);    
}
コード例 #2
0
ファイル: LPGUtils.cpp プロジェクト: cthunter01/pcbsd
QStringList LPGUtils::revertDir(QString oldPath, QString newPath){
  //Note: this is a recursive function and can take quite a while to perform lots of file copies

  //Load the directories and create it if necessary
  QDir oDir(oldPath);
  QDir nDir(newPath);
  bool ok=true;
  if( !nDir.exists() ){
    //Create the new Directory
    qDebug() << "Re-Create parent directory structure:" << newPath;
    nDir.cdUp();
    ok = nDir.mkpath(newPath.section("/",-1)); //also create all parent directories if necessary
    if(ok){ 
      qDebug() << " - Reset permissions on the main parent dir to match snapshot";
      nDir.cd(newPath.section("/",-1)); 
      QFile::setPermissions(newPath, QFile::permissions(oldPath)); //make sure the new dir has the old permissions
      QFileInfo FI(oldPath);
      system( QString("chown "+FI.owner()+":"+FI.group()+" "+newPath).toUtf8() );
    }
  }
  //Get a list of any files that error
  QStringList errors;
  if(!ok){
    errors << newPath;
    return errors;
  }
  //Get a list of all the files in the old dir and copy them over
  QStringList fList = oDir.entryList(QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot, QDir::Name);
  for(int i=0; i<fList.length(); i++){
    if( !revertFile(oldPath+"/"+fList[i], newPath+"/"+fList[i]) ){
       errors << newPath+"/"+fList[i];
    }
  }
  //Now list all the directories in the old dir and recursively copy them over
  fList = oDir.entryList(QDir::Dirs | QDir::Hidden | QDir::NoDotAndDotDot, QDir::Name);
  for(int i=0; i<fList.length(); i++){
    QStringList errs = revertDir(oldPath+"/"+fList[i], newPath+"/"+fList[i]);
    if( !errs.isEmpty() ){ errors << errs; }
  }
  return errors;
}