Permalink
Browse files

RrmdirTask

  • Loading branch information...
1 parent 909647a commit 11d6bcb16cc432aba9f9eb44922c799b6388c9f3 heartsentwined committed Sep 13, 2012
Showing with 71 additions and 1 deletion.
  1. +1 −1 src/task/RchownTask.php
  2. +70 −0 src/task/RrmdirTask.php
View
@@ -58,7 +58,7 @@ public function init()
*/
public function main()
{
- if (!$this->file) throw new BuildException('dir must be set');
+ if (!$this->file) throw new BuildException('file must be set');
if (!$this->user) throw new BuildException('user must be set');
if (strpos($this->user, '.')) {
View
@@ -0,0 +1,70 @@
+<?php
+require_once __DIR__ . '/../../../../autoload.php';
+
+use Heartsentwined\FileSystemManager\FileSystemManager;
+
+class RrmdirTask extends Task
+{
+ protected $dir;
+ protected $failonerror = false;
+
+ /**
+ * directory to delete
+ *
+ * @param string $dir
+ * @return void
+ */
+ public function setDir($dir)
+ {
+ if (!is_dir($dir)) {
+ throw new BuildException(sprintf(
+ 'Directory does not exist: %s',
+ realpath($dir)
+ ));
+ }
+ if (!is_writable($dir)) {
+ throw new BuildException(sprintf(
+ 'Directory is not writable: %s',
+ realpath($dir)
+ ));
+ }
+ $this->dir = realpath($dir);
+ }
+
+ /**
+ * if error occured, whether build should fail
+ *
+ * @param bool $value
+ * @return void
+ */
+ public function setFailonerror($value)
+ {
+ $this->failonerror = $value;
+ }
+
+ /**
+ * init
+ *
+ * @return void
+ */
+ public function init()
+ {
+ }
+
+ /**
+ * main method
+ *
+ * @return void
+ */
+ public function main()
+ {
+ if (!$this->dir) throw new BuildException('dir must be set');
+
+ FileSystemManager::rrmdir($this->dir);
+
+ $this->log(sprintf(
+ 'Recursively deleted the directory \'%s\'',
+ $this->dir
+ ));
+ }
+}

0 comments on commit 11d6bcb

Please sign in to comment.