You are here

public static function MimeDetectService::checkMagicfile in MimeDetect 8

Checks a 'magic' file information.

Parameters

string $magic_file: Path to magic file.

string $msg: Optional string variable reference to place error message.

Return value

bool Test result. TRUE if OK, FALSE on error.

3 calls to MimeDetectService::checkMagicfile()
MimeDetectService::checkFileinfo in src/MimeDetectService.php
Checks the availability for PHP fileinfo mime detection engine.
MimeDetectService::checkUnixfile in src/MimeDetectService.php
Checks UNIX 'file' command system avilability.
MimeDetectSettingsForm::validateForm in src/Form/MimeDetectSettingsForm.php
Form validation handler.

File

src/MimeDetectService.php, line 149

Class

MimeDetectService
MimeDetect service.

Namespace

Drupal\mimedetect

Code

public static function checkMagicfile($magic_file, &$msg = '') {
  $errors = FALSE;

  // Basic file exists check.
  if ($errors = !file_exists($magic_file)) {
    $msg = t("The path %path does not exist or is not readable by your webserver.", [
      '%path' => $magic_file,
    ]);
  }
  elseif ($errors = filetype($magic_file) != 'file' || !@filesize($magic_file)) {
    $msg = t("Could not load the magic file %path.", [
      '%path' => $magic_file,
    ]);
  }
  return !$errors;
}