private static function _mime_magic(
		string $fname, string $path_to_file=null
	) {
		# with builtin
		if (
			function_exists('mime_content_type') &&
			($mime = @mime_content_type($fname)) &&
			$mime != 'application/octet-stream'
		)
			return $mime;

		# with `file`, skip coverage because `file` is usually
		# not available on CI
		// @codeCoverageIgnoreStart
		if ($path_to_file && is_executable($path_to_file)) {
			$bin = $path_to_file;
		} elseif (!($bin = self::exec("bash -c 'type -p file'")[0])) {
			return 'application/octet-stream';
		}

		if (
			($mimes = self::exec('%s -bip %s', [$bin, $fname])) &&
			preg_match('!^[a-z0-9\-]+/!i', $mimes[0])
		)
			return $mimes[0];

		# giving up
		return 'application/octet-stream';
		// @codeCoverageIgnoreEnd
	}