original_string: public function file($path, array $options = [])
      {
          deprecationWarning(
              'Response::file() is deprecated. ' .
              'Use withFile() instead.'
          );
  
          $file = $this->validateFile($path);
          $options += [
              'name' => null,
              'download' => null
          ];
  
          $extension = strtolower($file->ext());
          $download = $options['download'];
          if ((!$extension || $this->type($extension) === false) && $download === null) {
              $download = true;
          }
  
          $fileSize = $file->size();
          if ($download) {
              $agent = env('HTTP_USER_AGENT');
  
              if (preg_match('%Opera(/| )([0-9].[0-9]{1,2})%', $agent)) {
                  $contentType = 'application/octet-stream';
              } elseif (preg_match('/MSIE ([0-9].[0-9]{1,2})/', $agent)) {
                  $contentType = 'application/force-download';
              }
  
              if (!empty($contentType)) {
                  $this->type($contentType);
              }
              if ($options['name'] === null) {
                  $name = $file->name;
              } else {
                  $name = $options['name'];
              }
              $this->download($name);
              $this->header('Content-Transfer-Encoding', 'binary');
          }
  
          $this->header('Accept-Ranges', 'bytes');
          $httpRange = env('HTTP_RANGE');
          if (isset($httpRange)) {
              $this->_fileRange($file, $httpRange);
          } else {
              $this->header('Content-Length', $fileSize);
          }
  
          $this->_file = $file;
          $this->stream = new Stream($file->path, 'rb');
      }
code: public function file($path, array $options = [])
      {
          deprecationWarning(
              'Response::file() is deprecated. ' .
              'Use withFile() instead.'
          );
  
          $file = $this->validateFile($path);
          $options += [
              'name' => null,
              'download' => null
          ];
  
          $extension = strtolower($file->ext());
          $download = $options['download'];
          if ((!$extension || $this->type($extension) === false) && $download === null) {
              $download = true;
          }
  
          $fileSize = $file->size();
          if ($download) {
              $agent = env('HTTP_USER_AGENT');
  
              if (preg_match('%Opera(/| )([0-9].[0-9]{1,2})%', $agent)) {
                  $contentType = 'application/octet-stream';
              } elseif (preg_match('/MSIE ([0-9].[0-9]{1,2})/', $agent)) {
                  $contentType = 'application/force-download';
              }
  
              if (!empty($contentType)) {
                  $this->type($contentType);
              }
              if ($options['name'] === null) {
                  $name = $file->name;
              } else {
                  $name = $options['name'];
              }
              $this->download($name);
              $this->header('Content-Transfer-Encoding', 'binary');
          }
  
          $this->header('Accept-Ranges', 'bytes');
          $httpRange = env('HTTP_RANGE');
          if (isset($httpRange)) {
              $this->_fileRange($file, $httpRange);
          } else {
              $this->header('Content-Length', $fileSize);
          }
  
          $this->_file = $file;
          $this->stream = new Stream($file->path, 'rb');
      }
code_tokens: public function file ( $ path , array $ options = [ ] ) { deprecationWarning ( 'Response::file() is deprecated. ' . 'Use withFile() instead.' ) ; $ file = $ this -> validateFile ( $ path ) ; $ options += [ 'name' => null , 'download' => null ] ; $ extension = strtolower ( $ file -> ext ( ) ) ; $ download = $ options [ 'download' ] ; if ( ( ! $ extension || $ this -> type ( $ extension ) === false ) && $ download === null ) { $ download = true ; } $ fileSize = $ file -> size ( ) ; if ( $ download ) { $ agent = env ( 'HTTP_USER_AGENT' ) ; if ( preg_match ( '%Opera(/| )([0-9].[0-9]{1,2})%' , $ agent ) ) { $ contentType = 'application/octet-stream' ; } elseif ( preg_match ( '/MSIE ([0-9].[0-9]{1,2})/' , $ agent ) ) { $ contentType = 'application/force-download' ; } if ( ! empty ( $ contentType ) ) { $ this -> type ( $ contentType ) ; } if ( $ options [ 'name' ] === null ) { $ name = $ file -> name ; } else { $ name = $ options [ 'name' ] ; } $ this -> download ( $ name ) ; $ this -> header ( 'Content-Transfer-Encoding' , 'binary' ) ; } $ this -> header ( 'Accept-Ranges' , 'bytes' ) ; $ httpRange = env ( 'HTTP_RANGE' ) ; if ( isset ( $ httpRange ) ) { $ this -> _fileRange ( $ file , $ httpRange ) ; } else { $ this -> header ( 'Content-Length' , $ fileSize ) ; } $ this -> _file = $ file ; $ this -> stream = new Stream ( $ file -> path , 'rb' ) ; }
docstring: Setup for display or download the given file.
  
  If $_SERVER['HTTP_RANGE'] is set a slice of the file will be
  returned instead of the entire file.
  
  ### Options keys
  
  - name: Alternate download name
  - download: If `true` sets download header and forces file to be downloaded rather than displayed in browser
  
  @param string $path Path to file. If the path is not an absolute path that resolves
  to a file, `APP` will be prepended to the path (this behavior is deprecated).
  @param array $options Options See above.
  @return void
  @throws \Cake\Http\Exception\NotFoundException
  @deprecated 3.4.0 Use withFile() instead.
docstring_tokens: Setup for display or download the given file .