Assets::file

@param string $file

@return string
776877
public function file($file)
    {
        $filePaths = loader()->getPublicDirs(true);

        foreach ($filePaths as $filePath) {
            if (is_file($filePath . $file)) {
                return path_to_url($filePath . $file);
                break;
            }
        }
    }
567288
public function locateFile($file)
    {
        $components = $this->parseResource($file);
        if ($components['path']) {
            $path = dirname($components['path']) . '/public/';

            return $path . $components['file'];
        } else {
            return $components['file'];
        }
    }
715046
public static function getAbsFile($file)
    {
        // If already absolute
        if (self::is_absolute($file)) {
            return $file;
        }

        // If path is relative to public folder search there first
        if (self::publicDir()) {
            $path = Path::join(self::publicFolder(), $file);
            if (file_exists($path)) {
                return $path;
            }
        }

        // Default to base folder
        return Path::join(self::baseFolder(), $file);
    }
281235
public function assets($file, $lib=null, $theme=null) {

        $this->secondaryTheme($theme);
        
        $assets = $this->enqueueFiles($file,
                    $this->container->getFolderAssets($lib)
                );
        
        return  $assets;

    }
1314733
public function realpath($file)
    {
        $prefix = preg_quote($this->_prefix, '~');
        $file = preg_replace("~^{$prefix}~", '', $file);
        if (!$this->_hasVolume) {
            return $file;
        }
        if (preg_match('~^[A-Z]+:~', $file)) {
            return $file;
        }
        $file = ltrim($file, DS);
        $pos = strpos($file, DS);
        if ($pos !== false) {
            $file = substr_replace($file, ':' . DS, $pos, 1);
        }
        return $file;
    }
796000
public static function read(string $file = ''): string
    {
        $result = false;
        $file = static::normalizePath($file);

        if (static::exists($file)) {
            $result = @\file_get_contents($file);
        }

        return $result;
    }
750843
private function open_image( $file )
	{
		$sfile = new SFile($file);

		// If $file isn't an array, we'll turn it into one
		if ( !is_array($file) ) {
			$file = array(
				'type'		=> $sfile->getMimeType(),
				'tmp_name'	=> $file
			);
		}

		$mime = $file['type'];
		$file_path = $file['tmp_name'];

		switch ( $mime )
		{
			case 'image/pjpeg': // IE6
			case 'image/jpeg':	$img = @imagecreatefromjpeg( $file_path );	break;
			case 'image/gif':	$img = @imagecreatefromgif( $file_path );	break;
			case 'image/png':	$img = @imagecreatefrompng( $file_path );	break;
			default:				$img = false;								break;
		}

		return $img;
	}
69162
static function resolveFileResolvable(string $file) {
        $rfile = @\realpath($file);
        if($rfile) {
            if(self::$filesystem) {
                return self::$filesystem->getContents($file);
            }
            
            return \React\Promise\resolve(\file_get_contents($rfile));
        } elseif(\filter_var($file, FILTER_VALIDATE_URL)) {
            return \CharlotteDunois\Yasmin\Utils\URLHelpers::resolveURLToData($file);
        }
        
        return \React\Promise\reject(new \RuntimeException('Given file is not resolvable'));
    }
1051903
protected final function resolveResource($file)
	{
		if(0 === strpos($file, './') || 0 === strpos($file, '../'))
		{
			$file = rtrim(dirname($this->getResource()), '/\\') . '/' . $file;
		}
		elseif(!preg_match("'^/|(?:[^:]+://)|(?:[a-z]:[\\\\/])'i", $file))
		{
			$dir = rtrim(dirname($this->getResource()), '/\\');
			$file = $dir . '/' . ltrim($file, '/\\');
		}
		
		return (string)$file;
	}
867915
private function updateAssets($file) {
        $modulesAssets = MODULES . $this->view->getModule() . DIRECTORY_SEPARATOR . 'View' .
                DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR;
        $themeAssets = THEMES . engineGet('config', 'defaults', 'theme') .
                DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR;

        if (is_dir($modulesAssets) && is_readable($modulesAssets . $file)) {
            $publicFile = $this->publicAssetsPath . $this->view->getModule() . DIRECTORY_SEPARATOR . $file;

            if (!is_dir($modulesAssets . $file) && (!is_readable($publicFile) || $this->checkOutOfDate($publicFile, $modulesAssets . $file))) {
                if (!is_dir(dirname($publicFile))) {
                    mkdir(dirname($publicFile), 0777, true);
                }
                copy($modulesAssets . $file, $publicFile);
            }
            else if (is_dir($modulesAssets . $file)) {
                Util::copyDir($modulesAssets . $file, $publicFile);
            }
        }
        else if (is_dir($themeAssets) && is_readable($themeAssets . $file)) {
            $publicFile = $this->publicAssetsPath . engineGet('config', 'defaults', 'theme') . DIRECTORY_SEPARATOR . $file;
            if (!is_dir($themeAssets . $file) && (!is_readable($publicFile) || $this->checkOutOfDate($publicFile, $themeAssets . $file))) {
                if (!is_dir(dirname($publicFile))) {
                    mkdir(dirname($publicFile), 0777, true);
                }
                copy($themeAssets . $file, $publicFile);
            }
            else if (is_dir($themeAssets . $file)) {
                Util::copyDir($themeAssets . $file, $publicFile);
            }
        }
        else {
            return false;
        }
        return true;
    }
