public static function getRelative($filePath, $rootPath = null, $forceDS = DIRECTORY_SEPARATOR, $toRealpath = true)
{
// Cleanup file path
if ($toRealpath && !self::isReal($filePath)) {
$filePath = self::real($filePath);
}
$filePath = self::clean($filePath, $forceDS);
// Cleanup root path
$rootPath = $rootPath ?: Sys::getDocRoot();
if ($toRealpath && !self::isReal($rootPath)) {
$rootPath = self::real($rootPath);
}
$rootPath = self::clean($rootPath, $forceDS);
// Remove root part
$relPath = preg_replace('#^' . preg_quote($rootPath) . '#i', '', $filePath);
$relPath = ltrim($relPath, $forceDS);
return $relPath;
}