copydyliptoSysTempath static method
Future<void>
copydyliptoSysTempath(
)
Implementation
static Future<void> copydyliptoSysTempath() async {
String macosexePath = Platform.resolvedExecutable;
var pathArr = macosexePath.split(Platform.isMacOS ? '/' : '\\');
var dirpath = pathArr.sublist(0, pathArr.length - 1).join(Platform.isMacOS ? '/' : '\\');
String pp = getDylibPath();
String name = Tools.getDyLibNameByPlatform(isOrigin: true).first;
if (Platform.isMacOS) {
String runPath = normalize(join(dirpath, '../Frameworks/'));
String distFullpath = join(runPath, name);
if ((File(distFullpath).existsSync())) {
print("$distFullpath exits . return.");
return;
}
String res = await shell.startAndReadAsString('cp', arguments: [
"-f",
pp,
runPath,
]);
String log = "exec cmd 'cp -f $pp $runPath'. and the response ${res.isEmpty ? "success" : res}.";
print(log);
} else if (Platform.isWindows) {
String sysDir = "C:\\Windows\\System32\\";
String distFullpath = join(dirpath, name);
bool inappext = File(distFullpath).existsSync();
if (inappext) {
print("$distFullpath exits .");
}
String winSYsFullPath = normalize(join(sysDir, name));
bool inSys = File(winSYsFullPath).existsSync();
if (inSys) {
print("$winSYsFullPath exits .");
}
if (!inappext) {
WrappedProcess res = await shell.start('copy', arguments: [
"/y",
pp,
dirpath,
]);
String log = "exec cmd 'copy $pp $dirpath'. and the response is ${await res.exitCode}.";
print(log);
}
// windows额外拷贝一份到系统目录兜底
if (!inSys) {
WrappedProcess resSys = await shell.start('copy', arguments: [
"/y",
pp,
sysDir,
]);
String logsys = "exec cmd 'copy $pp $sysDir'. and the response is ${await resSys.exitCode}.";
print(logsys);
} else {}
}
}