mirror of
https://github.com/danog/file.git
synced 2024-11-26 11:54:54 +01:00
when() → onResolve()
This commit is contained in:
parent
b3f354472f
commit
97256b9029
@ -154,7 +154,7 @@ class EioDriver implements Driver {
|
||||
*/
|
||||
public function exists(string $path): Promise {
|
||||
$deferred = new Deferred;
|
||||
$this->stat($path)->when(function ($error, $result) use ($deferred) {
|
||||
$this->stat($path)->onResolve(function ($error, $result) use ($deferred) {
|
||||
$deferred->resolve((bool) $result);
|
||||
});
|
||||
|
||||
@ -166,7 +166,7 @@ class EioDriver implements Driver {
|
||||
*/
|
||||
public function isdir(string $path): Promise {
|
||||
$deferred = new Deferred;
|
||||
$this->stat($path)->when(function ($error, $result) use ($deferred) {
|
||||
$this->stat($path)->onResolve(function ($error, $result) use ($deferred) {
|
||||
if ($result) {
|
||||
$deferred->resolve(!($result["mode"] & \EIO_S_IFREG));
|
||||
} else {
|
||||
@ -182,7 +182,7 @@ class EioDriver implements Driver {
|
||||
*/
|
||||
public function isfile(string $path): Promise {
|
||||
$deferred = new Deferred;
|
||||
$this->stat($path)->when(function ($error, $result) use ($deferred) {
|
||||
$this->stat($path)->onResolve(function ($error, $result) use ($deferred) {
|
||||
if ($result) {
|
||||
$deferred->resolve((bool) ($result["mode"] & \EIO_S_IFREG));
|
||||
} else {
|
||||
@ -198,7 +198,7 @@ class EioDriver implements Driver {
|
||||
*/
|
||||
public function size(string $path): Promise {
|
||||
$deferred = new Deferred;
|
||||
$this->stat($path)->when(function ($error, $result) use ($deferred) {
|
||||
$this->stat($path)->onResolve(function ($error, $result) use ($deferred) {
|
||||
if (empty($result)) {
|
||||
$deferred->fail(new FilesystemException(
|
||||
"Specified path does not exist"
|
||||
@ -220,7 +220,7 @@ class EioDriver implements Driver {
|
||||
*/
|
||||
public function mtime(string $path): Promise {
|
||||
$deferred = new Deferred;
|
||||
$this->stat($path)->when(function ($error, $result) use ($deferred) {
|
||||
$this->stat($path)->onResolve(function ($error, $result) use ($deferred) {
|
||||
if ($result) {
|
||||
$deferred->resolve($result["mtime"]);
|
||||
} else {
|
||||
@ -238,7 +238,7 @@ class EioDriver implements Driver {
|
||||
*/
|
||||
public function atime(string $path): Promise {
|
||||
$deferred = new Deferred;
|
||||
$this->stat($path)->when(function ($error, $result) use ($deferred) {
|
||||
$this->stat($path)->onResolve(function ($error, $result) use ($deferred) {
|
||||
if ($result) {
|
||||
$deferred->resolve($result["atime"]);
|
||||
} else {
|
||||
@ -256,7 +256,7 @@ class EioDriver implements Driver {
|
||||
*/
|
||||
public function ctime(string $path): Promise {
|
||||
$deferred = new Deferred;
|
||||
$this->stat($path)->when(function ($error, $result) use ($deferred) {
|
||||
$this->stat($path)->onResolve(function ($error, $result) use ($deferred) {
|
||||
if ($result) {
|
||||
$deferred->resolve($result["ctime"]);
|
||||
} else {
|
||||
@ -395,7 +395,7 @@ class EioDriver implements Driver {
|
||||
if (empty($arrayPath)) {
|
||||
\eio_mkdir($tmpPath, $mode, $priority, [$this, "onGenericResult"], $deferred);
|
||||
} else {
|
||||
$this->isdir($tmpPath)->when(function ($error, $result) use (
|
||||
$this->isdir($tmpPath)->onResolve(function ($error, $result) use (
|
||||
$callback, $tmpPath, $mode, $priority
|
||||
) {
|
||||
if ($result) {
|
||||
|
@ -32,7 +32,7 @@ class ParallelDriver implements Driver {
|
||||
|
||||
$deferred = new Deferred;
|
||||
$promise = $worker->enqueue($task);
|
||||
$promise->when(static function ($exception, array $result = null) use ($worker, $deferred, $path) {
|
||||
$promise->onResolve(static function ($exception, array $result = null) use ($worker, $deferred, $path) {
|
||||
if ($exception) {
|
||||
$deferred->fail($exception);
|
||||
return;
|
||||
|
@ -133,7 +133,7 @@ class UvDriver implements Driver {
|
||||
*/
|
||||
public function exists(string $path): Promise {
|
||||
$deferred = new Deferred;
|
||||
$this->stat($path)->when(function ($error, $result) use ($deferred) {
|
||||
$this->stat($path)->onResolve(function ($error, $result) use ($deferred) {
|
||||
$deferred->resolve((bool) $result);
|
||||
});
|
||||
|
||||
@ -145,7 +145,7 @@ class UvDriver implements Driver {
|
||||
*/
|
||||
public function isdir(string $path): Promise {
|
||||
$deferred = new Deferred;
|
||||
$this->stat($path)->when(function ($error, $result) use ($deferred) {
|
||||
$this->stat($path)->onResolve(function ($error, $result) use ($deferred) {
|
||||
if ($result) {
|
||||
$deferred->resolve(!($result["mode"] & \UV::S_IFREG));
|
||||
} else {
|
||||
@ -161,7 +161,7 @@ class UvDriver implements Driver {
|
||||
*/
|
||||
public function isfile(string $path): Promise {
|
||||
$deferred = new Deferred;
|
||||
$this->stat($path)->when(function ($error, $result) use ($deferred) {
|
||||
$this->stat($path)->onResolve(function ($error, $result) use ($deferred) {
|
||||
if ($result) {
|
||||
$deferred->resolve((bool) ($result["mode"] & \UV::S_IFREG));
|
||||
} else {
|
||||
@ -177,7 +177,7 @@ class UvDriver implements Driver {
|
||||
*/
|
||||
public function size(string $path): Promise {
|
||||
$deferred = new Deferred;
|
||||
$this->stat($path)->when(function ($error, $result) use ($deferred) {
|
||||
$this->stat($path)->onResolve(function ($error, $result) use ($deferred) {
|
||||
if (empty($result)) {
|
||||
$deferred->fail(new FilesystemException(
|
||||
"Specified path does not exist"
|
||||
@ -199,7 +199,7 @@ class UvDriver implements Driver {
|
||||
*/
|
||||
public function mtime(string $path): Promise {
|
||||
$deferred = new Deferred;
|
||||
$this->stat($path)->when(function ($error, $result) use ($deferred) {
|
||||
$this->stat($path)->onResolve(function ($error, $result) use ($deferred) {
|
||||
if ($result) {
|
||||
$deferred->resolve($result["mtime"]);
|
||||
} else {
|
||||
@ -217,7 +217,7 @@ class UvDriver implements Driver {
|
||||
*/
|
||||
public function atime(string $path): Promise {
|
||||
$deferred = new Deferred;
|
||||
$this->stat($path)->when(function ($error, $result) use ($deferred) {
|
||||
$this->stat($path)->onResolve(function ($error, $result) use ($deferred) {
|
||||
if ($result) {
|
||||
$deferred->resolve($result["atime"]);
|
||||
} else {
|
||||
@ -235,7 +235,7 @@ class UvDriver implements Driver {
|
||||
*/
|
||||
public function ctime(string $path): Promise {
|
||||
$deferred = new Deferred;
|
||||
$this->stat($path)->when(function ($error, $result) use ($deferred) {
|
||||
$this->stat($path)->onResolve(function ($error, $result) use ($deferred) {
|
||||
if ($result) {
|
||||
$deferred->resolve($result["ctime"]);
|
||||
} else {
|
||||
@ -360,7 +360,7 @@ class UvDriver implements Driver {
|
||||
$deferred->resolve((bool) $fh);
|
||||
});
|
||||
} else {
|
||||
$this->isdir($tmpPath)->when(function ($error, $result) use (
|
||||
$this->isdir($tmpPath)->onResolve(function ($error, $result) use (
|
||||
$callback, $tmpPath, $mode
|
||||
) {
|
||||
if ($result) {
|
||||
|
Loading…
Reference in New Issue
Block a user