Skip to content

Commit c598606

Browse files
authored
Merge pull request #11 from pozitronik/master
Added $include_hidden parameter to getAll(), dirSize(), count()
2 parents 7e9fcc6 + e55e8d9 commit c598606

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

FtpClient.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,13 @@ public function connect($host, $ssl = false, $port = 21, $timeout = 90)
160160
* @param string $source_directory
161161
* @param string $target_directory
162162
* @param int $mode
163+
* @param bool $include_hidden
163164
*
164165
* @return FtpClient
165166
*/
166-
public function getAll($source_directory, $target_directory, $mode = FTP_BINARY)
167+
public function getAll($source_directory, $target_directory, $mode = FTP_BINARY, $include_hidden = false)
167168
{
168-
$d = $this->scanDir($source_directory);
169+
$d = $this->scanDir($source_directory, false, $include_hidden);
169170

170171
// do this for each file in the directory
171172
foreach ($d as $file) {
@@ -175,7 +176,7 @@ public function getAll($source_directory, $target_directory, $mode = FTP_BINARY)
175176
if (!is_dir($new_target_directory)) {
176177
mkdir($new_target_directory);
177178
}
178-
$this->getAll($new_source_directory, $new_target_directory);
179+
$this->getAll($new_source_directory, $new_target_directory, $mode, $include_hidden);
179180
} else {
180181
$this->get($new_target_directory, $new_source_directory, $mode);
181182
}
@@ -509,12 +510,13 @@ public function scanDir($directory = '.', $recursive = false, $includeHidden = f
509510
*
510511
* @param string $directory The directory, by default is the current directory
511512
* @param bool $recursive true by default
513+
* @param bool $include_hidden false by default
512514
*
513515
* @return int The size in bytes
514516
*/
515-
public function dirSize($directory = '.', $recursive = true)
517+
public function dirSize($directory = '.', $recursive = true, $include_hidden = false)
516518
{
517-
$items = $this->scanDir($directory, $recursive);
519+
$items = $this->scanDir($directory, $recursive, $include_hidden);
518520
$size = 0;
519521
foreach ($items as $item) {
520522
$size += (int)$item['size'];
@@ -529,14 +531,15 @@ public function dirSize($directory = '.', $recursive = true)
529531
* @param string $directory The directory, by default is the current directory
530532
* @param string|null $type The type of item to count (file, directory, link, unknown)
531533
* @param bool $recursive true by default
534+
* @param bool $include_hidden
532535
*
533536
* @return int
534537
*/
535-
public function count($directory = '.', $type = null, $recursive = true)
538+
public function count($directory = '.', $type = null, $recursive = true, $include_hidden = false)
536539
{
537540
$items = (($type === null)
538541
? $this->nlist($directory, $recursive)
539-
: $this->scanDir($directory, $recursive));
542+
: $this->scanDir($directory, $recursive, $include_hidden));
540543

541544
$count = 0;
542545
foreach ($items as $item) {

0 commit comments

Comments
 (0)