fs.php: add concat_path

This commit is contained in:
Zankaria 2025-03-26 00:07:41 +01:00
parent 592cf2e41d
commit d04282d92d

View file

@ -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;
}
}