diff --git a/src/Service/Utility/PathUtility.php b/src/Service/Utility/PathUtility.php index 46584d8..a0f1bc0 100644 --- a/src/Service/Utility/PathUtility.php +++ b/src/Service/Utility/PathUtility.php @@ -30,4 +30,28 @@ public static function addLeadingSlash(string $path) { return DIRECTORY_SEPARATOR . $path; } + + /** + * @param string $path + * @param int $mode + * @param bool $recursive + * @return bool + */ + public static function ensurePath(string $path, int $mode = 0777, bool $recursive = true) + { + if (!is_dir($path)) { + return mkdir($path, $mode, $recursive); + } + + return true; + } + + /** + * @param string $file + * @return false|string + */ + public static function getPathFromFile(string $file) + { + return StringUtility::removeFromEnd(DIRECTORY_SEPARATOR, $file, true); + } }