src/Tar.php
public function create($file = '')
    {
        $this->file   = $file;
        $this->memory = '';
        $this->fh     = 0;

        if ($this->file) {
            // determine compression
            if ($this->comptype == Archive::COMPRESS_AUTO) {
                $this->setCompression($this->complevel, $this->filetype($file));
            }

            if ($this->comptype === Archive::COMPRESS_GZIP) {
                $this->fh = @gzopen($this->file, 'wb'.$this->complevel);
            } elseif ($this->comptype === Archive::COMPRESS_BZIP) {
                $this->fh = @bzopen($this->file, 'w');
            } else {
                $this->fh = @fopen($this->file, 'wb');
            }

            if (!$this->fh) {
                throw new ArchiveIOException('Could not open file for writing: '.$this->file);
            }
        }
        $this->writeaccess = true;
        $this->closed      = false;
    }
public function create($file = '')
    {
        $this->file   = $file;
        $this->memory = '';
        $this->fh     = 0;

        if ($this->file) {
            // determine compression
            if ($this->comptype == Archive::COMPRESS_AUTO) {
                $this->setCompression($this->complevel, $this->filetype($file));
            }

            if ($this->comptype === Archive::COMPRESS_GZIP) {
                $this->fh = @gzopen($this->file, 'wb'.$this->complevel);
            } elseif ($this->comptype === Archive::COMPRESS_BZIP) {
                $this->fh = @bzopen($this->file, 'w');
            } else {
                $this->fh = @fopen($this->file, 'wb');
            }

            if (!$this->fh) {
                throw new ArchiveIOException('Could not open file for writing: '.$this->file);
            }
        }
        $this->writeaccess = true;
        $this->closed      = false;
    }
public function create ( $ file = '' ) { $ this -> file = $ file ; $ this -> memory = '' ; $ this -> fh = 0 ; if ( $ this -> file ) { // determine compression if ( $ this -> comptype == Archive :: COMPRESS_AUTO ) { $ this -> setCompression ( $ this -> complevel , $ this -> filetype ( $ file ) ) ; } if ( $ this -> comptype === Archive :: COMPRESS_GZIP ) { $ this -> fh = @ gzopen ( $ this -> file , 'wb' . $ this -> complevel ) ; } elseif ( $ this -> comptype === Archive :: COMPRESS_BZIP ) { $ this -> fh = @ bzopen ( $ this -> file , 'w' ) ; } else { $ this -> fh = @ fopen ( $ this -> file , 'wb' ) ; } if ( ! $ this -> fh ) { throw new ArchiveIOException ( 'Could not open file for writing: ' . $ this -> file ) ; } } $ this -> writeaccess = true ; $ this -> closed = false ; }
Create a new TAR file

If $file is empty, the tar file will be created in memory

@param string $file
@throws ArchiveIOException
@throws ArchiveIllegalCompressionException
Create a new TAR file