diff --git a/inc/functions/fs.php b/inc/functions/fs.php index 2d38c384..37901bf0 100644 --- a/inc/functions/fs.php +++ b/inc/functions/fs.php @@ -15,3 +15,17 @@ function move_or_copy_uploaded(string $from, string $to) { } return true; } + +/** + * Concats two paths accounting for directory separators. + */ +function concat_path(string $base, string $other): string { + if ($base[\strlen($base) - 1] === DIRECTORY_SEPARATOR) { + $base = \substr($base, 0, \strlen($base) - 1); + } + if ($other[0] === DIRECTORY_SEPARATOR) { + return $base . $other; + } else { + return $base . DIRECTORY_SEPARATOR . $other; + } +}