forked from leftypol/leftypol
fs.php: add concat_path
This commit is contained in:
parent
592cf2e41d
commit
d04282d92d
1 changed files with 14 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue