getSharedLibLocation static method

Future<String> getSharedLibLocation()

Implementation

static Future<String> getSharedLibLocation() async {
  var march = Process.runSync("uname", ["-m"]).stdout.trim();
  var uri = await Isolate.resolvePackageUri(
      Uri.parse('package:l2ethernet/$march/$soName'));
  if (uri != null) return uri.path;

  var binPath = Platform.resolvedExecutable;
  var soPath =
      '${path.dirname(binPath)}${path.separator}lib${path.separator}$march${path.separator}$soName';
  if (FileStat.statSync(soPath).type == FileSystemEntityType.file)
    return soPath;

  soPath = '/usr/local/lib/$soName';
  if (FileStat.statSync(soPath).type == FileSystemEntityType.file)
    return soPath;

  // if (uri == null) {
  //   print('uri is null');
  // } else {
  //   print('uri=${uri.path}');
  // }
  throw FormatException("Cannot find file libeth.so");
}