From e55e8d93c7983d5e1b6cd1933a8c9fe2435561d5 Mon Sep 17 00:00:00 2001 From: Pavel Dubrovsky Date: Wed, 26 Apr 2017 15:02:02 +0300 Subject: [PATCH] Added $include_hidden parameter to getAll(), dirSize(), count() functions. --- FtpClient.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/FtpClient.php b/FtpClient.php index 323ec23..0ef468a 100644 --- a/FtpClient.php +++ b/FtpClient.php @@ -160,12 +160,13 @@ public function connect($host, $ssl = false, $port = 21, $timeout = 90) * @param string $source_directory * @param string $target_directory * @param int $mode + * @param bool $include_hidden * * @return FtpClient */ - public function getAll($source_directory, $target_directory, $mode = FTP_BINARY) + public function getAll($source_directory, $target_directory, $mode = FTP_BINARY, $include_hidden = false) { - $d = $this->scanDir($source_directory); + $d = $this->scanDir($source_directory, false, $include_hidden); // do this for each file in the directory foreach ($d as $file) { @@ -175,7 +176,7 @@ public function getAll($source_directory, $target_directory, $mode = FTP_BINARY) if (!is_dir($new_target_directory)) { mkdir($new_target_directory); } - $this->getAll($new_source_directory, $new_target_directory); + $this->getAll($new_source_directory, $new_target_directory, $mode, $include_hidden); } else { $this->get($new_target_directory, $new_source_directory, $mode); } @@ -509,12 +510,13 @@ public function scanDir($directory = '.', $recursive = false, $include_hidden = * * @param string $directory The directory, by default is the current directory * @param bool $recursive true by default + * @param bool $include_hidden false by default * * @return int The size in bytes */ - public function dirSize($directory = '.', $recursive = true) + public function dirSize($directory = '.', $recursive = true, $include_hidden = false) { - $items = $this->scanDir($directory, $recursive); + $items = $this->scanDir($directory, $recursive, $include_hidden); $size = 0; foreach ($items as $item) { $size += (int)$item['size']; @@ -529,14 +531,15 @@ public function dirSize($directory = '.', $recursive = true) * @param string $directory The directory, by default is the current directory * @param string|null $type The type of item to count (file, directory, link, unknown) * @param bool $recursive true by default + * @param bool $include_hidden * * @return int */ - public function count($directory = '.', $type = null, $recursive = true) + public function count($directory = '.', $type = null, $recursive = true, $include_hidden = false) { $items = (($type === null) ? $this->nlist($directory, $recursive) - : $this->scanDir($directory, $recursive)); + : $this->scanDir($directory, $recursive, $include_hidden)); $count = 0; foreach ($items as $item) {