Creates a content service asset object based on a given resampled file path

@param type $filename
@return ContentServiceAsset
517178
protected function createResampledAsset($filename) {
        $fullpath = Director::baseFolder() . '/' . $filename;
        $asset = ContentServiceAsset::get()->filter('Filename', $filename)->first();

		if(!$asset) {
            $asset = new ContentServiceAsset();
        }

        $this->service = singleton('ContentService');


        $asset->Filename = $filename;
        $asset->SourceID = $this->ID;
        $asset->ParentID = $this->ParentID;
        $mtime = time();

        $writer = $this->service->getWriterFor($asset, 'FilePointer', $this->targetStore());
        if ($writer) {
            if (file_exists($fullpath)) {
                // likely that cached image never got built correctly.
                $name = \Controller::join_links(dirname($filename), $mtime, basename($filename));
                $writer->write(fopen($fullpath, 'r'), $name);

                $asset->FilePointer = $writer->getContentId();
                $asset->write();

                $reader = $writer->getReader();
                if ($reader && $reader->exists()) {
                    singleton('ContentDeliveryService')->removeLocalFile($fullpath);
                }
            } else {
                $asset = null;
            }
        } else {
            $asset = null;
        }

        return $asset;
    }
1126719
public function createFile($fileName, $preserve = false)
        {
            $this->initRunFolder();

            $fileInfo = new \SplFileInfo($this->tmpRunFolder . DIRECTORY_SEPARATOR . $fileName);

            $this->filesystem->touch($fileInfo);

            $this->files[] = array(
                'file'  => $fileInfo,
                'preserve'  => $preserve
            );

            $this->filesystem->chmod($fileInfo, 0600);

            return $fileInfo;
        }
1326778
public function fileContent($content)
    {
        if (is_resource($this->fileContent)) {
            fclose($this->fileContent);
        }

        $this->fileContent = $content;

        if (is_resource($content) && empty($this->fileType)) {
            $this->fileType($this->getTypeFromResource($content));
        }

        return $this;
    }
636708
public static function load( $fileName )
	{
		$parser	= new XML_DOM_Parser();
		$xml	= FS_File_Reader::load( $fileName );
		$tree	= $parser->parse( $xml );
		return $tree;
	}
1055100
public static function fromFile(string $filename, bool $allowGuessByExtension): MediaType
    {
        $result = 'application/octet-stream';

        if (!@is_file($filename) || !@is_readable($filename)) {
            return new self($result);
        }

        $result = self::guessFromFinfo($filename);
        if (self::isFallback($result)) {
            $result = self::guessFromFileCommand($filename);
        }

        if ($allowGuessByExtension && self::isFallback($result)) {
            $extension = pathinfo($filename, PATHINFO_EXTENSION);
            if (self::isKnownExtension($extension)) {
                return self::fromExtension($extension);
            }
        }

        $result = str_replace(['charset=binary', 'charset=us-ascii'], ['', ''], strtolower($result));
        $result = rtrim($result, '; ');

        return new self($result);
    }
811276
public static function parseFile($filename) {
    $source = @file_get_contents($filename);
    if ($source === FALSE) {
      return FALSE;
    }
    return self::parseSource($source, $filename);
  }
189011
public function setFileRaw( string$key, string$contentType, string$content, string$fileName=null ):self
	{
		$this->files[$key]= [
			'fileName'=> $fileName??md5($content),
			'contentType'=> $contentType,
			'content'=> $content,
		];

		return $this;
	}
1034576
public static function parseFile($fileName, $fileContent = null)
    {
        $fileName = PathResolver::realpath($fileName);
        if (isset(self::$parsedFiles[$fileName]) && !isset($fileContent)) {
            return self::$parsedFiles[$fileName];
        }

        if (isset(self::$maximumCachedFiles) && (count(self::$parsedFiles) === self::$maximumCachedFiles)) {
            array_shift(self::$parsedFiles);
        }

        if (!isset($fileContent)) {
            $fileContent = file_get_contents($fileName);
        }
        $treeNode = self::$parser->parse($fileContent);
        $treeNode = self::$traverser->traverse($treeNode);

        self::$parsedFiles[$fileName] = $treeNode;

        return $treeNode;
    }
1352013
private function loadFile($filename)
    {
        $dom = new Document();
        $dom->formatOutput = true;
        $dom->load($filename);

        $this->applyReferenceElementtype($dom);

        return $dom;
    }
221826
public function sendToDisk($filename)
    {
        $filePath = self::getOutputPath($filename);
        $this->pImage->render($filePath);
        return $filePath;
    }
887967
public function createPath($filename)
    {
        $dir = Config::get('js-localization.storage_path');
        if (!is_dir($dir)) {
            mkdir($dir, 0777, true);
        }

        return $dir . $filename;
    }
566993
private function createResourceResponse($filename)
    {
        $response = new Response();

        $filestats = stat($filename);

        $response->headers->set('Content-Type', MimeType::getInstance()->guess($filename));
        $response->headers->set('Content-Length', $filestats['size']);

        $response->setCache(array(
            'etag'          => basename($filename),
            'last_modified' => new \DateTime('@'.$filestats['mtime']),
            'public'        => 'public',
        ));

        $response->setContent(file_get_contents($filename));

        return $response;
    }
1373345
public function isFileService($serviceName, $resources = null)
    {
        $service = Service::whereName($serviceName)->first();
        if (!empty($service)) {
            if (null === $type = ServiceManager::getServiceType($service->type)) {
                return false;
            }

            return (ServiceTypeGroups::FILE === $type->getGroup());
        } elseif (!empty($resources)) {
            if (is_string($resources)) {
                $resources = explode(',', $resources);
            }
            foreach ($resources as $resource) {
                if (is_string($resource)) {
                    if (false !== $this->zip->locateName(
                            $serviceName .
                            '/' .
                            rtrim($resource, '/') .
                            '/' .
                            md5($resource) .
                            '.' .
                            static::FILE_EXTENSION
                        )
                    ) {
                        return true;
                    }
                }
            }
        }

        return false;
    }
1024778
static public function tryCreateFromFile($filename) {
		try {
			$instance = self::createFromFile($filename);
			return $instance;
		} catch (\Exception $exception) {
			return null;
		}
	}
1065898
protected function createFileName($fileName)
    {
        return $this->parseFileName($fileName) . $this->suffix() . $this->config->fileExtension();
    }
839258
public function getOriginal($filename)
    {
        $path = $this->getImagePath($filename);

        return $this->buildResponse(file_get_contents($path));
    }
1337299
public function addFile($fileName, Scopable $scope = null) {
		$content = new HtmlFromFile();
		$content->fileName = $fileName;
		$content->scope = $scope;
		$this->children[] = $content;
	
		return $this;
	}