src/Zip.php
public function addFile($file, $fileinfo = '')
    {
        if (is_string($fileinfo)) {
            $fileinfo = FileInfo::fromPath($file, $fileinfo);
        }

        if ($this->closed) {
            throw new ArchiveIOException('Archive has been closed, files can no longer be added');
        }

        $data = @file_get_contents($file);
        if ($data === false) {
            throw new ArchiveIOException('Could not open file for reading: '.$file);
        }

        // FIXME could we stream writing compressed data? gzwrite on a fopen handle?
        $this->addData($fileinfo, $data);
    }
public function addFile($file, $fileinfo = '')
    {
        if (is_string($fileinfo)) {
            $fileinfo = FileInfo::fromPath($file, $fileinfo);
        }

        if ($this->closed) {
            throw new ArchiveIOException('Archive has been closed, files can no longer be added');
        }

        $data = @file_get_contents($file);
        if ($data === false) {
            throw new ArchiveIOException('Could not open file for reading: '.$file);
        }

        // FIXME could we stream writing compressed data? gzwrite on a fopen handle?
        $this->addData($fileinfo, $data);
    }
public function addFile ( $ file , $ fileinfo = '' ) { if ( is_string ( $ fileinfo ) ) { $ fileinfo = FileInfo :: fromPath ( $ file , $ fileinfo ) ; } if ( $ this -> closed ) { throw new ArchiveIOException ( 'Archive has been closed, files can no longer be added' ) ; } $ data = @ file_get_contents ( $ file ) ; if ( $ data === false ) { throw new ArchiveIOException ( 'Could not open file for reading: ' . $ file ) ; } // FIXME could we stream writing compressed data? gzwrite on a fopen handle? $ this -> addData ( $ fileinfo , $ data ) ; }
Add a file to the current archive using an existing file in the filesystem

@param string $file path to the original file
@param string|FileInfo $fileinfo either the name to use in archive (string) or a FileInfo oject with all meta data, empty to take from original
@throws ArchiveIOException
@throws FileInfoException
Add a file to the current archive using an existing file in the filesystem