610563
public static function image2Png($file)
    {
        try {
            if (is_file($file)) {
                return Image::open($file)->setCacheDir(dirname($file))->png();
            }
        } catch (Exception $e) {
        }
        return false;
    }
86978
public function downloadPath($file)
    {
        if (!$file) {
            return '';
        }

        $parts = explode(';', $file);
        $fileId = $parts[0];

        $src = $this->router->generate('frontendmedia_download', ['fileId' => $fileId], UrlGeneratorInterface::ABSOLUTE_PATH);

        return $src;
    }
713926
public function delete( $file )
	{
		// check for absolut path
		if ( substr( $file, 0, 1 ) == '/' ) 
		{
			return CCFile::delete( $file );
		}
		
		return CCFile::delete( $this->path( $file ) );
	}
39931
public function getUrl($file, $scope = null)
    {
        $asset = new AssetPath($file, $scope);
        return $this->resolve($asset->getPath(), $asset->getScope());
    }
285777
public function render( $file = '' ) {
		reset( $this->assets[ $this->type ] );
		//reset($this->attr[$this->type]);
		$attr = '';

		if ( $this->type == 'js' ) {

			if ( $file != '' ) {
				$key     = array_search( $file, $this->assets[ $this->type ] );
				$version = $this->versions[ $this->type ][ $key ];
				$asset   = $this->assets[ $this->type ][ $key ];

				if ( preg_match( "/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $asset ) ) {
					$asset_url = $asset;
				} else {
					$asset_url = $this->BaseUrl . Config::get( 'path.assets' ) . "/$this->type/" . $asset . '.' .
					             $this->type . $version;
				}

				while ( list( $at, $val ) = each( $this->attr[ $this->type ][ $key ] ) ) {
					$attr .= $at . '="' . $val . '" ';
				}

				if ( $key ) {
					return '<script type="text/javascript" src="' . $asset_url . '" ' . $attr . '></script>' . "\n";
				}

			} else {
				$render = '';

				while ( list( $key, $value ) = each( $this->assets[ $this->type ] ) ) {
					$asset   = $this->assets[ $this->type ][ $key ];
					$version = $this->versions[ $this->type ][ $key ];

					if ( preg_match( "/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $asset ) ) {
						$asset_url = $asset;
					} else {
						$asset_url = $this->BaseUrl . Config::get( 'path.assets' ) . "/$this->type/" . $asset . '.' .
						             $this->type . $version;
					}

					$attr = '';

					while ( list( $at, $val ) = each( $this->attr[ $this->type ][ $key ] ) ) {
						$attr .= $at . '="' . $val . '" ';
					}

					$render .= '<script type="text/javascript" src="' . $asset_url . '" ' . $attr . '></script>' . "\n";
				}

				return $render;
			}

		} elseif ( $this->type == 'css' ) {

			if ( $file != '' ) {
				$key     = array_search( $file, $this->assets[ $this->type ] );
				$asset   = $this->assets[ $this->type ][ $key ];
				$version = $this->versions[ $this->type ][ $key ];

				if ( preg_match( "/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $asset ) ) {
					$asset_url = $asset;
				} else {
					$asset_url = $this->BaseUrl . Config::get( 'path.assets' ) . "/$this->type/" . $asset . '.' .
					             $this->type . $version;
				}

				while ( list( $at, $val ) = each( $this->attr[ $this->type ][ $key ] ) ) {
					$attr .= $at . '="' . $val . '" ';
				}

				if ( $key ) {
					return '<link rel="stylesheet" href="' . $asset_url . '" ' . $attr . ' />' . "\n";
				}

			} else {
				$render = '';

				while ( list( $key, $value ) = each( $this->assets[ $this->type ] ) ) {
					$attr    = '';
					$asset   = $this->assets[ $this->type ][ $key ];
					$version = $this->versions[ $this->type ][ $key ];

					if ( preg_match( "/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $asset ) ) {
						$asset_url = $asset;
					} else {
						$asset_url = $this->BaseUrl . Config::get( 'path.assets' ) . "/$this->type/" . $asset . '.' .
						             $this->type . $version;
					}

					while ( list( $at, $val ) = each( $this->attr[ $this->type ][ $key ] ) ) {
						$attr .= $at . '="' . $val . '" ';
					}

					$render .= '<link rel="stylesheet" href="' . $asset_url . '" ' . $attr . ' />' . "\n";
				}

				return $render;
			}
		}

	}
1303690
public function parse($file)
    {
        if (isset($this->_tree[$file])) {
            return $this->_tree[$file];
        }
        $parser = $this->_classes['parser'];
        return $this->_tree[$file] = $parser::parse(file_get_contents($file), ['lines' => true]);
    }
553609
private function load($file)
    {
        if (!isset($this->commands[$file])) {
            $this->commands[$file] = Yaml::parse($file);
        }
        return $this->commands[$file];
    }