Ejemplo n.º 1
0
        private void EndReadBytes(byte[] data, object obj)
        {
            if (data == null)
            {
                SetOver();
                return;
            }

            MemoryStream ms = new MemoryStream(data);

            relationFile = RelationFile.Deserialize(ms);
            if (relationFile != null)
            {
                CoroutineHelper.CreateCoroutineHelper(LoadAsset(relationFile));
            }
            else
            {
                SetOver();
            }
        }
Ejemplo n.º 2
0
        private void Collect(string root)
        {
            string[] paths = Directory.GetFiles(root);
            if (paths != null)
            {
                string fileName = null;
                for (int i = 0, count = paths.Length; i < count; i++)
                {
                    fileName = Path.GetFileName(paths[i]);
                    if (files.ContainsKey(fileName))
                    {
                        Debug.LogError("duplicate files->" + files[fileName] + "^" + paths[i]);
                        continue;
                    }

                    if (fileName == null || fileName == "")
                    {
                        continue;
                    }

                    string path   = paths[i];
                    string suffix = Path.GetExtension(path);
                    if (suffix == ".cf")
                    {
                        RelationData rd = new RelationData();
                        rd.origin   = fileName;
                        rd.dest     = fileName;
                        rd.path     = path;
                        rd.encrypt  = false;
                        rd.fileType = VersionFile.Type.COMBINE_FILE;

                        files.Add(fileName, rd);

                        CombineFile   cf  = new CombineFile(fileName);
                        List <string> lst = new List <string>();
                        cf.CollectAllFilePath(lst);
                        for (int a = 0, acount = lst.Count; a < acount; a++)
                        {
                            files.Add(lst[a], rd);
                        }
                    }
                    else if (suffix == ".rf")
                    {
                        RelationData rd = new RelationData();
                        rd.origin   = fileName;
                        rd.dest     = fileName;
                        rd.path     = path;
                        rd.encrypt  = false;
                        rd.fileType = VersionFile.Type.RELATION_FILE;

                        files.Add(fileName, rd);

                        using (FileStream fs = File.OpenRead(path))
                        {
                            var rf = RelationFile.Deserialize(fs);
                            files.Add(rf.Name, rd);
                        }
                    }
                    else
                    {
                        RelationData rd = new RelationData();
                        rd.origin   = fileName;
                        rd.dest     = fileName;
                        rd.path     = path;
                        rd.encrypt  = false;
                        rd.fileType = VersionFile.Type.DEFAULT;

                        files.Add(fileName, rd);
                    }
                }
            }

            string[] dirs = Directory.GetDirectories(root);
            if (dirs != null)
            {
                for (int i = 0, count = dirs.Length; i < count; i++)
                {
                    Collect(dirs[i]);
                }
            }
        }