Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/ParallelDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,12 @@ public function size(string $path): Promise
return call(function () use ($path) {
$stat = yield $this->stat($path);
if (empty($stat)) {
throw new FilesystemException("Specified path does not exist");
throw new PathDoesNotExistException($path);
}
if ($stat["mode"] & 0100000) {
return $stat["size"];
}
throw new FilesystemException("Specified path is not a regular file");
throw new FilesystemException(\sprintf('Specified path "%s" is not a regular file', $path));
});
}

Expand All @@ -228,7 +228,7 @@ public function mtime(string $path): Promise
return call(function () use ($path) {
$stat = yield $this->stat($path);
if (empty($stat)) {
throw new FilesystemException("Specified path does not exist");
throw new PathDoesNotExistException($path);
}
return $stat["mtime"];
});
Expand All @@ -242,7 +242,7 @@ public function atime(string $path): Promise
return call(function () use ($path) {
$stat = yield $this->stat($path);
if (empty($stat)) {
throw new FilesystemException("Specified path does not exist");
throw new PathDoesNotExistException($path);
}
return $stat["atime"];
});
Expand All @@ -256,7 +256,7 @@ public function ctime(string $path): Promise
return call(function () use ($path) {
$stat = yield $this->stat($path);
if (empty($stat)) {
throw new FilesystemException("Specified path does not exist");
throw new PathDoesNotExistException($path);
}
return $stat["ctime"];
});
Expand Down
19 changes: 19 additions & 0 deletions src/PathDoesNotExistException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Amp\File;

class PathDoesNotExistException extends FilesystemException
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe FileNotFoundException?

{
private $path;

public function __construct(string $path)
{
$this->path = $path;
parent::__construct(\sprintf('Specified path "%s" does not exist', $path));
}

public function getPath(): string
{
return $this->path;
}
}