diff --git a/MD_STD.php b/MD_STD.php index eeeba8a..77a14dd 100644 --- a/MD_STD.php +++ b/MD_STD.php @@ -34,6 +34,22 @@ class MD_STD { } + /** + * Returns the real path of a relative file path. Throws an error rather than + * returning the default false. + * + * @param string $path File path to convert. + * + * @return string + */ + public static function realpath(string $path):string { + + $output = realpath($path); + if (!is_string($output)) throw new MDFileDoesNotExist("The file {$path} does not exist or is not readable."); + return $output; + + } + /** * Gets contents of a folder. *