Check file exists and readable

@param  string $file definition file name
@return void
@throws NotFoundException if not exist or readable
@access protected
517509
protected function checkFileExistence(/*# string */ $file)
    {
        if (!file_exists($file) || !is_readable($file)) {
            throw new NotFoundException(
                Message::get(Message::DEFINITION_NOT_FOUND, $file),
                Message::DEFINITION_NOT_FOUND
            );
        }
    }
306702
private function deleteFile($file) {
		try {
			if($this->client && $this->client->enabled()) {
				$this->client->delete($file);
			}
		}
		catch(StorageException $ex) {
			Logger::error("Error deleting file '$file'.", ['exception' => $ex->getMessage(), 'Key' => $file]);
		}
	}
1258586
private function loadFile ($file)
	{
		if (!isset ($this->files[$file]))
		{
			$filename = $this->folder . $file . '.php';

			// First load these
			if (file_exists ($filename))
			{
				$this->files[$file] = include ($filename);
			}

			// Now overload with environment values
			if (isset ($this->environment))
			{
				$filename = $this->folder . $this->environment . '/' . $file . '.php';
				if (file_exists ($filename))
				{
					$this->merge ($file, include ($filename));
				}
			}

		}
	}
510628
public function checkFilename($file)
    {
        $newFilename  = $file;
        $parts        = pathinfo($file);
        $origFilename = $parts['filename'];
        $ext          = (isset($parts['extension']) && ($parts['extension'] != '')) ? '.' . $parts['extension'] : null;

        $i = 1;

        while (file_exists($this->uploadDir . DIRECTORY_SEPARATOR . $newFilename)) {
            $newFilename = $origFilename . '_' . $i . $ext;
            $i++;
        }

        return $newFilename;
    }
939382
private function checkNotAllowedTypes($file = '')
        {
            $notAllowedTypes = $this->getNotAllowedExt();

            if ('*' === $notAllowedTypes) {
                return true;
            }

            if(is_string($notAllowedTypes))
            {
                $notAllowedTypes = (array) $notAllowedTypes;
            }

            foreach($notAllowedTypes as $type){
                if(strstr($file, $type)){
                    return false;
                }else{
                    continue;
                }
            }

            return true;
        }
1368925
public function read($file)
    {
        $this->filePath = $file;
        $this->lines = file($this->filePath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
    }
129373
private function loadFile($file, $ext)
    {
        $filename = $this->fixFilename($file, $ext);

        if (!is_readable($filename)) {
            throw new NotFoundException('file', $file);
        }

        return file_get_contents($filename);
    }
1312908
public static function load($file)
    {
        if (file_exists($file)) {
            $env = \M1\Env\Parser::parse(file_get_contents($file));
            foreach ($env as $key => $value) {
                putenv("{$key}={$value}");
            }
        }
    }
82621
private function lintFile($file)
    {
        // first try to parse it
        try {
            $this->parser->parse(\file_get_contents($file));
        } catch (\Exception $e) {
            return false;
        }

        return true;
    }
1048198
public static function checkFileDeletable($file)
    {
        clearstatcache();
        $dir = dirname($file);
        // Deleting a file requires write permissions on the directory.
        // It does not require write permissions on the file
        return @file_exists($dir) && @is_writable($dir);
    }
141713
public function validateAssetFile($file)
    {
        $filePath = substr($file, 1);

        if (!is_file($filePath))
            throw new FileNotFoundException("File ".$filePath." was not found");

        $path_parts = pathinfo($filePath);

        if( !in_array($path_parts['extension'], array(
            "js", "css", "png", "jpg", "jpeg", "gif", "ttf", "otf", "woff"
        )))
            throw new WrongFileExtensionException("Wrong file format\n
            Supported formats: js, css, png, jpg, jpeg, gif, ttf, otf, woff");
    }
501152
public function fileGet($file)
    {
        if (($r = @file_get_contents($this->alias->resolve($file))) === false) {
            throw new FileNotFoundException($file);
        }

        return $r;
    }
1240075
public function deleteFile($file)
    {
        if (!$this->filesystem->has($file)) {
            return;
        }

        $this->filesystem->delete($file);
        $this->cacheManager->remove($file);
    }
332490
public function read($file)
    {
        $this->filePath = $file;
        $this->config = parse_ini_file($this->filePath);
    }
600757
public static function Delete( string $file )
   {

      if ( ! \file_exists( $file ) )
      {
         // No deleting required
         return;
      }

      try
      {
         \unlink( $file );
         \clearstatcache();
         if ( ! \file_exists( $file ) )
         {
            // Deleting was successful
            return;
         }
      }
      catch ( \Throwable $ex ) { }

      if ( '\\' === DIRECTORY_SEPARATOR )
      {
         $f = \escapeshellarg( $file );
         try { \exec( "del {$f}" ); }
         catch ( \Throwable $ex )
         {
            throw new IOException( $file, 'Deleting the defined file fails!', \E_USER_ERROR, $ex );
         }
         \clearstatcache();
         if ( \file_exists( $file ) )
         {
            throw new IOException(
               $file,
               'Deleting the defined file fails! No known method works.'
            );
         }
         return;
      }

      try { \exec( "unlink {$file}" ); }
      catch ( \Throwable $ex )
      {
         throw new IOException( $file, 'Deleting the defined file fails!', \E_USER_ERROR, $ex );
      }

      \clearstatcache();

      if ( \file_exists( $file ) )
      {
         throw new IOException(
            $file,
            'Deleting the defined file fails!'
         );
      }

   }
1349855
public static function checkFile($file)
    {
        if (Symphony::Log()) {
            Symphony::Log()->pushDeprecateWarningToLog('General::checkFile()', '`General::checkFileWritable()');
        }
        clearstatcache();
        $dir = dirname($file);

        if (
            (!is_writable($dir) || !is_readable($dir)) // Folder
            || (file_exists($file) && (!is_readable($file) || !is_writable($file))) // File
        ) {
            return false;
        }

        return true;
    }
1274692
public function readHelpFile($file)
    {
        $this->helpArray = array_merge(
            $this->helpArray,
            (array)parse_ini_string($this->pool->fileService->getFileContents($file))
        );
    }