Yii Framework Forum: CFileHelper::findFiles() - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

CFileHelper::findFiles() Rate Topic: -----

#1 User is offline   saegeek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 245
  • Joined: 09-December 09
  • Location:Montpellier - France

Posted 09 April 2012 - 07:09 AM

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)
And [for] their saying, "Indeed, we have killed the Messiah, Jesus, the son of Mary, the messenger of God ." And they did not kill him, nor did they crucify him; but [another] was made to resemble him to them. And indeed, those who differ over it are in doubt about it. They have no knowledge of it except the following of assumption. And they did not kill him, for certain.Rather, God raised him to Himself.
1

#2 User is offline   naser 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 85
  • Joined: 30-October 09
  • Location:tehran - Iran

Posted 09 April 2012 - 07:17 AM

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

#3 User is offline   saegeek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 245
  • Joined: 09-December 09
  • Location:Montpellier - France

Posted 09 April 2012 - 07:38 AM

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
And [for] their saying, "Indeed, we have killed the Messiah, Jesus, the son of Mary, the messenger of God ." And they did not kill him, nor did they crucify him; but [another] was made to resemble him to them. And indeed, those who differ over it are in doubt about it. They have no knowledge of it except the following of assumption. And they did not kill him, for certain.Rather, God raised him to Himself.
0

#4 User is offline   saegeek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 245
  • Joined: 09-December 09
  • Location:Montpellier - France

Posted 09 April 2012 - 10:05 AM

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
);

And [for] their saying, "Indeed, we have killed the Messiah, Jesus, the son of Mary, the messenger of God ." And they did not kill him, nor did they crucify him; but [another] was made to resemble him to them. And indeed, those who differ over it are in doubt about it. They have no knowledge of it except the following of assumption. And they did not kill him, for certain.Rather, God raised him to Himself.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users