// ========== doDelDir函数 START ==========
function doDelDir($dir)
{
$dh=opendir($dir);
while ($file=readdir($dh))
{
if($file!="." && $file!="..")
{
$fullpath=$dir."/".$file;
if(!is_dir($fullpath))
{
unlink($fullpath);
}
else
{
$this->doDelDir($fullpath);
}
}
}
closedir($dh);
if (rmdir($dir))
{
return true;
}
else
{
return false;
}
}
// ========== doDelDir函数 END ==========
// ========== doMoveDir函数 START ==========
function doMoveDir($source,$target)
{
if(is_dir($source))
{
$dest_name=basename($source);
if(!mkdir($target.$dest_name))
{
return false;
}
$d=dir($source);
while(($entry=$d->read())!==false)
{
if(is_dir($source.$entry))
{
if($entry=="."||$entry=="..")
{
continue;
}
else
{
$this->doMoveDir("$source$entry\\","$target$dest_name\\");
}
}
else
{
if(!copy("$source$entry","$target$dest_name\\$entry"))
{
return false;
}
}
}
}
else
{
if(!copy("$source$entry","$target$dest_name\\"))
{
return false;
}
}
return true;
}
// ========== doMoveDir函数 END ==========