Esempio n. 1
0
<?php

uv_fs_mkdir(uv_default_loop(), "hoge", 0644, function ($result) {
    var_dump($result);
});
uv_run();
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function mkdir($path, $mode = 0644)
 {
     $this->reactor->addRef();
     $promisor = new Deferred();
     \uv_fs_mkdir($this->loop, $path, $mode, function ($fh) use($promisor) {
         $this->reactor->delRef();
         $promisor->succeed((bool) $fh);
     });
     return $promisor->promise();
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function mkdir($path, $mode = 0666, $recursive = false)
 {
     $this->reactor->addRef();
     $promisor = new Deferred();
     if ($recursive) {
         $path = str_replace("/", DIRECTORY_SEPARATOR, $path);
         $arrayPath = array_filter(explode(DIRECTORY_SEPARATOR, $path));
         $tmpPath = "";
         $callback = function () use(&$callback, &$arrayPath, &$tmpPath, $mode, $promisor) {
             $tmpPath .= DIRECTORY_SEPARATOR . array_shift($arrayPath);
             if (empty($arrayPath)) {
                 \uv_fs_mkdir($this->loop, $tmpPath, $mode, function ($fh) use($promisor) {
                     $this->reactor->delRef();
                     $promisor->succeed((bool) $fh);
                 });
             } else {
                 $this->isdir($tmpPath)->when(function ($error, $result) use($callback, $tmpPath, $mode) {
                     if ($result) {
                         $callback();
                     } else {
                         \uv_fs_mkdir($this->loop, $tmpPath, $mode, $callback);
                     }
                 });
             }
         };
         $callback();
     } else {
         \uv_fs_mkdir($this->loop, $path, $mode, function ($fh) use($promisor) {
             $this->reactor->delRef();
             $promisor->succeed((bool) $fh);
         });
     }
     return $promisor->promise();
 }