Регистр файлов

This commit is contained in:
origami11 2017-02-16 10:14:36 +03:00
parent 4fd0187ea6
commit c8958cbee0
83 changed files with 25 additions and 53 deletions

41
src/ZipFile.php Normal file
View file

@ -0,0 +1,41 @@
<?php
/**
* Расширение класса ZipArchive с возможность архивирования директории
*/
class ZipFile extends ZipArchive
{
private $ignore = array('.', '..');
public function addIgnore($name)
{
$this->ignore [] = $name;
}
private function addDirDo($location, $name)
{
assert(is_string($location) && is_string($name));
$name .= '/';
$location .= '/';
$file = null;
// Read all Files in Dir
$dir = opendir($location);
while (($file = readdir($dir)) !== false)
{
if (in_array($file, $this->ignore)) continue;
// Rekursiv, If dir: FlxZipArchive::addDir(), else ::File();
$call = (is_dir($location . $file)) ? 'addDir' : 'addFile';
call_user_func(array($this, $call), $location . $file, $name . $file);
}
}
public function addDir($location, $name)
{
assert(is_string($location) && is_string($name));
$this->addEmptyDir($name);
$this->addDirDo($location, $name);
}
}