forked from reactphp/filesystem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile_create_new.php
24 lines (21 loc) · 1007 Bytes
/
file_create_new.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
use React\Filesystem\Factory;
use React\Filesystem\Node\FileInterface;
use React\Filesystem\Node\NotExistInterface;
use React\Filesystem\Stat;
use React\Promise\PromiseInterface;
require 'vendor/autoload.php';
Factory::create()->detect(sys_get_temp_dir() . __FILE__ . time() . time() . time() . time() . time() . time())->then(static function (NotExistInterface $node): PromiseInterface {
return $node->createFile();
})->then(static function (FileInterface $file): PromiseInterface {
return $file->stat();
})->then(static function (Stat $stat): void {
echo $stat->path(), ': ', get_class($stat), PHP_EOL;
echo 'Mode: ', $stat->mode(), PHP_EOL;
echo 'Uid: ', $stat->uid(), PHP_EOL;
echo 'Gid: ', $stat->gid(), PHP_EOL;
echo 'Size: ', $stat->size(), PHP_EOL;
echo 'Atime: ', $stat->atime()->format(DATE_ISO8601), PHP_EOL;
echo 'Mtime: ', $stat->mtime()->format(DATE_ISO8601), PHP_EOL;
echo 'Ctime: ', $stat->ctime()->format(DATE_ISO8601), PHP_EOL;
})->done();