isProtocolHandlerCurrent function

Future<bool> isProtocolHandlerCurrent(
  1. String neomagePath
)

Check whether the OS-level protocol handler is current.

Implementation

Future<bool> isProtocolHandlerCurrent(String neomagePath) async {
  try {
    if (Platform.isMacOS) {
      final target = await Link(_macosSymlinkPath).target();
      return target == neomagePath;
    } else if (Platform.isLinux) {
      final content = await File(_linuxDesktopPath()).readAsString();
      return content.contains(_linuxExecLine(neomagePath));
    } else if (Platform.isWindows) {
      final result = await Process.run('reg', [
        'query',
        _windowsCommandKey,
        '/ve',
      ]);
      return result.exitCode == 0 &&
          (result.stdout as String).contains(
            _windowsCommandValue(neomagePath),
          );
    }
  } catch (_) {}
  return false;
}