Browse Source

Merge pull request #244 from muja/scandir

Use scandir instead of opendir to ensure alphabetical order.
Tyler Heshka 10 năm trước cách đây
mục cha
commit
2fdcacc14b
1 tập tin đã thay đổi với 2 bổ sung3 xóa
  1. 2 3
      lib/pico.php

+ 2 - 3
lib/pico.php

@@ -363,8 +363,8 @@ class Pico
     protected function get_files($directory, $ext = '')
     {
         $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('~', '#'))) {
                     continue;
                 }
@@ -379,7 +379,6 @@ class Pico
                     }
                 }
             }
-            closedir($handle);
         }
 
         return $array_items;