Example #1
0
 /**
  * {@inheritdoc}
  */
 public function mkdir($path, $mode = 0644)
 {
     $this->incrementPending();
     $promisor = new Deferred();
     $priority = \EIO_PRI_DEFAULT;
     \eio_mkdir($path, $mode, $priority, [$this, "onGenericResult"], $promisor);
     return $promisor->promise();
 }
Example #2
0
 /**
  * Creates directory
  * @param  string   $path Path
  * @param  integer  $mode Mode (octal)
  * @param  callable $cb   Callback
  * @param  integer  $pri  Priority
  * @return resource|boolean
  */
 public static function mkdir($path, $mode, $cb = null, $pri = EIO_PRI_DEFAULT)
 {
     $cb = CallbackWrapper::forceWrap($cb);
     if (!FileSystem::$supported) {
         $r = mkdir($path, $mode);
         if ($cb) {
             call_user_func($cb, $path, $r);
         }
         return $r;
     }
     return eio_mkdir($path, $mode, $pri, $cb, $path);
 }
Example #3
0
 public static function mkdir($path, $mode, $cb = null, $pri = EIO_PRI_DEFAULT)
 {
     if (!FS::$supported) {
         $r = mkdir($path, $mode);
         if ($cb) {
             call_user_func($cb, $path, $r);
         }
         return;
     }
     return eio_mkdir($path, $mode, $pri, $cb, $path);
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 public function mkDir(string $path, int $mode = 0755) : \Generator
 {
     $delayed = new Delayed();
     \eio_mkdir($path, $mode, null, function (Delayed $delayed, $result, $req) {
         if (-1 === $result) {
             $delayed->reject(new FileException(sprintf('Could not create directory: %s.', \eio_get_last_error($req))));
         } else {
             $delayed->resolve(true);
         }
     }, $delayed);
     $this->poll->listen();
     try {
         $result = (yield $delayed);
     } finally {
         $this->poll->done();
     }
     return $result;
 }
Example #5
0
 /**
  * {@inheritdoc}
  */
 public function mkdir($path, $mode = 0666, $recursive = false)
 {
     \call_user_func($this->incrementor, 1);
     $promisor = new Deferred();
     $priority = \EIO_PRI_DEFAULT;
     if ($recursive) {
         $path = str_replace("/", DIRECTORY_SEPARATOR, $path);
         $arrayPath = array_filter(explode(DIRECTORY_SEPARATOR, $path));
         $tmpPath = "";
         $callback = function () use(&$callback, &$arrayPath, &$tmpPath, $mode, $priority, $promisor) {
             $tmpPath .= DIRECTORY_SEPARATOR . array_shift($arrayPath);
             if (empty($arrayPath)) {
                 \eio_mkdir($tmpPath, $mode, $priority, [$this, "onGenericResult"], $promisor);
             } else {
                 $this->isdir($tmpPath)->when(function ($error, $result) use($callback, $tmpPath, $mode, $priority) {
                     if ($result) {
                         $callback();
                     } else {
                         \eio_mkdir($tmpPath, $mode, $priority, $callback);
                     }
                 });
             }
         };
         $callback();
     } else {
         \eio_mkdir($path, $mode, $priority, [$this, "onGenericResult"], $promisor);
     }
     return $promisor->promise();
 }