rename之前先删除目的地址

This commit is contained in:
wlx 2011-03-04 14:17:31 +00:00
parent 5109706a67
commit 43e95fb6c1
1 changed files with 13 additions and 0 deletions

View File

@ -27,7 +27,20 @@
$newdir=$data_dir.sprintf('%05d',floor(($duuid2[0]+0.1)/100)*100).'-'.sprintf('%05d',ceil(($duuid2[0]+0.1)/100)*100-1)."/".$duuid2[0]; $newdir=$data_dir.sprintf('%05d',floor(($duuid2[0]+0.1)/100)*100).'-'.sprintf('%05d',ceil(($duuid2[0]+0.1)/100)*100-1)."/".$duuid2[0];
print $dir."\n"; print $dir."\n";
$dir=$backup_dir.trim($duuid2[1]); $dir=$backup_dir.trim($duuid2[1]);
@rrmdir($newdir);
rename($dir,$newdir); rename($dir,$newdir);
} }
} }
function rrmdir($dir) {
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (filetype($dir."/".$object) == "dir") rrmdir($dir."/".$object); else unlink($dir."/".$object);
}
}
reset($objects);
rmdir($dir);
}
}
?> ?>