private function archive_pathname($ziparch, $archivepath, $file,
            file_progress $progress = null) {
        // Record progress each time this function is called.
        if ($progress) {
            $progress->progress();
        }

        if (!file_exists($file)) {
            return false;
        }

        if (is_file($file)) {
            if (!is_readable($file)) {
                return false;
            }
            return $ziparch->add_file_from_pathname($archivepath, $file);
        }
        if (is_dir($file)) {
            if ($archivepath !== '') {
                $ziparch->add_directory($archivepath);
            }
            $files = new DirectoryIterator($file);
            foreach ($files as $file) {
                if ($file->isDot()) {
                    continue;
                }
                $newpath = $archivepath.'/'.$file->getFilename();
                $this->archive_pathname($ziparch, $newpath, $file->getPathname(), $progress);
            }
            unset($files); // Release file handles.
            return true;
        }
    }
private function archive_pathname($ziparch, $archivepath, $file,
            file_progress $progress = null) {
        // Record progress each time this function is called.
        if ($progress) {
            $progress->progress();
        }

        if (!file_exists($file)) {
            return false;
        }

        if (is_file($file)) {
            if (!is_readable($file)) {
                return false;
            }
            return $ziparch->add_file_from_pathname($archivepath, $file);
        }
        if (is_dir($file)) {
            if ($archivepath !== '') {
                $ziparch->add_directory($archivepath);
            }
            $files = new DirectoryIterator($file);
            foreach ($files as $file) {
                if ($file->isDot()) {
                    continue;
                }
                $newpath = $archivepath.'/'.$file->getFilename();
                $this->archive_pathname($ziparch, $newpath, $file->getPathname(), $progress);
            }
            unset($files); // Release file handles.
            return true;
        }
    }
private function archive_pathname ( $ ziparch , $ archivepath , $ file , file_progress $ progress = null ) { // Record progress each time this function is called. if ( $ progress ) { $ progress -> progress ( ) ; } if ( ! file_exists ( $ file ) ) { return false ; } if ( is_file ( $ file ) ) { if ( ! is_readable ( $ file ) ) { return false ; } return $ ziparch -> add_file_from_pathname ( $ archivepath , $ file ) ; } if ( is_dir ( $ file ) ) { if ( $ archivepath !== '' ) { $ ziparch -> add_directory ( $ archivepath ) ; } $ files = new DirectoryIterator ( $ file ) ; foreach ( $ files as $ file ) { if ( $ file -> isDot ( ) ) { continue ; } $ newpath = $ archivepath . '/' . $ file -> getFilename ( ) ; $ this -> archive_pathname ( $ ziparch , $ newpath , $ file -> getPathname ( ) , $ progress ) ; } unset ( $ files ) ; // Release file handles. return true ; } }
Perform archiving file from file path.

@param zip_archive $ziparch zip archive instance
@param string $archivepath file path to archive
@param string $file path name of the file
@param file_progress $progress Progress indicator callback or null if not required
@return bool success
Perform archiving file from file path .