Commit 05950917 authored by fallenstardust's avatar fallenstardust

仅当原路径确实存在文件才复制

parent f4eb6a5a
...@@ -280,9 +280,12 @@ public class MainActivity extends HomeActivity { ...@@ -280,9 +280,12 @@ public class MainActivity extends HomeActivity {
AppsSettings.get().getSoundPath(), false); AppsSettings.get().getSoundPath(), false);
//复制原目录文件 //复制原目录文件
FileUtils.copyDir(ORI_DECK, AppsSettings.get().getDeckDir(), false); if (new File(ORI_DECK).list() != null)
FileUtils.copyDir(ORI_REPLAY, AppsSettings.get().getResourcePath() + "/" + Constants.CORE_REPLAY_PATH, false); FileUtils.copyDir(ORI_DECK, AppsSettings.get().getDeckDir(), false);
FileUtils.copyDir(ORI_PICS, AppsSettings.get().getCardImagePath(), false); if (new File(ORI_REPLAY).list() != null)
FileUtils.copyDir(ORI_REPLAY, AppsSettings.get().getResourcePath() + "/" + Constants.CORE_REPLAY_PATH, false);
if (new File(ORI_PICS).list() != null)
FileUtils.copyDir(ORI_PICS, AppsSettings.get().getCardImagePath(), false);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
Log.e("MainActivity", "错误" + e); Log.e("MainActivity", "错误" + e);
......
...@@ -6,12 +6,9 @@ import android.content.res.AssetManager; ...@@ -6,12 +6,9 @@ import android.content.res.AssetManager;
import android.os.Build; import android.os.Build;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.widget.Toast;
import java.io.Closeable; import java.io.Closeable;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
...@@ -125,7 +122,6 @@ public class IOUtils { ...@@ -125,7 +122,6 @@ public class IOUtils {
try { try {
inputStream = am.open(assets); inputStream = am.open(assets);
} catch (Exception e) { } catch (Exception e) {
Toast.makeText(context, "copyFilesFromAssets error" + e, Toast.LENGTH_SHORT).show();
} }
if (inputStream != null) { if (inputStream != null) {
copyToFile(inputStream, tofile.getAbsolutePath()); copyToFile(inputStream, tofile.getAbsolutePath());
......
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