[英]Why RootTools cp command don't work?
I'm trying to make a copy of a file in the etc folder, for that I use the next code in a button: 我正在尝试在etc文件夹中制作文件的副本,为此我在按钮中使用了下一个代码:
changeNTP.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
File exists = new File("/etc/gps.conf");
if (exists.exists()) {
// We make a backup first
CommandCapture command = new CommandCapture(0, "cp -f /etc/gps.conf /etc/gps" + System.currentTimeMillis() + ".conf");
try {
RootTools.getShell(true).add(command);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RootDeniedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// Last time that file was modified
//Date filedate = new Date(exists.lastModified());
}
}
});
Well, the problem is that it doesn't copy anything. 好吧,问题在于它不会复制任何内容。 What could be the problem? 可能是什么问题呢?
Thanks. 谢谢。
Ok, the next is best solution: 好的,接下来是最好的解决方案:
int date = (int) System.currentTimeMillis();
String source = "/system/etc/gps.conf";
String destination = "/system/etc/gps" + date + ".conf";
if(RootTools.remount("/system/etc/", "rw")){
RootTools.copyFile(source, destination, true, true);
}
The problem is that previously I pointed to /etc, but this location is a symlink, the real path is /system/etc. 问题是以前我指的是/ etc,但是这个位置是一个符号链接,实际路径是/ system / etc。 Obviously we can't change mount type of a symlink, so, the previous code that I just have posted, is the good answer. 显然,我们无法更改符号链接的安装类型,因此,我刚刚发布的先前代码是不错的答案。
Thanks. 谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.