findDllPath static method

Future<String> findDllPath()

Finds the DLL in the current directory or its subdirectories

Implementation

static Future<String> findDllPath() async {
  // Get the package root directory
  final packageConfig = await findPackageConfig(Directory.current);
  final package = packageConfig?.packages
      .firstWhere((p) => p.name == 'argos_translator_offline');

  if (package == null) {
    throw Exception('Package not found!');
  }

  // Get the package directory
  final packageDir = Directory(package.root.path);
  String path = packageDir.path;
  if (path[0] == "/") {
    path = path.substring(1);
  }

  final dllPath = "${path}dlls/argos_bridge.dll".replaceAll("/", "\\");

  if (File(dllPath).existsSync()) {
    return dllPath;
  }

  throw Exception(
      'Could not find argos_bridge.dll in the dlls directory where $dllPath');
}