remove() 정적인 공개 메소드

Deletes a directory
static public remove ( string $dir, boolean $keep = false ) : boolean
$dir string The path of the directory
$keep boolean If set to true, the directory will flushed but not removed.
리턴 boolean True: the directory has been removed, false: removing failed
예제 #1
0
파일: Uninstall.php 프로젝트: getkirby/cli
 protected function uninstall($plugin, $output)
 {
     $root = $this->kirby()->roots()->plugins() . DS . $plugin;
     dir::remove($root);
     $output->writeln('<comment>The "' . $plugin . '" plugin has been removed!</comment>');
     $output->writeln('');
 }
예제 #2
0
 public function testSize()
 {
     dir::make($this->tmpDir);
     f::write($this->tmpDir . DS . 'testfile-1.txt', str::random(5));
     f::write($this->tmpDir . DS . 'testfile-2.txt', str::random(5));
     f::write($this->tmpDir . DS . 'testfile-3.txt', str::random(5));
     $this->assertEquals(15, dir::size($this->tmpDir));
     $this->assertEquals('15 b', dir::niceSize($this->tmpDir));
     dir::remove($this->tmpDir);
 }
예제 #3
0
파일: Panel.php 프로젝트: getkirby/cli
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($this->isInstalled() === false) {
         throw new RuntimeException('Invalid Kirby installation');
     }
     $helper = $this->getHelper('question');
     $question = new ConfirmationQuestion('<info>Do you really want to uninstall the Panel? (y/n)</info>' . PHP_EOL . 'leave blank to cancel: ', false);
     if ($helper->ask($input, $output, $question)) {
         // load kirby
         $this->bootstrap();
         // remove the panel folder
         dir::remove($this->dir() . DS . 'panel');
         $output->writeln('<comment>The panel has been uninstalled!</comment>');
         $output->writeln('');
     }
 }
예제 #4
0
파일: Uninstall.php 프로젝트: getkirby/cli
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($this->isInstalled() === false) {
         throw new RuntimeException('Invalid Kirby installation');
     }
     $helper = $this->getHelper('question');
     $question = new ConfirmationQuestion('<info>Do you really want to uninstall Kirby? (y/n)</info>' . PHP_EOL . 'leave blank to cancel: ', false);
     if ($helper->ask($input, $output, $question)) {
         // load kirby
         $this->bootstrap();
         f::remove($this->dir() . DS . 'index.php');
         f::remove($this->dir() . DS . '.htaccess');
         f::remove($this->dir() . DS . '.gitignore');
         f::remove($this->dir() . DS . 'license.md');
         f::remove($this->dir() . DS . 'readme.md');
         dir::remove($this->dir() . DS . 'kirby');
         dir::remove($this->dir() . DS . 'panel');
         dir::remove($this->dir() . DS . 'thumbs');
         $output->writeln('<comment>Kirby has been uninstalled!</comment>');
         $output->writeln('');
     }
 }
예제 #5
0
파일: page.php 프로젝트: LucasFyl/korakia
 /**
  * Deletes the page
  *
  * @param boolean $force Forces the page to be deleted even if there are subpages
  */
 public function delete($force = false)
 {
     if (!$this->isDeletable()) {
         throw new Exception('The page cannot be deleted');
     }
     if ($force === false and $this->children()->count()) {
         throw new Exception('This page has subpages');
     }
     $parent = $this->parent();
     if (!dir::remove($this->root())) {
         throw new Exception('The page could not be deleted');
     }
     $this->kirby->cache()->flush();
     $parent->reset();
     return true;
 }
function resizeOnDemandDeleteDir($pageId)
{
    $path = str_replace('/', DS, $pageId);
    $root = kirby()->roots()->index() . DS . 'thumbs' . DS . $path;
    // delete directory with resized images
    if (f::exists($root)) {
        dir::remove($root, false);
    }
}
예제 #7
0
파일: testcase.php 프로젝트: Zegnat/library
 protected function tearDown()
 {
     dir::remove($this->root);
 }
예제 #8
0
파일: page.php 프로젝트: nsteiner/kdoc
 /**
  * Clean the thumbs folder for the page
  * 
  */
 public function removeThumbs()
 {
     return dir::remove($this->kirby()->roots()->thumbs() . DS . $this->id());
 }
예제 #9
0
 static function deleteDir()
 {
     $delete = self::childByUID(get('uid'));
     if (!$delete) {
         return array('status' => 'error', 'msg' => l::get('pages.errors.notfound'));
     }
     if ($delete->isHomePage()) {
         return array('status' => 'error', 'msg' => l::get('pages.delete.errors.homepage'));
     }
     if ($delete->isErrorPage()) {
         return array('status' => 'error', 'msg' => l::get('pages.delete.errors.errorpage'));
     }
     if ($delete->hasChildren()) {
         return array('status' => 'error', 'msg' => l::get('pages.delete.errors.subpages'));
     }
     if (!dir::remove($delete->root())) {
         return array('status' => 'error', 'msg' => l::get('pages.delete.errors.permissions'));
     }
     self::killCache();
     return array('status' => 'success', 'msg' => l::get('pages.delete.success'));
 }
예제 #10
0
파일: item.php 프로젝트: Zegnat/library
 public function delete()
 {
     // get this before the item is killed
     $dayroot = $this->root('day');
     if (!dir::remove($this->root())) {
         throw new Exception('The item directory could not be removed');
     }
     if (!$this->library->database->query('delete from items where id = :id', array('id' => $this->id))) {
         throw new Exception('The delete query failed');
     }
     // make sure to clean up the directory attic
     $this->library->clean($dayroot);
 }
예제 #11
0
 /**
  * Overload delete to include assets
  * when the object is deleted.
  */
 public function delete($id = NULL)
 {
     if ($id === NULL and $this->loaded) {
         # delete testimonial survey questions
         ORM::factory('question')->where(array('owner_id' => $id))->delete_all();
         echo 'survey questions deleted<br/>';
         # delete testimonial tags/categories
         ORM::factory('tag')->where(array('owner_id' => $id))->delete_all();
         echo 'testimonial tags deleted<br/>';
         # delete tconfigs
         ORM::factory('tconfig')->where(array('owner_id' => $id))->delete_all();
         echo 'tconfig settings deleted<br/>';
         # delete all testimonials
         ORM::factory('testimonial')->where(array('owner_id' => $id))->delete_all();
         echo 'testimonials deleted<br/>';
         # delete owner data folder.
         $folder = t_paths::data($this->apikey);
         if (dir::remove($folder)) {
             echo "data directory {$folder} deleted<br/>";
         }
     }
     return parent::delete($id);
 }
예제 #12
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>');
 }
예제 #13
0
파일: library.php 프로젝트: Zegnat/library
 public function clean($root)
 {
     if (!is_dir($root)) {
         throw new Exception('The given directory does not exist');
     }
     if (!str::startsWith($root, $this->root)) {
         throw new Exception('Invalid directory. Must be within the library');
     }
     while ($root != $this->root) {
         $files = dir::read($root);
         if (count($files) === 0) {
             dir::remove($root);
         } else {
             break;
         }
         $root = dirname($root);
     }
 }
예제 #14
0
파일: Plugin.php 프로젝트: getkirby/cli
 protected function delete($name, $output)
 {
     dir::remove($this->root() . DS . $name);
     $output->writeln('<comment>The "' . $name . '" plugin has been deleted!</comment>');
     $output->writeln('');
 }