Add stricter wrapper around unlink()
This commit is contained in:
parent
d28c245a1a
commit
298e2238a8
20
MD_STD.php
20
MD_STD.php
|
@ -62,7 +62,7 @@ final class MD_STD {
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function mkdir(string $pathname, int $mode = 0775, bool $recursive = false) {
|
public static function mkdir(string $pathname, int $mode = 0775, bool $recursive = false):void {
|
||||||
|
|
||||||
if (\mkdir($pathname, $mode, $recursive) === false) {
|
if (\mkdir($pathname, $mode, $recursive) === false) {
|
||||||
throw new Exception("Failed to create directory: $pathname");
|
throw new Exception("Failed to create directory: $pathname");
|
||||||
|
@ -70,6 +70,24 @@ final class MD_STD {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper around unlink, that throws an exception if the file failed to be
|
||||||
|
* removed.
|
||||||
|
*
|
||||||
|
* @see https://www.php.net/manual/en/function.unlink.php
|
||||||
|
*
|
||||||
|
* @param string $filename File path.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function unlink(string $filename):void {
|
||||||
|
|
||||||
|
if (\unlink($filename) === false) {
|
||||||
|
throw new Exception("Failed to delete: $filename");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets contents of a folder.
|
* Gets contents of a folder.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user