Find the files version.

@param $file
@return mixed
494946
public function version($file)
    {
        try {
            $manifest = $this->readManifestFile();
        } catch (\Exception $e) {
            Craft::log(printf($e->getMessage()), LogLevel::Info, true);
            return $file;
        }

        // if no manifest, return the regular asset
        if (!$manifest) {
            return $file;
        }

        return '/' . $this->buildPath . '/' . $manifest[$file];
    }
270990
public function findOriginalFileToVersion(File $file)
    {
        if(!$this->containsFile($file)){
            return null;
        }

        preg_match("/([^-]+)(-.*)?/", $file->getBasename(), $matches);
        $ext = $file->getExtension() == ""?"":".".$file->getExtension();
        return new FileImpl($file->getParentFolder()->getAbsolutePath()."/".$matches[1].$ext);
    }
933462
public static function pathInfo($file)
    {
        $result = self::_pathInfo($file);
        return self::i()->dump($result, '! pathInfo (' . $file . ') !');
    }
289660
public function isMinified($file)
    {
        $minified = false;

        if (!$minified) {
            $fileInfo = $this->getFileInfo();
            if (isset($fileInfo[$file])) {
                $minified = $fileInfo[$file]['Minify'];
            }
        }

        if (!$minified) {
            $combinesInfo = $this->getCombinesInfo();
            if (isset($combinesInfo[$file])) {
                $minified = $combinesInfo[$file]['Minify'];
            }
        }

        return $minified;
    }
1024919
private function fileVersionExists($version, $files)
    {
        if (null === $version || 'all' == $version) {
            return true;
        }

        foreach ($files as $file) {
            $filenameParser = new FileNameParser($file->getFileName());
            if ($version === $filenameParser->getVersion()) {
                return true;
            }
        }

        return false;
    }
75152
private static function getIgnoredFiles($file) {
    if (file_exists($file) === FALSE) {
      return array();
    }

    $contents = file_get_contents($file);
    if ($contents === FALSE) {
      return array();
    }

    return preg_split('/\s+/', $contents);
  }
88180
public static function for_file($file)
    {
        if (!$file || (is_string($file) && !file_exists($file))) {
            return null;
        }

        // Ensure we have a File instance to work with
        if (is_string($file)) {
            /** @var File $fileObject */
            $fileObject = File::create();
            $fileObject->setFromLocalFile($file);
            $file = $fileObject;
        }

        $extension = $file->getExtension();
        $mime = $file->getMimeType();

        foreach (self::get_extractor_classes() as $className) {
            $extractor = self::get_extractor($className);

            // Skip unavailable extractors
            if (!$extractor->isAvailable()) {
                continue;
            }

            // Check extension
            if ($extension && $extractor->supportsExtension($extension)) {
                return $extractor;
            }

            // Check mime
            if ($mime && $extractor->supportsMime($mime)) {
                return $extractor;
            }
        }
    }
558508
protected function getFileFinder($file) {
    return new class($file) implements ClassFinderInterface {

      protected $file;

      public function __construct($file) {
        $this->file = $file;
      }

      public function findFile($class) {
        return $this->file;
      }
    };
  }
584113
def get_version(*file_paths):
    """"""
    filename = os.path.join(os.path.dirname(__file__), *file_paths)
    print("Looking for version in: {}".format(filename))
    version_file = open(filename).read()
    version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
    if version_match:
        return version_match.group(1)
    raise RuntimeError('Unable to find version string.')
305010
public function getPath($file)
    {
        $file = "/".ltrim($file,"/");

        $best = null;
        foreach($this->nodes as $node) {
            $mount = $node->getMountPoint();
            if (strncmp($mount, $file, strlen($mount)) === 0) {
                $nodefile = substr($file, strlen($mount));
                //printf("nodefile=%s mount=%s file=%s\n", $nodefile, $mount, $file);
                if ($node->has($nodefile)) {
                    return $node->getPath($nodefile);
                }
                if (!$best) {
                    $best = $node->getPath($nodefile);
                }
                if ($node->getIsWritable($nodefile)) {
                    $best = $node->getPath($nodefile);
                }
            }
        }
        return $best;

    }
