Updated makeAbsoluteUrl to handle already absolute paths

This commit is contained in:
2011-06-26 18:12:50 +01:00
parent 4604a57434
commit 05464cb189

View File

@@ -237,7 +237,18 @@ class SihnonFramework_Main {
}
}
/**
* Returns the canonical form of the given path, made absolute if relative
*
* @param string $relative_path
* @return string
*/
public static function makeAbsolutePath($relative_path) {
if (preg_match('#^/#', $relative_path)) {
// This path is already absolute, just canonicalise it
return realpath($relative_path);
}
$absolute_path = getcwd() . DIRECTORY_SEPARATOR . $relative_path;
return realpath($absolute_path);
}