Improve file existence check and copying methods, optimize command execution logic, and fix KPM version display issue (#298)
* fix: Remove the incorrect display of the KPM version and simplify the checking logic * refactor: Optimize the command execution logic and simplify the code structure. * fix: Improve the file existence check and file copying methods.
This commit is contained in:
@@ -19,10 +19,12 @@ public class UltraShellHelper {
|
||||
}
|
||||
|
||||
public static boolean isPathExists(String path) {
|
||||
return runCmd("file " + path).contains("No such file or directory");
|
||||
String result = runCmd("test -f '" + path + "' && echo 'exists'");
|
||||
return result.contains("exists");
|
||||
}
|
||||
|
||||
public static void CopyFileTo(String path, String target) {
|
||||
runCmd("cp -f " + path + " " + target);
|
||||
public static boolean CopyFileTo(String path, String target) {
|
||||
String result = runCmd("cp -f '" + path + "' '" + target + "' 2>&1");
|
||||
return !result.contains("cp: ");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user