539053
private function get_po_revision( $file ) {
		$file        = $this->language_files_dir . '/' . $file;
		$headers     = array( 'PO-Revision-Date' => '"PO-Revision-Date' );
		$all_headers = array();

		$fp = fopen( $file, 'r' );

		// Pull only the first 1kiB of the file in.
		$contents = fread( $fp, 1024 );

		fclose( $fp );

		foreach ( $headers as $field => $regex ) {
			if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $contents, $match ) && $match[1] ) {
				$value                 = $this->_cleanup_header_comment( $match[1] );
				$value                 = preg_replace( '~(\\\n)?"$~', '', $value );
				$all_headers[ $field ] = $value;
			} else {
				$all_headers[ $field ] = '';
			}
		}

		return $all_headers['PO-Revision-Date'];
	}
186065
def find_version(file_path):
    
    with open(file_path, 'r') as f:
        file_contents = f.read()
    version_match = re.search(r"^__version__\s*=\s*['\"]([^'\"]*)['\"]",
                              file_contents, re.M)
    if version_match:
        return version_match.group(1)
    else:
        raise RuntimeError("unable to find version string")
1017421
public static function getFile( $file ) {
		$file = Storage::getFile( Route::DOCUMENT_ROOT() . 'app/config/' . $file . '.json' );
		$out  = Parser::json( $file );

		return $out;
	}
1268402
private function getCache($file)
    {
        if (null === $this->cache) {
            return null;
        }

        $key = md5($file);

        // File already present
        if ($this->cache->has($key)) {
            list($mtime, $path) = unserialize($this->cache->get($key));

            if ($mtime === filemtime($file)) {
                return $path;
            }

            $delete = $this->directory.'/'.$path;
            if (file_exists($delete) && false === @unlink($delete)) {
                throw new \RuntimeException('Unable to remove file '.$delete);
            }
        }

        return null;
    }
730313
protected function read_version_file() {
		$retval = NULL;
		
		//okay, all files present: check the version in the VERSION file.
		if(file_exists($this->versionFileLocation)) {
			$versionFileContents = file_get_contents($this->versionFileLocation);
			
			$versionMatches = array();
			preg_match_all('/\nVERSION: (.*)\n/', $versionFileContents, $versionMatches);
			if(count($versionMatches) == 2 && count($versionMatches[1]) == 1) {
				$this->versionFileVersion = $this->get_full_version_string(trim($versionMatches[1][0]));
				$retval = $this->versionFileVersion;

				//now retrieve the PROJECT name.
				$projectMatches = array();
				preg_match_all('/\nPROJECT: (.*)\n/', $versionFileContents, $projectMatches);
				if(count($projectMatches) == 2 && count($projectMatches[1]) == 1) {
					$this->projectName = trim($projectMatches[1][0]);
				}
				else {
					$this->error_handler(__METHOD__ .": failed to find PROJECT name");
				}
			}
			else {
				$this->error_handler(__METHOD__ .": could not find VERSION data");
			}
		}
		else {
			$this->error_handler(__METHOD__ .": Version file (". $this->versionFileLocation .") does not exist");
		}
		
		return($retval);
	}
826203
public function getUrl($file = '')
        {

            $version = $this->manager->getVersion();
            $pattern = $this->manager->getPattern();

            /** Search Params
             *  %f => $file
             *  %v => $version
             */

            $f = str_replace('%f', $file, $pattern);
            $v = str_replace('%v', $version, $f);

            return $this->getUrlString() . $v;
        }
734158
protected function getFile($file)
    {
        $mapping = [
            '%environment%' => $this->runtime->getEnvironment(),
        ];

        if ($this->runtime->getHostName() !== null) {
            $mapping['%host%'] = $this->runtime->getHostName();
        }

        if ($this->runtime->getReleaseId() !== null) {
            $mapping['%release%'] = $this->runtime->getReleaseId();
        }

        $options = $this->getOptions();
        return str_replace(
            array_keys($mapping),
            array_values($mapping),
            $options[$file]
        );
    }