當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Git::sha1Hex方法代碼示例

本文整理匯總了PHP中Git::sha1Hex方法的典型用法代碼示例。如果您正苦於以下問題:PHP Git::sha1Hex方法的具體用法?PHP Git::sha1Hex怎麽用?PHP Git::sha1Hex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Git的用法示例。


在下文中一共展示了Git::sha1Hex方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getRawObject

 /**
  * @brief Fetch an object in its binary representation by name.
  *
  * Throws an exception if the object cannot be found.
  *
  * @param $objectName (string) name of the object (binary SHA1)
  * @returns (array) an array consisting of the object type (int) and the
  * binary representation of the object (string)
  */
 protected function getRawObject($objectName)
 {
     static $cache = array();
     /* FIXME allow limiting the cache to a certain size */
     if (isset($cache[$objectName])) {
         return $cache[$objectName];
     }
     $sha1 = Git::sha1Hex($objectName);
     $path = sprintf('%s/objects/%s/%s', $this->dir, substr($sha1, 0, 2), substr($sha1, 2));
     if (file_exists($path)) {
         list($hdr, $objectData) = explode("", gzuncompress(file_get_contents($path)), 2);
         sscanf($hdr, "%s %d", $type, $objectSize);
         $objectType = Git::getTypeID($type);
         $result = array($objectType, $objectData);
     } elseif ($packedObject = $this->findPackedObject($objectName)) {
         list($packName, $objectOffset) = $packedObject;
         $pack = fopen(sprintf('%s/objects/pack/pack-%s.pack', $this->dir, sha1Hex($packName)), 'rb');
         flock($pack, LOCK_SH);
         /* check magic and version */
         $magic = fread($pack, 4);
         $version = Binary::fuint32($pack);
         if ($magic != 'PACK' || $version != 2) {
             throw new Exception('unsupported pack format');
         }
         $result = $this->unpackObject($pack, $objectOffset);
         fclose($pack);
     } else {
         throw new Exception(sprintf('object not found: %s', sha1Hex($objectName)));
     }
     $cache[$objectName] = $result;
     return $result;
 }
開發者ID:Ennosuke,項目名稱:glip,代碼行數:41,代碼來源:Git.php


注:本文中的Git::sha1Hex方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。