Commit 402e9d9a authored by fallenstardust's avatar fallenstardust

可选是否替换

parent d0381018
...@@ -249,10 +249,9 @@ public class MainActivity extends HomeActivity { ...@@ -249,10 +249,9 @@ public class MainActivity extends HomeActivity {
AppsSettings.get().getSoundPath(), false); AppsSettings.get().getSoundPath(), false);
//复制原目录文件 //复制原目录文件
FileUtils.copyDir(ORI_DECK, AppsSettings.get().getDeckDir()); FileUtils.copyDir(ORI_DECK, AppsSettings.get().getDeckDir(), false);
FileUtils.copyDir(ORI_REPLAY, AppsSettings.get().getResourcePath() + "/" + Constants.CORE_REPLAY_PATH); FileUtils.copyDir(ORI_REPLAY, AppsSettings.get().getResourcePath() + "/" + Constants.CORE_REPLAY_PATH, false);
FileUtils.copyDir(ORI_TEXTURES, AppsSettings.get().getCoreSkinPath()); FileUtils.copyDir(ORI_PICS, AppsSettings.get().getCardImagePath(), false);
FileUtils.copyDir(ORI_PICS, AppsSettings.get().getCardImagePath());
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
Log.e("MainActivity", "错误" + e); Log.e("MainActivity", "错误" + e);
......
...@@ -271,10 +271,10 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> { ...@@ -271,10 +271,10 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
IOUtils.copyFilesFromAssets(mContext, getDatapath(Constants.WINDBOT_PATH), IOUtils.copyFilesFromAssets(mContext, getDatapath(Constants.WINDBOT_PATH),
resPath, needsUpdate); resPath, needsUpdate);
//复制原目录文件 //复制原目录文件
FileUtils.copyDir(ORI_DECK, mSettings.getDeckDir()); FileUtils.copyDir(ORI_DECK, mSettings.getDeckDir(), false);
FileUtils.copyDir(ORI_REPLAY, resPath + "/" + Constants.CORE_REPLAY_PATH); FileUtils.copyDir(ORI_REPLAY, resPath + "/" + Constants.CORE_REPLAY_PATH, false);
FileUtils.copyDir(ORI_TEXTURES, mSettings.getCoreSkinPath()); FileUtils.copyDir(ORI_TEXTURES, mSettings.getCoreSkinPath(), true);
FileUtils.copyDir(ORI_PICS, mSettings.getCardImagePath()); FileUtils.copyDir(ORI_PICS, mSettings.getCardImagePath(), false);
han.sendEmptyMessage(0); han.sendEmptyMessage(0);
......
...@@ -170,8 +170,9 @@ public class FileUtils { ...@@ -170,8 +170,9 @@ public class FileUtils {
out.write(data, 0, len); out.write(data, 0, len);
} }
} }
//复制文件夹全部文件 //复制文件夹全部文件
public static void copyDir(String oldPath, String newPath) throws IOException { public static void copyDir(String oldPath, String newPath, boolean isReplaced) throws IOException {
File file = new File(oldPath); File file = new File(oldPath);
//文件名称列表 //文件名称列表
String[] filePath = file.list(); String[] filePath = file.list();
...@@ -182,11 +183,11 @@ public class FileUtils { ...@@ -182,11 +183,11 @@ public class FileUtils {
for (int i = 0; i < filePath.length; i++) { for (int i = 0; i < filePath.length; i++) {
if ((new File(oldPath + file.separator + filePath[i])).isDirectory()) { if ((new File(oldPath + file.separator + filePath[i])).isDirectory()) {
copyDir(oldPath + file.separator + filePath[i], newPath + file.separator + filePath[i]); copyDir(oldPath + file.separator + filePath[i], newPath + file.separator + filePath[i], false);
} }
if (new File(oldPath + file.separator + filePath[i]).isFile()) { if (new File(oldPath + file.separator + filePath[i]).isFile()) {
if (!(new File(newPath + file.separator + filePath[i]).exists())) if (!(new File(newPath + file.separator + filePath[i]).exists()) || isReplaced)
copyFile(oldPath + file.separator + filePath[i], newPath + file.separator + filePath[i], true); copyFile(oldPath + file.separator + filePath[i], newPath + file.separator + filePath[i], true);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment