[HttpKernel] added Filesystem::isAbsolutePath()

This commit is contained in:
Fabien Potencier 2011-05-31 11:04:23 +02:00
parent 65200aa86a
commit f70c7e7c1c

View File

@ -208,6 +208,27 @@ class Filesystem
}
}
/**
* Returns whether the file path is an absolute path.
*
* @param string $file A file path
*
* @return Boolean
*/
public function isAbsolutePath($file)
{
if ($file[0] == '/' || $file[0] == '\\'
|| (strlen($file) > 3 && ctype_alpha($file[0])
&& $file[1] == ':'
&& ($file[2] == '\\' || $file[2] == '/')
)
) {
return true;
}
return false;
}
private function toIterator($files)
{
if (!$files instanceof \Traversable) {