示例#1
0
        private void _GetLoadDetails(string origin, out string destName, out string path, out int size, out bool encrypt, out VersionFile.Type fileType)
        {
            destName = null;
            path     = null;
            size     = -1;
            encrypt  = false;
            fileType = VersionFile.Type.DEFAULT;

            if (Config.DirectlyLoadResource())
            {
                if (directlyLoadFiles == null)
                {
                    return;
                }

                directlyLoadFiles.GetRealPath(origin, out destName, out path, out encrypt, out fileType);
            }
            else
            {
                if (origin == null)
                {
                    return;
                }

                RelationData rd;
                if (!nameToRelation.TryGetValue(origin, out rd))
                {
                    Debugger.LogWarning("file not exist in version->" + origin);
                    return;
                }

                if (rd != null)
                {
                    lock (lock_getpath)
                    {
                        GameUtils.StringBuilderClear();
                        int fl = versionFileData.fileLocate[rd.index];
                        if (fl == (int)FileLocate.Download)
                        {
                            GameUtils.stringBuilder.Append(GetLocalAssetPath());
                        }
                        else
                        {
                            GameUtils.stringBuilder.Append(streamingAssetsPath);
                            GameUtils.stringBuilder.Append("/MeData/");
                        }

                        GameUtils.stringBuilder.Append(rd.guid);
                        path = GameUtils.stringBuilder.ToString();
                    }
                    destName = rd.origin;
                    size     = rd.size;
                    encrypt  = rd.encrypt;
                    fileType = rd.fileType;
                }
                //#if UNITY_EDITOR
                else
                {
                    Debugger.LogError("this path is not in versionInfo->" + origin);
                }
                //#endif //UNITY_EDITOR
            }
        }
示例#2
0
        public static void GetLoadDetails(string origin, out string destName, out string path, out int size, out bool encrypt, out VersionFile.Type fileType)
        {
            if (instance == null)
            {
                destName = null;
                path     = null;
                size     = -1;
                encrypt  = false;
                fileType = VersionFile.Type.DEFAULT;
                return;
            }

            instance._GetLoadDetails(origin, out destName, out path, out size, out encrypt, out fileType);
        }
示例#3
0
        private static void __AsynReadBytesByPath(string originName, string destName, string path, VersionFile.Type fileType, EndReadBytes endRead, System.Object obj, bool cb_whatever = false, bool needRemoveImpurity = true)
        {
            if (instance == null || instance.platformLoader == null)
            {
                return;
            }

            byte[] arr = null;
            if (fileType == VersionFile.Type.COMBINE_FILE)
            {
                CombineFile cf = CombineFileManager.GetInstance().GetCombineFile(destName);
                arr = cf.Read(originName);
            }
            else
            {
                arr = instance.platformLoader.SyncReadBytes(path);
            }

            if (arr != null)
            {
                if (needRemoveImpurity)
                {
                    ThreadTask.RunAsync(() =>
                    {
                        DataDecode(arr, arr.Length);
                    },
                                        () =>
                    {
                        if (endRead != null)
                        {
                            endRead(arr, obj);
                        }
                    });
                }
                else
                {
                    if (endRead != null)
                    {
                        endRead(arr, obj);
                    }
                }
            }
            else
            {
                if (cb_whatever)
                {
                    if (endRead != null)
                    {
                        endRead(arr, obj);
                    }
                }
            }
        }
示例#4
0
 public static void AsynReadBytesByPath(string path, VersionFile.Type fileType, EndReadBytes endRead, System.Object obj, bool cb_whatever = false, bool needRemoveImpurity = true)
 {
     __AsynReadBytesByPath(null, null, path, VersionFile.Type.DEFAULT, endRead, obj, cb_whatever, needRemoveImpurity);
 }
示例#5
0
        private static byte[] __SyncReadBytesByPath(string originName, string destName, string path, VersionFile.Type fileType, bool removeImpurity = true)
        {
            if (instance == null || instance.platformLoader == null)
            {
                return(null);
            }

            byte[] data = null;
            if (fileType == VersionFile.Type.COMBINE_FILE)
            {
                CombineFile cf = CombineFileManager.GetInstance().GetCombineFile(destName);
                data = cf.Read(originName);
            }
            else
            {
                data = instance.platformLoader.SyncReadBytes(path);
            }

            if (data != null)
            {
                if (removeImpurity)
                {
                    DataDecode(data, data.Length);
                }
            }

            return(data);
        }
示例#6
0
        public void GetRealPath(string fileName, out string destName, out string path, out bool encrypt, out VersionFile.Type fileType)
        {
            destName = null;
            path     = null;
            encrypt  = false;
            fileType = VersionFile.Type.DEFAULT;

            RelationData rd;

            if (files.TryGetValue(fileName, out rd))
            {
                destName = rd.dest;
                path     = rd.path;
                encrypt  = rd.encrypt;
                fileType = rd.fileType;
            }
        }