- put all functions into a class LetoDMS_File

This commit is contained in:
steinm 2010-11-25 21:11:03 +00:00
parent ba8acee05a
commit 7b7d0cc954

View File

@ -18,35 +18,30 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
function renameFile($old, $new)
{
class LetoDMS_File {
function renameFile($old, $new) {
return @rename($old, $new);
}
}
function removeFile($file)
{
function removeFile($file) {
return @unlink($file);
}
}
function copyFile($source, $target)
{
function copyFile($source, $target) {
return @copy($source, $target);
}
}
function moveFile($source, $target)
{
function moveFile($source, $target) {
if (!@copyFile($source, $target))
return false;
return @removeFile($source);
}
}
function renameDir($old, $new)
{
function renameDir($old, $new) {
return @rename($old, $new);
}
}
function makeDir($path)
{
function makeDir($path) {
/*
if (strncmp($path, DIRECTORY_SEPARATOR, 1) == 0) {
$mkfolder = DIRECTORY_SEPARATOR;
@ -92,10 +87,9 @@ function makeDir($path)
return true;
}
}
function removeDir($path)
{
function removeDir($path) {
$handle = @opendir($path);
while ($entry = @readdir($handle) )
{
@ -114,24 +108,18 @@ function removeDir($path)
}
@closedir($handle);
return @rmdir($path);
}
}
function copyDir($sourcePath, $targetPath)
{
if (mkdir($targetPath, 0777))
{
function copyDir($sourcePath, $targetPath) {
if (mkdir($targetPath, 0777)) {
$handle = @opendir($sourcePath);
while ($entry = @readdir($handle) )
{
while ($entry = @readdir($handle) ) {
if ($entry == ".." || $entry == ".")
continue;
else if (is_dir($sourcePath . $entry))
{
else if (is_dir($sourcePath . $entry)) {
if (!copyDir($sourcePath . $entry . "/", $targetPath . $entry . "/"))
return false;
}
else
{
} else {
if (!@copy($sourcePath . $entry, $targetPath . $entry))
return false;
}
@ -142,23 +130,21 @@ function copyDir($sourcePath, $targetPath)
return false;
return true;
}
}
function moveDir($sourcePath, $targetPath)
{
function moveDir($sourcePath, $targetPath) {
if (!copyDir($sourcePath, $targetPath))
return false;
return removeDir($sourcePath);
}
}
// code by Kioob (php.net manual)
function gzcompressfile($source,$level=false)
{
// code by Kioob (php.net manual)
function gzcompressfile($source,$level=false) {
$dest=$source.'.gz';
$mode='wb'.$level;
$error=false;
if($fp_out=@gzopen($dest,$mode)){
if($fp_in=@fopen($source,'rb')){
if($fp_out=@gzopen($dest,$mode)) {
if($fp_in=@fopen($source,'rb')) {
while(!feof($fp_in))
@gzwrite($fp_out,fread($fp_in,1024*512));
@fclose($fp_in);
@ -170,6 +156,6 @@ function gzcompressfile($source,$level=false)
if($error) return false;
else return $dest;
}
}
?>