3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
15 * The 'file:...' scheme is loosely defined in RFC-1738
17 class File
extends Uri
19 protected static $validSchemes = array('file');
22 * Check if the URI is a valid File URI
24 * This applies additional specific validation rules beyond the ones
25 * required by the generic URI syntax.
30 public function isValid()
36 return parent
::isValid();
40 * User Info part is not used in file URIs
42 * @see Uri::setUserInfo()
43 * @param string $userInfo
46 public function setUserInfo($userInfo)
52 * Fragment part is not used in file URIs
54 * @see Uri::setFragment()
55 * @param string $fragment
58 public function setFragment($fragment)
64 * Convert a UNIX file path to a valid file:// URL
69 public static function fromUnixPath($path)
71 $url = new static('file:');
72 if (substr($path, 0, 1) == '/') {
81 * Convert a Windows file path to a valid file:// URL
86 public static function fromWindowsPath($path)
88 $url = new static('file:');
90 // Convert directory separators
91 $path = str_replace(array('/', '\\'), array('%2F', '/'), $path);
93 // Is this an absolute path?
94 if (preg_match('|^([a-zA-Z]:)?/|', $path)) {