Pump data into an active hashing context
from a file. Returns TRUE on success or
FALSE on failure.
(PHP 5 >= 5.1.2, PECL hash >= 1.1)

@param resource
@param string
@param resource
@return bool
964608
public function updateFile($hcontext, $filename, $scontext = null)
    {
        if (!is_resource($hcontext)) {
            return false;
        }

        return hash_update_file($hcontext, $filename, $scontext);
    }
522211
protected function loadStorage($resource)
    {
        $template = $this->parser->parse($resource);

        $key = $template->getLogicalName();
        if (isset($this->cache[$key])) {
            return $this->cache[$key];
        }

        $storage = $this->template_loader->load($template);
        if (!$storage instanceof MatterStorage) {
            throw new \RuntimeException(sprintf('The template "%s" does not have matter.', $template));
        }

        return $this->cache[$key] = $storage;
    }
41619
protected function loadResource($resource)
    {
        $stream = fopen($resource, 'r');

        $stat = fstat($stream);

        if ($stat['size'] < self::MO_HEADER_SIZE) {
            throw new InvalidResourceException('MO stream content has an invalid format.');
        }
        $magic = unpack('V1', fread($stream, 4));
        $magic = hexdec(substr(dechex(current($magic)), -8));

        if (self::MO_LITTLE_ENDIAN_MAGIC == $magic) {
            $isBigEndian = false;
        } elseif (self::MO_BIG_ENDIAN_MAGIC == $magic) {
            $isBigEndian = true;
        } else {
            throw new InvalidResourceException('MO stream content has an invalid format.');
        }

        // formatRevision
        $this->readLong($stream, $isBigEndian);
        $count = $this->readLong($stream, $isBigEndian);
        $offsetId = $this->readLong($stream, $isBigEndian);
        $offsetTranslated = $this->readLong($stream, $isBigEndian);
        // sizeHashes
        $this->readLong($stream, $isBigEndian);
        // offsetHashes
        $this->readLong($stream, $isBigEndian);

        $messages = [];

        for ($i = 0; $i < $count; ++$i) {
            $pluralId = null;
            $translated = null;

            fseek($stream, $offsetId + $i * 8);

            $length = $this->readLong($stream, $isBigEndian);
            $offset = $this->readLong($stream, $isBigEndian);

            if ($length < 1) {
                continue;
            }

            fseek($stream, $offset);
            $singularId = fread($stream, $length);

            if (false !== strpos($singularId, "\000")) {
                list($singularId, $pluralId) = explode("\000", $singularId);
            }

            fseek($stream, $offsetTranslated + $i * 8);
            $length = $this->readLong($stream, $isBigEndian);
            $offset = $this->readLong($stream, $isBigEndian);

            if ($length < 1) {
                continue;
            }

            fseek($stream, $offset);
            $translated = fread($stream, $length);

            if (false !== strpos($translated, "\000")) {
                $translated = explode("\000", $translated);
            }

            $ids = ['singular' => $singularId, 'plural' => $pluralId];
            $item = compact('ids', 'translated');

            if (\is_array($item['translated'])) {
                $messages[$item['ids']['singular']] = stripcslashes($item['translated'][0]);
                if (isset($item['ids']['plural'])) {
                    $plurals = [];
                    foreach ($item['translated'] as $plural => $translated) {
                        $plurals[] = sprintf('{%d} %s', $plural, $translated);
                    }
                    $messages[$item['ids']['plural']] = stripcslashes(implode('|', $plurals));
                }
            } elseif (!empty($item['ids']['singular'])) {
                $messages[$item['ids']['singular']] = stripcslashes($item['translated']);
            }
        }

        fclose($stream);

        return array_filter($messages);
    }
1131429
public static function getResourceParser($resource)
    {
        if(self::$_resourceLoader) {
            $type = preg_replace("/[^A-Za-z0-9_]/", " ", get_resource_type($resource));
            $type = str_replace(" ","", ucwords($type));
            return self::$_resourceLoader->load($type);
        }
        return false;
    }
220009
public function load(FilesystemResource $resource)
    {

        if(!$this->validateExtension($resource)){
            return false;
        }

        return $this->transform($resource);
    }
892045
public function themePathExists(string $resource): bool
    {
        if (file_exists($this->sourceDirectory.'/'.$resource)) {
            return true;
        }

        if (null === $this->theme) {
            return false;
        }

        $themeResource = $this->findThemeResource($this->theme, $resource);
        if (null !== $themeResource) {
            return true;
        }

        if (isset($this->theme['parent'])) {
            $themeResource = $this->findThemeResource($this->theme['parent'], $resource);
            if (null !== $themeResource) {
                return true;
            }
        }

        return false;
    }
418459
static function of($resource)
    {
        if (!is_resource($resource) && get_resource_type($resource) !== 'stream-context')
            throw new \InvalidArgumentException(sprintf(
                'Invalid Context Resource Passed, given: "%s".'
                , \Poirot\Std\flatten($resource)
            ));


        // ..
        $options = stream_context_get_params($resource);
        $context = new ContextStreamSocket($options); // Socket Context can be used as Base Context
        return $context;
    }
298904
public function getCachePathForResource(string $resource)
    {
        if (!$this->cacheDir) {
            return false;
        }

        return str_replace($this->appDir, $this->cacheDir, $resource);
    }
104517
public boolean contains(String resource) {
		boolean result = storage.contains(resource);
		logger.debug("resource '{}' {} in cache", resource, (result ? "is" : "is not"));
		return result; 
	}
604985
public function isGranted($resource)
    {
        foreach ($this->roles as $role) {
            if (true === $role->hasResource($resource)) {
                return true;
            }
        }

        return false;
    }
84122
public function isLocked($resource = null): bool
    {
        return $this->hasSharedLock($resource) || $this->hasExclusiveLock($resource);
    }
149936
public function findSimilarResources(PersistentResource $resource)
    {
        $query = $this->createQuery();
        $query->matching(
            $query->logicalAnd(
                $query->equals('sha1', $resource->getSha1()),
                $query->equals('filename', $resource->getFilename()),
                $query->equals('collectionName', $resource->getCollectionName())
            )
        );
        return $query->execute();
    }
417002
function join($resource)
    {
        //保存到空闲连接池中
        $this->resourcePool[spl_object_hash($resource)] = $resource;
        $this->release($resource);
    }
726847
public function deleteResource(PersistentResource $resource)
    {
        $pathAndFilename = $this->getStoragePathAndFilenameByHash($resource->getSha1());
        if (!file_exists($pathAndFilename)) {
            return true;
        }
        if (unlink($pathAndFilename) === false) {
            return false;
        }
        Files::removeEmptyDirectoriesOnPath(dirname($pathAndFilename));
        return true;
    }
947131
public function hasSharedLock($resource = null): bool
    {
        if (null !== $resource) {
            return isset($this->sharedLock[$this->getResourceId($resource)]);
        }

        return !empty($this->sharedLock);
    }
1034663
public function supports($resource, $type = null): bool
    {
        \assert('is_string($resource) && ($type === null || is_string($type))');
        return $this->parser->supports(pathinfo($resource, PATHINFO_EXTENSION));
    }
1347386
public function getIssue($resource)
    {
        $hashPosition = strpos($resource, '#');
        if ($hashPosition !== false) {
            $resource = substr($resource, 0, $hashPosition);
        }

        $url = $this->host . '/browse/';

        if (strncmp($resource, $url, strlen($url)) === 0) {
            return substr($resource, strlen($url));
        }
    }