/** * Open a descriptor for this archive * * @param GitPHP_Archive $archive archive * @return boolean true on success */ public function Open($archive) { if (!$archive) { return false; } if ($this->handle) { return true; } $args = array(); $args[] = '--format=tar'; $args[] = "--prefix='" . $archive->GetPrefix() . "'"; $args[] = $archive->GetObject()->GetHash(); $this->handle = $this->exe->Open($archive->GetProject()->GetPath(), GIT_ARCHIVE, $args); // hack to get around the fact that gzip files // can't be compressed on the fly and the php zlib stream // doesn't seem to daisy chain with any non-file streams $this->tempfile = tempnam(sys_get_temp_dir(), "GitPHP"); $mode = 'wb'; if ($this->compressLevel) { $mode .= $this->compressLevel; } $temphandle = gzopen($this->tempfile, $mode); if ($temphandle) { while (!feof($this->handle)) { gzwrite($temphandle, fread($this->handle, 1048576)); } gzclose($temphandle); $temphandle = fopen($this->tempfile, 'rb'); } if ($this->handle) { pclose($this->handle); } $this->handle = $temphandle; return $this->handle !== false; }
/** * Open a descriptor for this archive * * @param GitPHP_Archive $archive archive * @return boolean true on success */ public function Open($archive) { if (!$archive) { return false; } if ($this->handle) { return true; } $args = array(); $args[] = '--format=tar'; $args[] = "--prefix='" . $archive->GetPrefix() . "'"; $args[] = $archive->GetObject()->GetHash(); $this->handle = $this->exe->Open($archive->GetProject()->GetPath(), GIT_ARCHIVE, $args); return $this->handle !== false; }