@param Temp|UploadedFile|File $file
@param array                  $options

@return array

@throws \Exception
352883
public function manipulateImage($file, array $options, $imageType)
    {
        // Detect file type
        if ($file instanceof Temp) {
            $sanitizedFilename = $this->sanitizeFilename($file->filename);
        } elseif ($file instanceof UploadedFile) {
            $sanitizedFilename = $this->sanitizeFilename($file->getClientOriginalName());
        } elseif ($file instanceof File) {
            $actualFilename = str_replace('_source.', '.', $file->getFilename());
            $sanitizedFilename = $this->sanitizeFilename($actualFilename);
            $sourceFile = clone $file;
        } else {
            throw new \Exception('Unexpected file of class '.get_class($file));
        }

        $images = [];
        $pathParts = pathinfo($sanitizedFilename);
        // Move uploaded file and rename it as source file if this is needed.
        // We need to generate unique name if the name is already in use.
        if (! isset($sourceFile)) {
            $filename = $pathParts['filename']."_source{$imageType}.".$pathParts['extension'];
            $sourceFile = $file->move($this->getThumbnailPath(), $filename);
        }

        $images['original']['source'] = $sourceFile;
        $sanitizedFilename = $pathParts['filename'].$imageType.'.'.$pathParts['extension'];

        // If we have retina factor
        if ($this->getRetinaFactor()) {
            // Generate retina image by just copying the source.
            $retinaFilename = $this->generateRetinaName($sanitizedFilename);
            FileFacade::copy($sourceFile->getRealPath(), $this->getThumbnailPath().$retinaFilename);
            $images['original']['retina'] = Image::make($this->getThumbnailPath().$retinaFilename);

            // The original image is scaled down version of the source.
            $originalImage = Image::make($sourceFile->getRealPath());
            $width = round($originalImage->getWidth() / $this->getRetinaFactor());
            $height = round($originalImage->getHeight() / $this->getRetinaFactor());
            //$originalImage->resize($width, $height);
            $images['original']['original_file'] = $originalImage->save($this->getThumbnailPath().$sanitizedFilename);

            // Generate thumbs
            foreach ($options['thumbnails'] as $thumbnailName => $thumbnailOptions) {
                // Create retina thumb
                $images['thumbnails'][$thumbnailName]['retina'] = $this->createThumbnail($sourceFile->getRealPath(),
                    $thumbnailName, $this->generateRetinaName($sanitizedFilename),
                    $thumbnailOptions['width'] * $this->getRetinaFactor(),
                    $thumbnailOptions['height'] * $this->getRetinaFactor(),
                    $thumbnailOptions['type'],
                    array_get($thumbnailOptions, 'color'));
                // Create original thumb
                $images['thumbnails'][$thumbnailName]['original'] = $this->createThumbnail($sourceFile->getRealPath(),
                    $thumbnailName, $sanitizedFilename, $thumbnailOptions['width'],
                    $thumbnailOptions['height'], $thumbnailOptions['type'],
                    array_get($thumbnailOptions, 'color'));
            }
        } else {
            // Copy source file.
            $filename = $this->sanitizeFilename($file->getFilename());
            FileFacade::copy($sourceFile->getRealPath(), $this->getThumbnailPath().$filename);
            $images['original']['original_file'] = Image::make($this->getThumbnailPath().$filename);

            // Generate thumbs
            foreach ($options['thumbnails'] as $thumbnailName => $thumbnailOptions) {
                // Create original thumb
                $images['thumbnails'][$thumbnailName]['original'] = $this->createThumbnail($sourceFile->getRealPath(),
                    $thumbnailName, $sanitizedFilename, $thumbnailOptions['width'],
                    $thumbnailOptions['height'], $thumbnailOptions['type']);
            }
        }

        return $images;
    }
1270652
public static function open(array $options = [])
    {
        // get the method passed in $options else use port
        $method = array_get($options, 'method', 'post');
        $attributes['method'] = self::getMethod($method);

        $attributes['action'] = self::getAction($options);
        $attributes['accept-charset'] = array_get($options, 'charset', 'UTF-8');
        //
        //PUT and PATCH and DELETE
        //
        //if form use files
        if (isset($options['files']) || in_array('files', $options)) {
            $options['enctype'] = 'multipart/form-data';
        }

        $attributes = array_merge(
            $attributes, array_except($options, self::$reserved)
        );

        $attributes = Html::attributes($attributes);

        $token = self::token();

        return '<form'.$attributes.'>'.$token;
    }
1054521
public function fork($file, $options = array(), $start = true)
    {
        return $this->parallel(function ($process) use ($file) {
            if (is_string($file) && is_file($file)) {
                include($file);
            } else {
                throw new \RuntimeException('Bad file');
            }
        }, $options, $start);
    }
1066891
public function loadFromFile(string $file, array $options = []): Dom
    {
        return $this->loadStr(file_get_contents($file), $options);
    }
546330
public function load($files = [], $options = null)
    {
        if ($files != null) {
            $this->items = FileLoader::load($files, $options);
        }
        return $this;
    }
