odbcEngineCachedLibraryPath function
Hook cache path for the current host (x64 Windows/Linux only).
Implementation
@visibleForTesting
String? odbcEngineCachedLibraryPath({
required String libName,
String? packageRoot,
Map<String, String>? environment,
}) {
final env = environment ?? Platform.environment;
final home = env['HOME'] ?? env['USERPROFILE'];
if (home == null) {
return null;
}
final version = packageRoot == null ? null : _versionFromPubspec(packageRoot);
final cacheBase = version == null || version.isEmpty
? '$home${Platform.pathSeparator}.cache${Platform.pathSeparator}'
'odbc_fast'
: '$home${Platform.pathSeparator}.cache${Platform.pathSeparator}'
'odbc_fast${Platform.pathSeparator}$version';
final platformDir = Platform.isWindows
? 'windows_x64'
: Platform.isLinux
? 'linux_x64'
: null;
if (platformDir == null) {
return null;
}
final cached = File(
'$cacheBase${Platform.pathSeparator}$platformDir'
'${Platform.pathSeparator}$libName',
);
if (!cached.existsSync()) {
return null;
}
return cached.absolute.path;
}