Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Uri / File.php
blobc67907ea5495c74a114da82675c393f0aa846908
1 <?php
2 /**
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
8 */
10 namespace Zend\Uri;
12 /**
13 * File URI handler
15 * The 'file:...' scheme is loosely defined in RFC-1738
17 class File extends Uri
19 protected static $validSchemes = array('file');
21 /**
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.
27 * @return bool
28 * @see Uri::isValid()
30 public function isValid()
32 if ($this->query) {
33 return false;
36 return parent::isValid();
39 /**
40 * User Info part is not used in file URIs
42 * @see Uri::setUserInfo()
43 * @param string $userInfo
44 * @return File
46 public function setUserInfo($userInfo)
48 return $this;
51 /**
52 * Fragment part is not used in file URIs
54 * @see Uri::setFragment()
55 * @param string $fragment
56 * @return File
58 public function setFragment($fragment)
60 return $this;
63 /**
64 * Convert a UNIX file path to a valid file:// URL
66 * @param string $path
67 * @return File
69 public static function fromUnixPath($path)
71 $url = new static('file:');
72 if (substr($path, 0, 1) == '/') {
73 $url->setHost('');
76 $url->setPath($path);
77 return $url;
80 /**
81 * Convert a Windows file path to a valid file:// URL
83 * @param string $path
84 * @return File
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)) {
95 $url->setHost('');
98 $url->setPath($path);
99 return $url;