mirror of
https://github.com/danog/file.git
synced 2024-11-30 04:19:39 +01:00
Merge branch 'master' of https://github.com/danog/file
This commit is contained in:
commit
388199d955
@ -94,9 +94,12 @@ class BlockingDriver implements Driver
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (($size = @\filesize($path)) === false) {
|
if (($size = @\filesize($path)) === false) {
|
||||||
return new Failure(new FilesystemException(
|
$message = 'Could not open the file.';
|
||||||
\error_get_last()["message"]
|
if ($error = \error_get_last()) {
|
||||||
));
|
$message .= \sprintf(" Errno: %d; %s", $error["type"], $error["message"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Failure(new FilesystemException($message));
|
||||||
}
|
}
|
||||||
|
|
||||||
\clearstatcache(true, $path);
|
\clearstatcache(true, $path);
|
||||||
@ -328,15 +331,21 @@ class BlockingDriver implements Driver
|
|||||||
public function chown(string $path, int $uid, int $gid): Promise
|
public function chown(string $path, int $uid, int $gid): Promise
|
||||||
{
|
{
|
||||||
if ($uid !== -1 && !@\chown($path, $uid)) {
|
if ($uid !== -1 && !@\chown($path, $uid)) {
|
||||||
return new Failure(new FilesystemException(
|
$message = 'Could not open the file.';
|
||||||
\error_get_last()["message"]
|
if ($error = \error_get_last()) {
|
||||||
));
|
$message .= \sprintf(" Errno: %d; %s", $error["type"], $error["message"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Failure(new FilesystemException($message));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($gid !== -1 && !@\chgrp($path, $gid)) {
|
if ($gid !== -1 && !@\chgrp($path, $gid)) {
|
||||||
return new Failure(new FilesystemException(
|
$message = 'Could not open the file.';
|
||||||
\error_get_last()["message"]
|
if ($error = \error_get_last()) {
|
||||||
));
|
$message .= \sprintf(" Errno: %d; %s", $error["type"], $error["message"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Failure(new FilesystemException($message));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Success;
|
return new Success;
|
||||||
@ -358,9 +367,14 @@ class BlockingDriver implements Driver
|
|||||||
public function get(string $path): Promise
|
public function get(string $path): Promise
|
||||||
{
|
{
|
||||||
$result = @\file_get_contents($path);
|
$result = @\file_get_contents($path);
|
||||||
return ($result === false)
|
if ($result === false) {
|
||||||
? new Failure(new FilesystemException(\error_get_last()["message"]))
|
$message = 'Could not open the file.';
|
||||||
: new Success($result);
|
if ($error = \error_get_last()) {
|
||||||
|
$message .= \sprintf(" Errno: %d; %s", $error["type"], $error["message"]);
|
||||||
|
}
|
||||||
|
return new Failure(new FilesystemException($message));
|
||||||
|
}
|
||||||
|
return new Success($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -369,8 +383,13 @@ class BlockingDriver implements Driver
|
|||||||
public function put(string $path, string $contents): Promise
|
public function put(string $path, string $contents): Promise
|
||||||
{
|
{
|
||||||
$result = @\file_put_contents($path, $contents);
|
$result = @\file_put_contents($path, $contents);
|
||||||
return ($result === false)
|
if ($result === false) {
|
||||||
? new Failure(new FilesystemException(\error_get_last()["message"]))
|
$message = 'Could not open the file.';
|
||||||
: new Success($result);
|
if ($error = \error_get_last()) {
|
||||||
|
$message .= \sprintf(" Errno: %d; %s", $error["type"], $error["message"]);
|
||||||
|
}
|
||||||
|
return new Failure(new FilesystemException($message));
|
||||||
|
}
|
||||||
|
return new Success($result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user