@param $sha
@param $filepath

@return array
507174
public function getFile($sha, $filepath)
    {
        return $this->client->repositories()->getFile($this->id, $filepath, $sha);
    }
965388
public static String getEntireFileSha1(String filePath) throws Exception {
		InputStream fileInputStream = null;
		try {
			fileInputStream = CommonFileUtils.getFileInputStream(filePath);
			String sha1Digest = DigestUtils.sha1Hex(fileInputStream);
			return sha1Digest;
		} catch (Exception e) {
			String errMsg = "getFileSha1 occur a exception, file:" + filePath + ", exception:" + e.toString();
			LOG.error(errMsg);
			throw new Exception(errMsg);
		} finally {
			try {
				CommonFileUtils.closeFileStream(fileInputStream, filePath);
			} catch (Exception e) {
				throw e;
			}
		}
	}
739932
private function sortByPriority(array $filePaths): array
    {
        $toSort = [];

        foreach ($filePaths as $filePath) {
            $file = json_decode(file_get_contents($filePath), true);

            $sequence = Arr::get($file, 'general.sequence', 0);

            $toSort[$sequence][] = $filePath;
        }

        ksort($toSort);

        return Arr::collapse($toSort);
    }
1015295
public function passthru($filepath, $info = array())
	{
		$this->debug->group(__METHOD__);
		// $this->debug->log('info', $info);
		$info = array_merge(array(
			'filename'	=> null,
			'md5'		=> null,
			'mime'		=> 'image/jpeg',
			'size'		=> null,
		), $info);
		if (file_exists($filepath)) {
			if (empty($info['md5'])) {
				$info['md5'] = md5_file($filepath);
			}
			if (empty($info['size'])) {
				$info['size'] = filesize($filepath);
			}
			$headers = apache_request_headers();
			$this->debug->log('headers', $headers);
			$this->debug->log('info[md5]', $info['md5']);
			if (isset($headers['If-None-Match']) && $headers['If-None-Match'] == $info['md5']) {
				header('HTTP/1.1 304 Not Modified');
			} else {
				header('Content-Type: '.$info['mime']);
				header('ETag: '.$info['md5']);
				header('Content-Length: '.$info['size']);
				// header('Cache-Control: must-revalidate');
				header('Last Modified: '.gmdate('D, d M Y H:i:s \G\M\T'));
				if ($info['filename']) {
					header('Content-Disposition: inline; filename="'.$info['filename'].'"');
				}
				readfile($filepath);
			}
		} else {
			$this->debug->warn('file does not exist', $filepath);
		}
		$this->debug->groupEnd();
		return;
	}
94028
public function extract($filePath)
    {
        $directory = $this->directory->getDirectoryPath();
        $zipArchive = new ZipArchive();
        $zipArchive->open($filePath);
        $zipArchive->extractTo($directory);

        return $this->createFinderFromDirectory($directory);
    }
320815
public function extract($filePath)
    {
        $directory = $this->directory->getDirectoryPath();
        $rarArchive = RarArchive::open($filePath);
        $rarEntries = $rarArchive->getEntries();

        /**
         * @var RarEntry $rarEntiry
         */
        foreach ($rarEntries as $rarEntry) {

            $rarEntry->extract($directory);
        }

        return $this->createFinderFromDirectory($directory);
    }
262415
public function extract($filePath)
    {
        $directory = $this->directory->getDirectoryPath();
        $pharArchive = new Phar($filePath);
        $pharArchive->extractTo($directory);

        return $this->createFinderFromDirectory($directory);
    }
298407
def hash(filepath, method='sha1', buffer_size=65536):
    
    if method == 'sha1':
        hash_function = hashlib.sha1()
    elif method == 'md5':
        hash_function = hashlib.md5()
    else:
        raise NotImplementedError('Only md5 and sha1 hashes are known, but '
                                  ' \'{}\' was specified.'.format(method))

    with open(filepath, 'rb') as fp:
        while True:
            data = fp.read(buffer_size)
            if not data:
                break
            hash_function.update(data)
    return hash_function.hexdigest()
