From 7923f40dd79de89937339785d77a36b3c8df2372 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Wed, 3 Aug 2016 08:16:13 +0000 Subject: [PATCH] file : add scandirNotSorted function git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2984 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- file.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/file.php b/file.php index e57960a..3b14462 100644 --- a/file.php +++ b/file.php @@ -405,6 +405,23 @@ class file return $res; } + /** Return the list of files and directories in the directory. + * Do not return the . and .. virtual dirs. + * The result is NOT sorted + * @param string $directory The directory to read + * @return array the list of files and dirs + * @throws If directory not exists, or is not executable + */ + public function scandirNotSorted ($directory) + { + $this->debug (2, "scandirNotSorted ($directory)"); + $directory = $this->realpath ($directory); + $this->checkPathRO ($directory); + $res = array_values (array_diff (scandir ($directory, SCANDIR_SORT_NONE), + array('..', '.'))); + return $res; + } + /** Create a new file or update the timestamp if the file exists * @param string $filename the filename * @param int $time the timestamp to use (actual timestamp if not defined)