예제 #1
0
 /**
  * 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;
 }
예제 #2
0
 /**
  * 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;
 }
예제 #3
0
 /**
  * Gets the cached snapshot file name
  *
  * @return string cached file name
  */
 private function CachedSnapshotFile()
 {
     $key = ($this->archive->GetObject() ? $this->archive->GetObject()->GetHash() : '') . '|' . (isset($this->params['file']) ? $this->params['file'] : '') . '|' . (isset($this->params['prefix']) ? $this->params['prefix'] : '');
     $cachefile = sha1($key) . '-' . $this->archive->GetFilename();
     return $cachefile;
 }