Skip to content

Commit c3915fa

Browse files
committed
Added parameter to include hidden files/dirs in scanDir() output
1 parent 6d19225 commit c3915fa

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

FtpClient.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -495,12 +495,13 @@ public function isEmpty($directory)
495495
*
496496
* @param string $directory
497497
* @param bool $recursive
498+
* @param bool $include_hidden
498499
*
499500
* @return array
500501
*/
501-
public function scanDir($directory = '.', $recursive = false)
502+
public function scanDir($directory = '.', $recursive = false, $include_hidden = false)
502503
{
503-
return $this->parseRawList($this->rawlist($directory, $recursive));
504+
return $this->parseRawList($this->rawlist($directory, $recursive, $include_hidden));
504505
}
505506

506507
/**
@@ -638,16 +639,18 @@ public function putAll($source_directory, $target_directory, $mode = FTP_BINARY)
638639
*
639640
* @param string $directory The directory, by default is the current directory
640641
* @param bool $recursive
642+
* @param bool $include_hidden
641643
*
642644
* @return array
643645
*
644646
* @throws FtpException
645647
*/
646-
public function rawlist($directory = '.', $recursive = false)
648+
public function rawlist($directory = '.', $recursive = false, $include_hidden = false)
647649
{
648650
if (!$this->isDir($directory)) {
649651
throw new FtpException('"' . $directory . '" is not a directory.');
650652
}
653+
if ($include_hidden) $directory = "-la $directory";
651654
$list = $this->ftp->rawlist($directory);
652655
$items = [];
653656
if (false == $recursive) {

FtpWrapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* @method string pwd() pwd() Returns the current directory name
3131
* @method bool quit() quit() Closes an FTP connection
3232
* @method array raw() raw(string $command) Sends an arbitrary command to an FTP server
33-
* @method array rawlist() rawlist(string $directory, bool $recursive = false) Returns a detailed list of files in the given directory
33+
* @method array rawlist() rawlist(string $directory, bool $recursive = false, bool $include_hidden = false) Returns a detailed list of files in the given directory
3434
* @method bool rename() rename(string $oldname, string $newname) Renames a file or a directory on the FTP server
3535
* @method bool rmdir() rmdir(string $directory) Removes a directory
3636
* @method bool set_option() set_option(int $option, mixed $value) Set miscellaneous runtime FTP options

0 commit comments

Comments
 (0)