3 * @see https://github.com/zendframework/zend-uri for the canonical source repository
4 * @copyright Copyright (c) 2005-2018 Zend Technologies USA Inc. (https://www.zend.com)
5 * @license https://github.com/zendframework/zend-uri/blob/master/LICENSE.md New BSD License
13 * The 'file:...' scheme is loosely defined in RFC-1738
15 class File
extends Uri
17 protected static $validSchemes = ['file'];
20 * Check if the URI is a valid File URI
22 * This applies additional specific validation rules beyond the ones
23 * required by the generic URI syntax.
28 public function isValid()
34 return parent
::isValid();
38 * User Info part is not used in file URIs
40 * @see Uri::setUserInfo()
41 * @param string $userInfo
44 public function setUserInfo($userInfo)
50 * Fragment part is not used in file URIs
52 * @see Uri::setFragment()
53 * @param string $fragment
56 public function setFragment($fragment)
62 * Convert a UNIX file path to a valid file:// URL
67 public static function fromUnixPath($path)
69 $url = new static('file:');
70 if (substr($path, 0, 1) == '/') {
79 * Convert a Windows file path to a valid file:// URL
84 public static function fromWindowsPath($path)
86 $url = new static('file:');
88 // Convert directory separators
89 $path = str_replace(['/', '\\'], ['%2F', '/'], $path);
91 // Is this an absolute path?
92 if (preg_match('|^([a-zA-Z]:)?/|', $path)) {