Splits a reference to a file in 5 parts

@param string $fileref Filename/filepath to be analysed
@return array Contains keys [path], [file], [filebody], [fileext], [realFileext]
321421
public static function split_fileref($fileref) {
		$reg = array();
		if (preg_match('/(.*\/)(.*)$/', $fileref, $reg)) {
			$info['path'] = $reg[1];
			$info['file'] = $reg[2];
		} else {
			$info['path'] = '';
			$info['file'] = $fileref;
		}

		$reg = '';
		if (!is_dir($fileref) && preg_match('/(.*)\.([^\.]*$)/', $info['file'], $reg)) {
			$info['filebody'] = $reg[1];
			$info['fileext'] = strtolower($reg[2]);
			$info['realFileext'] = $reg[2];
		} else {
			$info['filebody'] = $info['file'];
			$info['fileext'] = '';
		}
		reset($info);
		return $info;
	}
332484
protected function & getArrayByReference(&$offset)
    {
        $offset = explode(self::SEPARATOR, $offset);

        if (count($offset) > 1) {
            $arr = &$this->getFromArray($this->storage, array_slice($offset, 0, -1), false);
        } else {
            $arr = &$this->storage;
        }

        $offset = array_slice($offset, -1);
        $offset = reset($offset);

        return $arr;
    }
266056
private function getFileContents($file)
    {
        if (!isset($this->filesContent[$file])) {
            $this->filesContent[$file] = file_exists($file) ? file($file) : [];
        }

        return $this->filesContent[$file];
    }
1050516
public static function realpath($path) {
    if (file_exists($path)) {
      return str_replace("\\", "/", realpath($path));
    }
    $path = str_replace("\\", "/", $path);
    $parts = array_filter(explode("/", $path), 'strlen');
    $absolutes = [];
    foreach ($parts as $part) {
      if ('.' == $part) {
        continue;
      }
      if ('..' == $part) {
        array_pop($absolutes);
      }
      else {
        $absolutes[] = $part;
      }
    }
    $result = implode("/", $absolutes);
    if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
      $result = '/'.$result;
    }
    return $result;
  }
691457
public static function urlencodeFilename($file) {
    $parts = explode('/', $file);
    $result = [];
    foreach ($parts as $part) {
      $result[] = rawurlencode($part);
    }
    return join('/', $result);
  }
393423
protected function resolveReference($ref)
	{
		// @todo Better resolver (Only work with internal components atm)
		if (strpos($ref, '#/components/') !== 0) {
			throw new Exception('Can not resolve this $ref atm (todo) : ' . $ref);
		}

		$componentPath = str_replace('#/components/', '', $ref);
		$pathParts = explode('/', $componentPath);

		$target = $this->openApiFileContent['components'];
		$processingPathParts = ['#', 'components'];
		$targetName = '';
		foreach ($pathParts as $pathPart) {
			$processingPathParts[] = $pathPart;
			if (!isset($target[$pathPart])) {
				throw new Exception('Can not resolve $ref "' . $ref . '" : Segment not found at "' . implode('/', $processingPathParts) . '"');
			}
			$target = $target[$pathPart];
			$targetName = $pathPart;
		}

		return [
			'name' => $targetName,
			'target' => $target
		];
	}
139169
private function getRelativeFilePath($file)
    {
        $realPath = $file->getRealPath();
        $pathPrefix = $this->baseDir.'/';
        $pos = strpos($realPath, $pathPrefix);
        $relativePath = (false !== $pos) ? substr_replace($realPath, '', $pos, strlen($pathPrefix)) : $realPath;

        return strtr($relativePath, '\\', '/');
    }
331472
private function extractFilePath($fileArgument)
    {
        // If the file argument was a variable, get it from the context
        if ($fileArgument !== null &&
            \strlen($fileArgument) > 0 &&
            $fileArgument[0] === '$') {
            $fileArgument = $this->context->get(\preg_replace('/^\$/', '', $fileArgument));
        }

        return $fileArgument;
    }
47145
public static function splitFileName($strFileName, $blnExtractVersion = true)
	{
		$arrParts = array();
		
		$intPosDot = strrpos($strFileName, ".");
		$fileName = substr($strFileName, 0, $intPosDot);
		$fileType = substr($strFileName, $intPosDot + 1);
		
		$hasVersion = false;
		$version = null;
		$versionMajor = null;
		$versionMinor = null;
		$versionPatch = null;
		
		if ($blnExtractVersion)
		{
			$arrFileNameParts = explode("_", $fileName);
			if (count($arrFileNameParts) >= 4)
			{
				$versionMajorTemp = $arrFileNameParts[count($arrFileNameParts) - 3];
				$versionMinorTemp = $arrFileNameParts[count($arrFileNameParts) - 2];
				$versionPatchTemp = $arrFileNameParts[count($arrFileNameParts) - 1];
				
				if (is_numeric($versionMajorTemp) && is_numeric($versionMinorTemp) && is_numeric($versionPatchTemp))
				{
					$hasVersion = true;
					$version = self::buildVersionForFileName($versionMajorTemp, $versionMinorTemp, $versionPatchTemp);
					$versionMajor = $versionMajorTemp;
					$versionMinor = $versionMinorTemp;
					$versionPatch = $versionPatchTemp;
					
					$fileName = substr($fileName, 0, strrpos($fileName, "_$version"));
				}
			}
		}
		
		$arrParts['fileName'] = $fileName;
		$arrParts['fileType'] = $fileType;
		$arrParts['hasVersion'] = $hasVersion;
		$arrParts['version'] = $version;
		$arrParts['versionMajor'] = $versionMajor;
		$arrParts['versionMinor'] = $versionMinor;
		$arrParts['versionPatch'] = $versionPatch;
		
		return $arrParts;
	}
