method move documentation in bbn\Ide\Directories

Moves a file or a directory.

function($dir, $src, $dest, $type = 'file') { ($root = $this->getRootPath($dir)) ){ $is_file = $type === 'file'; $wtype = $is_file ? 'file' : 'directory'; $pi = X::pathinfo($src); $pi['dirname'] = $pi['dirname'] === '.' ? '' : $pi['dirname']; $files = []; if ( $pi['dirname'] !== $dest ){ if ( !empty($cfg['tabs']) ){ $ext = false; foreach ( $cfg['tabs'] as $t ){ if ( empty($t['fixed']) ){ // MVC tab's path $real = $root . $t['path']; if ( $is_file ){ foreach ( $t['extensions'] as $e ){ $real_new = $real . $dest . '/' . $pi['filename']. '.' . $e['ext']; $real_ext = $real . $pi['dirname'] . '/' . $pi['filename'] . '.' . $e['ext']; if ( file_exists($real_ext) ){ if ( !file_exists($real_new) ){ $ext = empty($ext) ? $e['ext'] : $ext; $files[$real_ext] = $real_new; if ( $t['url'] === 'php' ){ $change_perm = [ 'old' => $real_ext, 'new' => $real_new, 'type' => 'file' ]; } } else { $this->error("The file $real_new is already exists."); return false; } } } if ( !empty($t['default']) ){ $file_url = $this->realToUrl($real_ext); $file_new_url = $this->realToUrl($real_new); } } else { $real_new = $real . $dest . '/' . $pi['basename']; $real .= $src; if ( file_exists($real) ){ if ( !file_exists($real_new) ){ $files[$real] = $real_new; if ( $t['url'] === 'php' ){ $change_perm = [ 'old' => $real, 'new' => $real_new, 'type' => 'dir' ]; } } else { $this->error("The directory $real_new is already exists."); return false; } } } if ( !empty($t['default']) ){ $file_new = $dest . '/' . $pi['basename']; } } } } else { $real = $root . $src; $real_new = $root . $dest . '/' . $pi['basename']; if ( file_exists($real) ){ if ( !file_exists($real_new) ){ $files[$real] = $real_new; } else { $this->error("The $wtype $real_new is already exists."); return false; } if ( $is_file ){ $file_url = $this->realToUrl($real); $file_new_url = $this->realToUrl($real_new); } $file_new = $dest . '/' . $pi['basename']; } } foreach ( $files as $s => $d ){ if ( !bbn\File\Dir::move($s, $d) ){ $this->error("Impossible to rename the $wtype: $s -> $d"); return false; } if ( is_file($s) ){ // Remove file's options (preferences) $this->options->remove($this->options->fromCode($this->realToId($s), $this->_files_pref())); } else { // Remove dir's options (preferences) $this->remDirOpt($s); } } // Change permission if ( !empty($change_perm) ){ $this->changePermByReal($change_perm['old'], $change_perm['new'], $change_perm['type']); } return [ 'file_url' => $file_url, 'file_new_url' => $file_new_url, 'file_new' => $file_new, ]; } $this->error("The old name and the new name are identical."); return false; } }

Moves a file or a directory. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.