move() 정적인 공개 메소드

Moves a directory to a new location
static public move ( string $old, string $new ) : boolean
$old string The current path of the directory
$new string The desired path where the dir should be moved to
리턴 boolean True: the directory has been moved, false: moving failed
예제 #1
0
 static function changeNum($uid, $num)
 {
     $p = self::childByUID($uid);
     if (!$p) {
         return array('status' => 'error', 'msg' => l::get('pages.errors.notfound'));
     }
     if ($num == $p->num()) {
         return array('status' => 'success', 'msg' => l::get('nochanges'));
     }
     $dirname = dirname($p->root()) . '/' . $num . '-' . $p->uid();
     if (!dir::move($p->root(), $dirname)) {
         return array('status' => 'error', 'msg' => l::get('pages.errors.move'));
     }
     return array('status' => 'success', 'msg' => l::get('pages.moved'));
 }
예제 #2
0
파일: folder.php 프로젝트: LucasFyl/korakia
 /**
  * Moves the directory to a new location
  * 
  * @param string $to
  * @return boolean
  */
 public function move($to)
 {
     if (!dir::move($this->root, $to)) {
         return false;
     } else {
         $this->root = true;
         return true;
     }
 }
예제 #3
0
파일: page.php 프로젝트: LucasFyl/korakia
 /**
  * Make the page invisible by removing the prepended number
  */
 public function hide()
 {
     if ($this->isInvisible()) {
         return true;
     }
     $root = dirname($this->root()) . DS . $this->uid();
     if (!dir::move($this->root(), $root)) {
         throw new Exception('The directory could not be moved');
     }
     $this->dirname = $this->uid();
     $this->num = null;
     $this->root = $root;
     $this->kirby->cache()->flush();
     $this->reset();
     return true;
 }
예제 #4
0
 public function testMove()
 {
     $this->assertTrue(dir::move($this->tmpDir, $this->movedDir));
 }
예제 #5
0
파일: item.php 프로젝트: Zegnat/library
 protected function relocate()
 {
     if ($this->old['created'] == $this->data['created']) {
         return;
     }
     $old = clone $this;
     $old->created = $this->old['created'];
     if (!$old->exists()) {
         return;
     }
     if (!dir::make($this->root())) {
         throw new Exception('The new directory could not be created');
     }
     if (!dir::move($old->root(), $this->root())) {
         throw new Exception('The directory could not be moved');
     }
     $this->library->clean($old->root('day'));
 }
예제 #6
0
파일: Plugin.php 프로젝트: getkirby/cli
 /**
  * Move the source to the final destination
  */
 protected function move()
 {
     $exists = $this->pluginExists();
     $error = $exists ? 'The plugin could not be updated' : 'The plugin could not be installed';
     $success = $exists ? 'The plugin has been updated to version:' : 'The plugin has been installed at version:';
     if ($exists) {
         $this->output->writeln('<info>Updating plugin...</info>');
     } else {
         $this->output->writeln('<info>Installing plugin...</info>');
     }
     $this->output->writeln('<info></info>');
     $this->prepare();
     $src = $this->source();
     $dest = $this->destination();
     // overwriting means having to clean the plugin first
     if (is_dir($dest)) {
         if (!dir::remove($dest)) {
             throw new RuntimeException('The old plugin could not be removed before the update');
         }
     }
     if (is_file($src)) {
         if (!f::move($src, $dest)) {
             throw new RuntimeException($error);
         }
     } else {
         if (is_dir($src)) {
             if (!dir::move($src, $dest)) {
                 throw new RuntimeException($error);
             }
         } else {
             throw new RuntimeException('Invalid source');
         }
     }
     $this->output->writeln('<comment>' . $success . ' "' . $this->version() . '"</comment>');
 }