CFileHelper::findFiles()

Hi,

I need a function that can entirely remove a directory content (all subdirectories and files)

I think CFileHelper::findFolders() is missing

And why not a CFileHelper::emptyDir(); (to quickly empty a directory content) (for an easy removal of uploaded files)

yeah in my opinion it’s a good and helpful feature.

Here is a nice function i found for emptying a directory :




    public function emptyDir($dir,$DeleteMe=false) {

        if(!$dh=@opendir($dir)) 

            return;

        while(false!==($obj=readdir($dh)))

        {

            if($obj=='.'||$obj=='..') 

                continue;

            if(!@unlink($dir.'/'.$obj)) 

                $this->emptyDir($dir.'/'.$obj,true);

        }

        closedir($dh);

        if($DeleteMe)

        {

            @rmdir($dir);

        }

    }



It works well

Also a new option for findFiles() is needed.

Return or not, the full path to the files to avoid results like this :




Array

(

    [0] => /var/www/protected/../images/originals/0se01wrb3q.jpg

    [1] => /var/www/protected/../images/originals/16cifp07v5.jpg

    [2] => /var/www/protected/../images/originals/1qwhxyni22.jpg

    [3] => /var/www/protected/../images/originals/1vwcjwyzbp.jpg

    [4] => /var/www/protected/../images/originals/1xqtioxrxh.jpg

    [5] => /var/www/protected/../images/originals/2c5ffdlzkv.jpg

    [6] => /var/www/protected/../images/originals/2hq60vu5j9.jpg

    [7] => /var/www/protected/../images/originals/2zcxwzvxvs.jpg

    [8] => /var/www/protected/../images/originals/4afd78c2ub.jpg

    [9] => /var/www/protected/../images/originals/4pu0gm1aj8.png

    [10] => /var/www/protected/../images/originals/6jxgd941hd.jpg

);