/**
  * @BeforeSuite
  */
 public static function testdir($event)
 {
     $testdir = "test_output";
     rmr($testdir);
     mkdir($testdir);
     chdir($testdir);
 }
Пример #2
0
 function rmr($dir)
 {
     if (is_dir($dir)) {
         $dircontent = scandir($dir);
         foreach ($dircontent as $c) {
             if ($c != '.' and $c != '..' and is_dir($dir . '/' . $c)) {
                 rmr($dir . '/' . $c);
             } else {
                 if ($c != '.' and $c != '..') {
                     unlink($dir . '/' . $c);
                 }
             }
         }
         rmdir($dir);
     } else {
         @unlink($dir);
     }
 }
Пример #3
0
/**
 * Removes all files in a directory recursively
 * and removes also the directory itself.
 *
 * @param string $dir the directory to remove recursively.
 */
function rmr($dir)
{
    if (is_dir($dir)) {
        $dircontent = scandir($dir);
        foreach ($dircontent as $c) {
            if ($c != '.' && $c != '..' && is_dir($dir . DIRECTORY_SEPARATOR . $c)) {
                rmr($dir . DIRECTORY_SEPARATOR . $c);
            } else {
                if ($c != '.' && $c != '..') {
                    unlink($dir . DIRECTORY_SEPARATOR . $c);
                }
            }
        }
        rmdir($dir);
    } else {
        if (file_exists($dir)) {
            unlink($dir);
        }
    }
}
function rmr($dir)
{
	if(!is_dir($dir)) {
		unlink($dir);
		return;
	}
	
	$dh=opendir($dir);
	
	while($file=readdir($dh))
	{
    	if($file != "." && $file != "..")
    	{
      		rmr($dir."/".$file);
    	}
  	}
  	closedir($dh);
  	rmdir($dir);
  	return;
}