private function _commit(Wrapper_FS_Changes $changes, $path = "")
  {
    $root = $this->getRoot();
    $rootpath = $root->path();

    if ($path) {
      $path .= "/";
    }

    $own = $changes->own();
    foreach ($own as $filename => $vEntity) {
      $filepath = $path . $filename;
      $rPath = $rootpath . "/" . $filepath;

      /* @var $vEntity Entity_Abstract|Entity_Virtual_Interface */
      $vExists = $vEntity->file_exists();
      $rDeleted = false;

      $rEntity = $vEntity;
      do {
        $rEntity = $rEntity->getRealEntity();
        $rDeleted = $rDeleted || !$rEntity->file_exists();
      } while ($rEntity instanceof Entity_Virtual_Interface);
      /* @var $rEntity Entity */
      $rExists = $rEntity->file_exists();
      if ($rExists && !$vExists) {
        $rDeleted = true;
      }

      if (!$vExists && !$rExists) {
        continue;
      } elseif ($rDeleted) {
        if ($rExists) {
          $this->_files->delete($rPath);
        }
        if ($vExists) {
          $this->_copyChanges($filepath);
        }
      } else {
        /* @var $vEntity Entity_Virtual */
        if ($vEntity->is_file()) {
          unlink($rPath);
          copy($vEntity->path(), $rPath);
        }
      }
    }

    $subtrees = $changes->sublists();
    foreach ($subtrees as $filename => $tree) {
      /* @var $tree Wrapper_FS_Changes */
      if (!isset($own[$filename])) {
        $this->_commit($tree, $path . $filename);
      }
    }

  }
private function _commit(Wrapper_FS_Changes $changes, $path = "")
  {
    $root = $this->getRoot();
    $rootpath = $root->path();

    if ($path) {
      $path .= "/";
    }

    $own = $changes->own();
    foreach ($own as $filename => $vEntity) {
      $filepath = $path . $filename;
      $rPath = $rootpath . "/" . $filepath;

      /* @var $vEntity Entity_Abstract|Entity_Virtual_Interface */
      $vExists = $vEntity->file_exists();
      $rDeleted = false;

      $rEntity = $vEntity;
      do {
        $rEntity = $rEntity->getRealEntity();
        $rDeleted = $rDeleted || !$rEntity->file_exists();
      } while ($rEntity instanceof Entity_Virtual_Interface);
      /* @var $rEntity Entity */
      $rExists = $rEntity->file_exists();
      if ($rExists && !$vExists) {
        $rDeleted = true;
      }

      if (!$vExists && !$rExists) {
        continue;
      } elseif ($rDeleted) {
        if ($rExists) {
          $this->_files->delete($rPath);
        }
        if ($vExists) {
          $this->_copyChanges($filepath);
        }
      } else {
        /* @var $vEntity Entity_Virtual */
        if ($vEntity->is_file()) {
          unlink($rPath);
          copy($vEntity->path(), $rPath);
        }
      }
    }

    $subtrees = $changes->sublists();
    foreach ($subtrees as $filename => $tree) {
      /* @var $tree Wrapper_FS_Changes */
      if (!isset($own[$filename])) {
        $this->_commit($tree, $path . $filename);
      }
    }

  }
private function _commit ( Wrapper_FS_Changes $ changes , $ path = "" ) { $ root = $ this -> getRoot ( ) ; $ rootpath = $ root -> path ( ) ; if ( $ path ) { $ path .= "/" ; } $ own = $ changes -> own ( ) ; foreach ( $ own as $ filename => $ vEntity ) { $ filepath = $ path . $ filename ; $ rPath = $ rootpath . "/" . $ filepath ; /* @var $vEntity Entity_Abstract|Entity_Virtual_Interface */ $ vExists = $ vEntity -> file_exists ( ) ; $ rDeleted = false ; $ rEntity = $ vEntity ; do { $ rEntity = $ rEntity -> getRealEntity ( ) ; $ rDeleted = $ rDeleted || ! $ rEntity -> file_exists ( ) ; } while ( $ rEntity instanceof Entity_Virtual_Interface ) ; /* @var $rEntity Entity */ $ rExists = $ rEntity -> file_exists ( ) ; if ( $ rExists && ! $ vExists ) { $ rDeleted = true ; } if ( ! $ vExists && ! $ rExists ) { continue ; } elseif ( $ rDeleted ) { if ( $ rExists ) { $ this -> _files -> delete ( $ rPath ) ; } if ( $ vExists ) { $ this -> _copyChanges ( $ filepath ) ; } } else { /* @var $vEntity Entity_Virtual */ if ( $ vEntity -> is_file ( ) ) { unlink ( $ rPath ) ; copy ( $ vEntity -> path ( ) , $ rPath ) ; } } } $ subtrees = $ changes -> sublists ( ) ; foreach ( $ subtrees as $ filename => $ tree ) { /* @var $tree Wrapper_FS_Changes */ if ( ! isset ( $ own [ $ filename ] ) ) { $ this -> _commit ( $ tree , $ path . $ filename ) ; } } }
Commit changes into real FS

Если удалено и не существовало с самого начала
- ничего не делаем
Иначе если когда-то не существовало
- удаляем всё RДерево
- Если сейчас существует, то
- переносим всё VДерево
Иначе если это файл, то
- удаляем RФайл
- копируем VФайл на место RФайла

По всем subtree
- сделать тоже самое, если не было собственных изменений

@param Wrapper_FS_Changes $changes Changes in FS
@param string             $path    Path to commit

@return null
Commit changes into real FS