Pārlūkot izejas kodu

Merge pull request #244 from muja/scandir

Use scandir instead of opendir to ensure alphabetical order.
Tyler Heshka 10 gadi atpakaļ
vecāks
revīzija
2fdcacc14b
1 mainītis faili ar 2 papildinājumiem un 3 dzēšanām
  1. 2 3
      lib/pico.php

+ 2 - 3
lib/pico.php

@@ -363,8 +363,8 @@ class Pico
     protected function get_files($directory, $ext = '')
     protected function get_files($directory, $ext = '')
     {
     {
         $array_items = array();
         $array_items = array();
-        if ($handle = opendir($directory)) {
-            while (false !== ($file = readdir($handle))) {
+        if ($files = scandir($directory)) {
+            foreach ($files as $file) {
                 if (in_array(substr($file, -1), array('~', '#'))) {
                 if (in_array(substr($file, -1), array('~', '#'))) {
                     continue;
                     continue;
                 }
                 }
@@ -379,7 +379,6 @@ class Pico
                     }
                     }
                 }
                 }
             }
             }
-            closedir($handle);
         }
         }
 
 
         return $array_items;
         return $array_items;