liuxue
2021-07-29 7e2df20ccc7cdfb528d309369460a4f3d66afdf1
SdkProject/library/src/main/java/com/secondworld/sdk/utils/FileUtil.java
@@ -2,7 +2,7 @@
import android.content.res.AssetManager;
import com.secondworld.sdk.GameApp;
import com.secondworld.sdk.GameAppProxy;
import com.secondworld.sdk.UnityMsgHandler;
import java.io.File;
@@ -33,14 +33,12 @@
        if (installVer == currentVer) {
            LogUtil.i("copyAssets", "已拷贝过,installVer:" + installVer + ";" + "currentVer:" + currentVer);
            Map<String, Object> _msg = new HashMap<>();
            _msg.put("code", CodeA2U.AssetCopyFinished);
            UnityMsgHandler.sendMessageToUnity(_msg);
            UnityMsgHandler.sendMessageToUnity(CodeA2U.AssetCopyFinished);
            return;
        }
        String _dest = GameApp.I.getExternalFilesDir("").getAbsolutePath();
        AssetManager _assetMgr = GameApp.I.getAssets();
        String _dest = GameAppProxy.app.getExternalFilesDir("").getAbsolutePath();
        AssetManager _assetMgr = GameAppProxy.app.getAssets();
        try {
            String[] _fileNames = _assetMgr.list("android");
            if (_fileNames != null) {
@@ -53,8 +51,7 @@
            // 存储此次的拷贝版本
            SPUtils.get().edit().putLong(SPUtils.LAST_COPY_VERSION, currentVer).apply();
            Map<String, Object> _msg = new HashMap<>();
            _msg.put("code", CodeA2U.AssetCopyFinished);
            UnityMsgHandler.sendMessageToUnity(_msg);
            UnityMsgHandler.sendMessageToUnity(CodeA2U.AssetCopyFinished);
        } catch (Exception e) {
            e.printStackTrace();
        }
@@ -67,7 +64,7 @@
     */
    public static void copyOneAsset(String fileName) {
        String originalPath = "android" + File.separator + fileName;
        String destPath = GameApp.I.getExternalFilesDir(
        String destPath = GameAppProxy.app.getExternalFilesDir(
                "").getAbsolutePath() + File.separator + fileName;
        String _destDir = destPath.substring(0, destPath.lastIndexOf('/') + 1);
        File _file = new File(_destDir);
@@ -75,7 +72,7 @@
            boolean mkdir = _file.mkdir();
        }
        try {
            InputStream _is = GameApp.I.getAssets().open(originalPath);
            InputStream _is = GameAppProxy.app.getAssets().open(originalPath);
            FileOutputStream _fos = new FileOutputStream(new File(destPath));
            byte[] _buffer = new byte[1024];
            int _byteCount;
@@ -92,7 +89,7 @@
    public static void copy(String original, String dest) {
        try {
            String[] fileNames = GameApp.I.getAssets().list(original);
            String[] fileNames = GameAppProxy.app.getAssets().list(original);
            if (fileNames.length > 0) {
                File dir = new File(dest);
                String mkdir = dir.mkdir() ? "成功" : "失败";
@@ -102,7 +99,7 @@
                            dest + File.separator + _fileName);
                }
            } else {
                InputStream _is = GameApp.I.getAssets().open(original);
                InputStream _is = GameAppProxy.app.getAssets().open(original);
                FileOutputStream _fos = new FileOutputStream(new File(dest));
                byte[] _buffer = new byte[1024];
                int _byteCount;