Forráskód Böngészése

[HttpKernel] added Filesystem::isAbsolutePath()

Fabien Potencier 14 éve
szülő
commit
f70c7e7c1c
1 módosított fájl, 21 hozzáadás és 0 törlés
  1. 21 0
      src/Symfony/Component/HttpKernel/Util/Filesystem.php

+ 21 - 0
src/Symfony/Component/HttpKernel/Util/Filesystem.php

@@ -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) {