Skip to content

Commit

Permalink
Merge pull request #11 from pozitronik/master
Browse files Browse the repository at this point in the history
Added $include_hidden parameter to getAll(), dirSize(), count()
  • Loading branch information
morontt authored Apr 26, 2017
2 parents 7e9fcc6 + e55e8d9 commit c598606
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions FtpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}
Expand Down Expand Up @@ -509,12 +510,13 @@ public function scanDir($directory = '.', $recursive = false, $includeHidden = f
*
* @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'];
Expand All @@ -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) {
Expand Down

0 comments on commit c598606

Please sign in to comment.