413319
public function decode($file, array $options = [])
    {
        $image  = new Image($file);
        $binary = $image->getBinaryString();

        return $this->decodeMessage($binary, $options);
    }
600676
public function file(array &$submitted, array $options = array())
    {
        $this->options = $options;
        $this->submitted = &$submitted;

        $this->validateFile();
        $this->validateTitleFile();
        $this->validateDescription();
        $this->validateWeight();
        $this->validateTranslation();
        $this->validateUploadFile();
        $this->validatePathFile();
        $this->validateEntityFile();
        $this->validateEntityIdFile();
        $this->validateFileTypeFile();
        $this->validateMimeTypeFile();

        $this->unsetSubmitted('update');

        return $this->getResult();
    }
184553
protected function lockFileName($file, array $options = array()) {
        $lockDir = $this->getOption('lock_dir', $options, $this->getCachePath() . 'locks' . DIRECTORY_SEPARATOR);
        return $lockDir . preg_replace('/\W/', '_', $file) . $this->getOption(xPDO::OPT_LOCKFILE_EXTENSION, $options, '.lock');
    }
159211
private function doRequestUpload(UploadedFile $file)
    {
        $tmpDirectory = $this->getApplication()->getTemporaryDir();
        $data = [];

        if (null !== $file) {
            if ($file->isValid()) {
                if ($file->getClientSize() <= $file->getMaxFilesize()) {
                    $data = $this->buildData($file->getClientOriginalName(), $file->guessExtension());
                    $file->move($tmpDirectory, $data['filename']);
                    $data['size'] = round($file->getClientSize() / 1024, 2);
                    if ($imageInfo = @getimagesize( $data['path'])) {
                        if (isset($imageInfo[0]) && isset($imageInfo[1])) {
                            $data['width'] = $imageInfo[0];
                            $data['height'] = $imageInfo[1];
                        }
                    } else {
                        $data['width'] = 0;
                        $data['height'] = 0;
                    }
                } else {
                    throw new BadRequestHttpException('Too big file, the max file size is ' . $file->getMaxFilesize());
                }
            } else {
                throw new BadRequestHttpException($file->getErrorMessage());
            }
        }

        return $data;
    }
582959
public function processUpdateJobFromFile($file, array $update = [ ], $report_email = false, $postback_url = false, array $options = [ ]) {
        return $this->processUpdateJob('file', $file, $update, $report_email, $postback_url, [ 'file' ], $options);
    }
612577
public function putFile($path, $file, $options = [])
    {
        return $this->putFileAs($path, $file, $file->hashName(), $options);
    }
863272
private function path($file, array $options = []) {
        // get base and full paths
        $base = $this->Url->assetUrl($file, $options);
        $fullpath = preg_replace('/^' . preg_quote($this->request->getAttribute('webroot'), '/') . '/', '', urldecode($base));

        // do webroot path
        $webrootPath = Configure::read('App.wwwRoot') . str_replace('/', DS, $fullpath);
        if(file_exists($webrootPath))
            return $webrootPath;

        // do plugin webroot path
        $pluginFile = $this->_getPluginFile($fullpath);
        if($pluginFile !== null && file_exists($pluginFile))
            return $pluginFile;

        // not found?
        return false;
    }
749416
public function process($file, $options)
    {
        $process = $this->execute($file, $options);

        return $this->setError($process);
    }
127221
protected function assertFile(string $file, array $options): bool
    {
        if (is_file($file) && is_readable($file)) {
            return true;
        }

        if (!(bool)($options['optional'] ?? false)) {
            throw new LoadException("Config file '$file' doesn't exist or is not readable");
        }

        return false;
    }
345166
public function open(array $options = [])
    {
        $method = array_get($options, 'method', 'post');

        // We need to extract the proper method from the attributes. If the method is
        // something other than GET or POST we'll use POST since we will spoof the
        // actual method since forms don't support the reserved methods in HTML.
        $attributes['method'] = $this->getMethod($method);

        $attributes['action'] = $this->getAction($options);

        $attributes['accept-charset'] = 'UTF-8';

        if (isset($options['files']) && $options['files']) {
            $options['enctype'] = 'multipart/form-data';
        }

        // Finally we're ready to create the final form HTML field. We will attribute
        // format the array of attributes. We will also add on the appendage which
        // is used to spoof requests for this PUT, PATCH, etc. methods on forms.
        $attributes = array_merge(

            $attributes, array_except($options, $this->reserved)

        );

        // Finally, we will concatenate all of the attributes into a single string so
        // we can build out the final form open statement. We'll also append on an
        // extra value for the hidden _method field if it's needed for the form.
        $attributes = $this->html->attributes($attributes);

        return '<form'.$attributes.'>';
    }
662355
public function load($file, array $options = [])
    {
        if ($this->getDefault($options, self::SIMPLEXML, false)) {
            return $this->loadSimpleXml($file, $options);
        }

        return $this->loadDom($file, $options);
    }
1112248
public static function fromFile($file, array $option = array())
    {
        if (!file_exists($file)) {
            throw new \InvalidArgumentException('File not found: ' . $file);
        }

        return new self(new FileIterator($file), $option);
    }