Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
FileLocator.php
01 <?php
02
03 /*
04 * This file is part of the Symfony package.
05 *
06 * (c) Fabien Potencier <fabien@symfony.com>
07 *
08 * For the full copyright and license information, please view the LICENSE
09 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\Config;
13
14 /**
15 * FileLocator uses an array of pre-defined paths to find files.
16 *
17 * @author Fabien Potencier <fabien@symfony.com>
18 */
19 class FileLocator implements FileLocatorInterface
20 {
21 protected $paths;
22
23 /**
24 * Constructor.
25 *
26 * @param string|array $paths A path or an array of paths where to look for resources
27 */
28 public function __construct($paths = array())
29 {
30 $this->paths = (array) $paths;
31 }
32
33 /**
34 * {@inheritdoc}
35 */
36 public function locate($name, $currentPath = null, $first = true)
37 {
38 if ('' == $name) {
39 throw new \InvalidArgumentException('An empty file name is not valid to be located.');
40 }
41
42 if ($this->isAbsolutePath($name)) {
43 if (!file_exists($name)) {
44 throw new \InvalidArgumentException(sprintf('The file "%s" does not exist.', $name));
45 }
46
47 return $name;
48 }
49
50 $paths = $this->paths;
51
52 if (null !== $currentPath) {
53 array_unshift($paths, $currentPath);
54 }
55
56 $paths = array_unique($paths);
57 $filepaths = array();
58
59 foreach ($paths as $path) {
60 if (@file_exists($file = $path.DIRECTORY_SEPARATOR.$name)) {
61 if (true === $first) {
62 return $file;
63 }
64 $filepaths[] = $file;
65 }
66 }
67
68 if (!$filepaths) {
69 throw new \InvalidArgumentException(sprintf('The file "%s" does not exist (in: %s).', $name, implode(', ', $paths)));
70 }
71
72 return $filepaths;
73 }
74
75 /**
76 * Returns whether the file path is an absolute path.
77 *
78 * @param string $file A file path
79 *
80 * @return bool
81 */
82 private function isAbsolutePath($file)
83 {
84 if ($file[0] === '/' || $file[0] === '\\'
85 || (strlen($file) > 3 && ctype_alpha($file[0])
86 && $file[1] === ':'
87 && ($file[2] === '\\' || $file[2] === '/')
88 )
89 || null !== parse_url($file, PHP_URL_SCHEME)
90 ) {
91 return true;
92 }
93
94 return false;
95 }
96 }
97