Commit d55521a5 authored by fallenstardust's avatar fallenstardust

搬运原目录文件

parent 60ede78e
......@@ -8,7 +8,7 @@ android {
applicationId "cn.garymb.ygomobile"
minSdkVersion 21
targetSdkVersion 28
versionCode 370000408
versionCode 370000409
versionName "3.7.0"
flavorDimensions "versionCode"
vectorDrawables.useSupportLibrary = true
......
......@@ -210,13 +210,17 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
ConfigManager systemConf = DataManager.openConfig(mSettings.getSystemConfig());
systemConf.setFontSize(mSettings.getFontSize());
systemConf.close();
//原目录文件路径
String deck = Environment.getExternalStorageDirectory() + "/" + Constants.PREF_DEF_GAME_DIR + "/" + Constants.CORE_DECK_PATH;
String replay = Environment.getExternalStorageDirectory() + "/" + Constants.PREF_DEF_GAME_DIR + "/" + Constants.CORE_REPLAY_PATH;
String textures = Environment.getExternalStorageDirectory() + "/" + Constants.PREF_DEF_GAME_DIR + "/" + Constants.CORE_SKIN_PATH;
String pics = Environment.getExternalStorageDirectory() + "/" + Constants.PREF_DEF_GAME_DIR + "/" + Constants.CORE_IMAGE_PATH;
InputStream fisdeck = new FileInputStream(Environment.getExternalStorageDirectory() + "/" + Constants.PREF_DEF_GAME_DIR + "/" + Constants.CORE_DECK_PATH);
//如果是新版本
if (needsUpdate) {
//复制卡组
setMessage(mContext.getString(R.string.check_things, mContext.getString(R.string.tip_new_deck)));
IOUtils.copyToFile(fisdeck, mContext.getExternalFilesDir(Constants.CORE_DECK_PATH).getAbsolutePath());
IOUtils.copyFilesFromAssets(mContext, getDatapath(Constants.CORE_DECK_PATH),
mSettings.getDeckDir(), needsUpdate);
//复制卡包
......@@ -266,7 +270,14 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
}
//复制人机资源
IOUtils.copyFilesFromAssets(mContext, getDatapath(Constants.WINDBOT_PATH),
resPath, needsUpdate);//mContext.getFilesDir().getPath()
resPath, needsUpdate);
//复制原目录文件
FileUtils.copyDir(deck, mSettings.getDeckDir());
FileUtils.copyDir(replay, resPath + "/" + Constants.CORE_REPLAY_PATH);
FileUtils.copyDir(textures, mSettings.getCoreSkinPath());
FileUtils.copyDir(pics, mSettings.getCardImagePath());
han.sendEmptyMessage(0);
loadData();
......
......@@ -170,6 +170,28 @@ public class FileUtils {
out.write(data, 0, len);
}
}
//复制文件夹全部文件
public static void copyDir(String oldPath, String newPath) throws IOException {
File file = new File(oldPath);
//文件名称列表
String[] filePath = file.list();
if (!(new File(newPath)).exists()) {
(new File(newPath)).mkdir();
}
for (int i = 0; i < filePath.length; i++) {
if ((new File(oldPath + file.separator + filePath[i])).isDirectory()) {
copyDir(oldPath + file.separator + filePath[i], newPath + file.separator + filePath[i]);
}
if (new File(oldPath + file.separator + filePath[i]).isFile()) {
if (!(new File(newPath + file.separator + filePath[i]).exists()))
copyFile(oldPath + file.separator + filePath[i], newPath + file.separator + filePath[i], true);
}
}
}
//删除文件(String Path)
public static void delFile(String s) {
......
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