Add function unlink_if_exists
This commit is contained in:
parent
23232f4e6a
commit
66a5b77b51
|
@ -94,6 +94,25 @@ final class MD_STD {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper around unlink, that explicitly deletes files when existent, but
|
||||
* accepts if they don't. An error is thrown if the files could not be
|
||||
* deleted for other reasons.
|
||||
*
|
||||
* @see https://www.php.net/manual/en/function.unlink.php
|
||||
*
|
||||
* @param non-empty-string $filename File path.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function unlink_if_exists(string $filename):void {
|
||||
|
||||
if (!\file_exists($filename)) return;
|
||||
|
||||
self::unlink($filename);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets contents of a folder.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue
Block a user