From 01968efa6f61ba6027fdca701ffa5300ef067586 Mon Sep 17 00:00:00 2001 From: jakoch Date: Wed, 30 Apr 2014 11:52:31 +0200 Subject: [PATCH] renamed listFiles() to getFolderContent(). fixed comment: the method doesn't return a "list of files in a directory, including dotfiles", it returns a "list of files and folders, excluding dotfiles". switched from !is_file() to is_dir() check. --- src/Composer/Downloader/ArchiveDownloader.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Composer/Downloader/ArchiveDownloader.php b/src/Composer/Downloader/ArchiveDownloader.php index bfe174fb7..bea491a02 100644 --- a/src/Composer/Downloader/ArchiveDownloader.php +++ b/src/Composer/Downloader/ArchiveDownloader.php @@ -49,12 +49,11 @@ abstract class ArchiveDownloader extends FileDownloader unlink($fileName); - // get file list - $contentDir = $this->listFiles($temporaryDir); + $contentDir = $this->getFolderContent($temporaryDir); // only one dir in the archive, extract its contents out of it - if (1 === count($contentDir) && !is_file($contentDir[0])) { - $contentDir = $this->listFiles($contentDir[0]); + if (1 === count($contentDir) && is_dir($contentDir[0])) { + $contentDir = $this->getFolderContent($contentDir[0]); } // move files back out of the temp dir @@ -128,9 +127,11 @@ abstract class ArchiveDownloader extends FileDownloader abstract protected function extract($file, $path); /** - * Returns the list of files in a directory including dotfiles + * Returns the folder content, excluding dotfiles + * + * @param string $dir Directory */ - private function listFiles($dir) + private function getFolderContent($dir) { $files = array_merge(glob($dir . '/.*') ?: array(), glob($dir . '/*') ?: array());