Archive_Tar::_close PHP Method

_close() public method

{{{ _close()
public _close ( )
    function _close()
    {
        //if (isset($this->_file)) {
        if (is_resource($this->_file)) {
            if ($this->_compress_type == 'gz') {
                @gzclose($this->_file);
            } else {
                if ($this->_compress_type == 'bz2') {
                    @bzclose($this->_file);
                } else {
                    if ($this->_compress_type == 'none') {
                        @fclose($this->_file);
                    } else {
                        $this->_error('Unknown or missing compression type (' . $this->_compress_type . ')');
                    }
                }
            }
            $this->_file = 0;
        }
        // ----- Look if a local copy need to be erase
        // Note that it might be interesting to keep the url for a time : ToDo
        if ($this->_temp_tarname != '') {
            @unlink($this->_temp_tarname);
            $this->_temp_tarname = '';
        }
        return true;
    }

Usage Example

Ejemplo n.º 1
0
 /** Generate a tar/tgz/bz file
  * If you define $installer, this function will also put in
  * the archive a file (si)
  *
  * @param unknown_type $file
  * @param unknown_type $format 
  * @param bool $installer filename for an instaler file
  */
 function generateTarGz($file, $format = 'gz', $installer = null)
 {
     if (!class_exists('Archive_Tar')) {
         include $this->dataDir . '/archive_tar.php';
     }
     $cp = new Archive_Tar($file, $format);
     $v_result = true;
     if (!$cp->_openWrite()) {
         return false;
     }
     foreach ($this->vfsFiles as $n => $v) {
         if (!$cp->_addString(substr($n, 1), $v)) {
             return false;
         }
     }
     $cp->_writeFooter();
     $cp->_close();
     return true;
 }