15529
def split_vcf(in_file, ref_file, config, out_dir=None):
    
    if out_dir is None:
        out_dir = os.path.join(os.path.dirname(in_file), "split")
    out_files = []
    with open(ref.fasta_idx(ref_file, config)) as in_handle:
        for line in in_handle:
            chrom, size = line.split()[:2]
            out_file = os.path.join(out_dir,
                                    os.path.basename(replace_suffix(append_stem(in_file, "-%s" % chrom), ".vcf")))
            subset_vcf(in_file, (chrom, 0, size), out_file, config)
            out_files.append(out_file)
    return out_files
875079
protected function splitNameAndPath($name)
    {

        list($start, $end) = strpos($name, '::') ? explode('::', $name) : ['', $name];

        if ($start) {
            return [$start, $end];
        }

        $paths = $this->getPaths();

        // If the name does not exists in the paths, it assumes its a (file)path.
        if (!isset($paths[$end])) {
            return ['', $end];
        }

        return [$end, ''];

    }
1263531
public static function getRelativeFilepath($file)
    {
        $storageDir = self::convertSlashes(config('filer.path.absolute'));
        $absolutePath = self::convertSlashes($file->getRealPath());
        return dirname(str_replace($storageDir, '', $absolutePath));
    }
661452
protected function decodeXrefStream($startxref, $xref=array()) {
        // try to read Cross-Reference Stream
        list($xrefobj, $unused) = $this->getRawObject($startxref);
        $xrefcrs = $this->getIndirectObject($xrefobj[1], $startxref, true);
        if (!isset($xref['xref_location'])) {
            $xref['xref_location'] = $startxref;
            $xref['max_object'] = 0;
        }
        if (!isset($xref['xref'])) {
            $xref['xref'] = array();
        }
        if (!isset($xref['trailer']) OR empty($xref['trailer'])) {
            // get only the last updated version
            $xref['trailer'] = array();
            $xref['trailer'][0] = PDF_TYPE_DICTIONARY;
            $xref['trailer'][1] = array();
            $filltrailer = true;
        } else {
            $filltrailer = false;
        }
        $valid_crs = false;
        $sarr = $xrefcrs[0][1];
        $keys = array_keys($sarr);
        $columns = 1; // Default as per PDF 32000-1:2008.
        $predictor = 1; // Default as per PDF 32000-1:2008.
        foreach ($keys as $k=>$key) {
            $v = $sarr[$key];
            if (($key == '/Type') AND ($v[0] == PDF_TYPE_TOKEN AND ($v[1] == 'XRef'))) {
                $valid_crs = true;
            } elseif (($key == '/Index') AND ($v[0] == PDF_TYPE_ARRAY AND ($v[1] >= 2))) {
                // first object number in the subsection
                $index_first = intval($v[1][0][1]);
                // number of entries in the subsection
                $index_entries = intval($v[1][1][1]);
            }
540830
public static function split($fileName)
    {
        $ext = pathinfo($fileName);
        return [
            $ext['dirname'],
            $ext['filename'],
            empty($ext['extension']) ? '' : $ext['extension']
        ];
    }
8335
public function getByRef($sRef, $aData = [])
    {
        if (empty($aData['where'])) {
            $aData['where'] = [];
        }

        $aData['where'][] = [$this->sTableAlias . '.ref', $sRef];

        $aEmails = $this->getAll(null, null, $aData);

        return !empty($aEmails) ? reset($aEmails) : false;
    }
1203071
public static function shortenPath($file)
    {
        $file = \array_values(\array_filter(\explode('/', \str_replace('\\', '/', $file)), 'strlen'));

        $longest_match = 0;
        $match = '/';

        foreach (self::$app_root_dirs as $path => $alias) {
            if (empty($path)) {
                continue;
            }

            $path = \array_values(\array_filter(\explode('/', \str_replace('\\', '/', $path)), 'strlen'));

            if (\array_slice($file, 0, \count($path)) === $path && \count($path) > $longest_match) {
                $longest_match = \count($path);
                $match = $alias;
            }
        }

        if ($longest_match) {
            $file = \array_merge(array($match), \array_slice($file, $longest_match));

            return \implode('/', $file);
        }

        // fallback to find common path with Kint dir
        $kint = \array_values(\array_filter(\explode('/', \str_replace('\\', '/', KINT_DIR)), 'strlen'));

        foreach ($file as $i => $part) {
            if (!isset($kint[$i]) || $kint[$i] !== $part) {
                return ($i ? '.../' : '/').\implode('/', \array_slice($file, $i));
            }
        }

        return '/'.\implode('/', $file);
    }
213002
protected function getFileParts($filename)
    {
        if (preg_match('/(.*)@(\d+)x\.(.*)$/', $filename, $matches)) {
            $name = $matches[1];
            $extension = $matches[3];
            $extra = (int) $matches[2];
            $type = 'alternative';

            if ($extra === 1) {
                $type = 'base';
                $extra = null;
            }
        } else {
            $fileParts = explode('.', $filename);

            $name = array_shift($fileParts);
            $extension = null;
            $extra = null;
            $type = 'base';

            while (($part = array_shift($fileParts)) !== null) {
                if ($part !== 'meta' && $part !== 'thumb') {
                    if (null !== $extension) {
                        $name .= '.' . $extension;
                    }
                    $extension = $part;
                } else {
                    $type = $part;
                    $extra = '.' . $part . '.' . implode('.', $fileParts);
                    break;
                }
            }
        }

        return array($name, $extension, $type, $extra);
    }