338899
public function create(string $ref, string $sha): array
    {
        return $this->getApi()->request($this->getApi()
                                             ->sprintf('/repos/:owner/:repo/git/refs', $this->getGitData()->getOwner(),
                                                 $this->getGitData()->getRepo()), Request::METHOD_POST, [
                'ref' => $ref,
                'sha' => $sha
            ]);
    }
338654
public function getFilePath($filePath)
    {
        $composerFiles = [];
        foreach ($this->alias as $name => $path) {
            $composerFiles[] = $path . '/' . $filePath;
        }

        return FileHelper::getFirstExistingFileArray($composerFiles);
    }
52507
public function findAllFiles(DirectoryPath $path = null)
    {
        if (null === $path) {
            $path = new DirectoryPath();
        }

        $finder = new Finder();
        $searchPath = $path->prepend($this->gitService->getRepositoryPath());

        $finder->in($searchPath->toAbsoluteString(DIRECTORY_SEPARATOR));

        $filePaths = [];

        foreach ($finder->files() as $file) {
            /** @var SplFileInfo $file */
            $filePaths[] = FilePath::parse('/' . $file->getRelativePathname())->prepend($path);
        }

        return $filePaths;
    }
381485
public static function load( $filePath, $asArray = NULL )
	{
		$reader	= new FS_File_JSON_Reader( $filePath );
		return $reader->read( $asArray );
	}
336999
protected function getConfigurationFiles($directoryPath)
    {
        $files = [];

        if (is_dir($directoryPath)) {
            foreach (Finder::create()->files()->in($directoryPath) as $file) {
                $group = basename($file->getRealPath(), '.php');
                $files[$group] = $file->getRealPath();
            }
        }

        return $files;
    }
942074
public static function getImageDimensions(string $filePath): ?\stdClass {
        list($width, $height, $type) = getimagesize($filePath);

        if ($type === null) {
            return null;
        }

        return (object)[
            'width' => (int)$width,
            'height' => (int)$height,
            'mime' => image_type_to_mime_type($type),
        ];
    }
61225
private function getSharedStimulusFile($filePath)
    {
        \helpers_TimeOutHelper::setTimeOutLimit(\helpers_TimeOutHelper::LONG);
        $extractPath = $this->extractArchive($filePath);
        \helpers_TimeOutHelper::reset();

        $iterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator($extractPath),
            \RecursiveIteratorIterator::LEAVES_ONLY);

        /** @var $file \SplFileInfo */
        foreach ($iterator as $file) {
            //check each file to see if it can be the shared stimulus file
            if ($file->isFile()) {
                if (preg_match('/^[\w]/', $file->getFilename()) === 1 && $file->getExtension() === 'xml') {
                    return $file->getRealPath();
                }
            }
        }

        throw new \common_Exception('XML not found in the package');
    }
417466
protected function getFileRelativePath($filePath)
    {
        $commonParts = array();

        // replace window \ to work with /
        $rootDir = (false !== strpos($this->rootDir, '\\')) ? str_replace('\\', '/', $this->rootDir) : $this->rootDir;

        $antiSlash = false;
        if (false !== strpos($filePath, '\\')) {
            $filePath = str_replace('\\', '/', $filePath);
            $antiSlash = true;
        }

        $rootDirParts = explode('/', $rootDir);
        $filePathParts = explode('/', $filePath);

        $i = 0;
        while ($i < count($rootDirParts)) {
            if (isset($rootDirParts[$i], $filePathParts[$i]) && $rootDirParts[$i] == $filePathParts[$i]) {
                $commonParts[] = $rootDirParts[$i];
            }
            $i++;
        }

        $filePath = str_replace(implode('/', $commonParts).'/', '', $filePath);

        $nbCommonParts = count($commonParts);
        $nbRootParts = count($rootDirParts);

        for ($i = $nbCommonParts; $i < $nbRootParts; $i++) {
            $filePath = '../'.$filePath;
        }

        return $antiSlash ? str_replace('/', '\\', $filePath) : $filePath;
    }
298790
private function getLocalFileHash($filename)
        {
                $path = $this->phpids_base . $filename;
                if (file_exists($path)) {
                        return sha1_file($path);
                } else {
                        return false;
                }
        }