public function recursiveCompress():bool
    {
        if ($this->source == null) {
            throw new Server500(new \ArrayObject(array("explain" => "The source must be not null.",
                "Please add source path.")));
        }
        if ($this->name == null) {
            throw new Server500(new \ArrayObject(array("explain" => "The archive name must be not null.",
                "Please add an archive name.")));
        }

        $source = str_replace('\\', '/', realpath($this->source));
        if (is_dir($source) === true) {
            $files = new \RecursiveIteratorIterator(
                new \RecursiveDirectoryIterator($source),
                \RecursiveIteratorIterator::SELF_FIRST
            );
            foreach ($files as $file) {
                $file = str_replace('\\', '/', $file);
                if (in_array(substr($file, strrpos($file, '/') + 1), array('.', '..'))) {
                    continue;
                }
                $file = realpath($file);
                if (is_dir($file) === true) {
                    $this->addEmptyDir(str_replace($source . '/', '', $file . '/'));
                } elseif (is_file($file) === true) {
                    $this->addFromString(str_replace(
                        $source . '/',
                        '',
                        $file
                    ), file_get_contents($file));
                }
            }
        } elseif (is_file($source) === true) {
            $this->addFromString(basename($source), file_get_contents($source));
        }
        return (true);
    }
public function recursiveCompress():bool
    {
        if ($this->source == null) {
            throw new Server500(new \ArrayObject(array("explain" => "The source must be not null.",
                "Please add source path.")));
        }
        if ($this->name == null) {
            throw new Server500(new \ArrayObject(array("explain" => "The archive name must be not null.",
                "Please add an archive name.")));
        }

        $source = str_replace('\\', '/', realpath($this->source));
        if (is_dir($source) === true) {
            $files = new \RecursiveIteratorIterator(
                new \RecursiveDirectoryIterator($source),
                \RecursiveIteratorIterator::SELF_FIRST
            );
            foreach ($files as $file) {
                $file = str_replace('\\', '/', $file);
                if (in_array(substr($file, strrpos($file, '/') + 1), array('.', '..'))) {
                    continue;
                }
                $file = realpath($file);
                if (is_dir($file) === true) {
                    $this->addEmptyDir(str_replace($source . '/', '', $file . '/'));
                } elseif (is_file($file) === true) {
                    $this->addFromString(str_replace(
                        $source . '/',
                        '',
                        $file
                    ), file_get_contents($file));
                }
            }
        } elseif (is_file($source) === true) {
            $this->addFromString(basename($source), file_get_contents($source));
        }
        return (true);
    }
public function recursiveCompress ( ) : bool { if ( $ this -> source == null ) { throw new Server500 ( new \ ArrayObject ( array ( "explain" => "The source must be not null." , "Please add source path." ) ) ) ; } if ( $ this -> name == null ) { throw new Server500 ( new \ ArrayObject ( array ( "explain" => "The archive name must be not null." , "Please add an archive name." ) ) ) ; } $ source = str_replace ( '\\' , '/' , realpath ( $ this -> source ) ) ; if ( is_dir ( $ source ) === true ) { $ files = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ source ) , \ RecursiveIteratorIterator :: SELF_FIRST ) ; foreach ( $ files as $ file ) { $ file = str_replace ( '\\' , '/' , $ file ) ; if ( in_array ( substr ( $ file , strrpos ( $ file , '/' ) + 1 ) , array ( '.' , '..' ) ) ) { continue ; } $ file = realpath ( $ file ) ; if ( is_dir ( $ file ) === true ) { $ this -> addEmptyDir ( str_replace ( $ source . '/' , '' , $ file . '/' ) ) ; } elseif ( is_file ( $ file ) === true ) { $ this -> addFromString ( str_replace ( $ source . '/' , '' , $ file ) , file_get_contents ( $ file ) ) ; } } } elseif ( is_file ( $ source ) === true ) { $ this -> addFromString ( basename ( $ source ) , file_get_contents ( $ source ) ) ; } return ( true ) ; }
Compress source dir to zip
@return bool If archive is compressed
@throws Server500
Compress source dir to zip