Ejemplo n.º 1
0
        public bool CheckAndFilterResourceFile(ResourceFileList resourceFileListHost, string projResourcePath)
        {
            Debug.Log("===>CheckAndFilterResourceFile:\nPath:" + projResourcePath);
            var folder = new DirectoryInfo(projResourcePath);

            FileSystemInfo[] fileInfos = folder.GetFileSystemInfos();

            foreach (var fileHost in resourceFileListHost.resourceFileList)
            {
                if (fileHost.name == "ResourceFileList.json")
                {
                    continue;
                }
                var counter = 0;
                Debug.Log("File length: " + fileHost.length);
                foreach (var fileInfo in fileInfos)
                {
                    if (fileHost.name == fileInfo.Name)
                    {
                        Debug.Log("Local resource name: " + fileInfo.Name);
                        //check md5
                        var localFileMd5 = IOHelperUtil.GetFileMD5(fileInfo.FullName);
                        if (fileHost.md5 != localFileMd5)
                        {
                            Debug.Log(string.Format("HostMd5: {0}\nLocalMd5: {1}", fileHost.md5, localFileMd5));
                            _willLoadList.Add(fileHost);
                            _totalBytesLength += long.Parse(fileHost.length);
                        }
                    }
                    else
                    {
                        counter += 1;
                    }
                }

                if (counter >= fileInfos.Length)
                {
                    _willLoadList.Add(fileHost);
                    _totalBytesLength += long.Parse(fileHost.length);
                }
            }

            return(_willLoadList.Count > 0);
        }
Ejemplo n.º 2
0
        public static void CreateResourceFileList <T>(string inputPath) where T : ResourceFile, new()
        {
            Debug.Log("JsonFrom: " + inputPath);
            var folder = new DirectoryInfo(inputPath);

            FileSystemInfo[] fileInfos = folder.GetFileSystemInfos();

            var bundleFileList = new ResourceFileList <T>();

            foreach (var fileInfo in fileInfos)
            {
                if (fileInfo.Name.EndsWith(".meta") || fileInfo.Name.EndsWith(".manifest"))
                {
                    continue;
                }
                T bundleFile = new T();
                bundleFile.name   = fileInfo.Name;
                bundleFile.md5    = IOHelperUtil.GetFileMD5(fileInfo.FullName);
                bundleFile.length = ((FileInfo)fileInfo).Length.ToString();

                bundleFileList.resourceFileList.Add(bundleFile);
            }
            IOHelperUtil.SaveToJson <ResourceFileList>(bundleFileList, inputPath);
        }
Ejemplo n.º 3
0
        public void loadConfig()
        {
            {
                XmlDocument xd = new XmlDocument();
                xd.Load(Path.Combine(Application.StartupPath, "config/channelList.xml"));

                XmlNodeList xnList = xd.SelectNodes("config/channelList/channel");

                ChannelList.Clear();
                foreach (XmlNode xn in xnList)
                {
                    ChannelItem item = new ChannelItem();
                    item.ChannelName = xn.SelectSingleNode("channelName").InnerText;
                    item.ChannelId   = xn.SelectSingleNode("channelId").InnerText;
                    ChannelList.Add(item);
                }
            }

            {
                XmlDocument xd = new XmlDocument();
                xd.Load(Path.Combine(Application.StartupPath, "config/packageList.xml"));

                XmlNodeList xnList = xd.SelectNodes("config/packageList/package");
                PackageList.Clear();
                foreach (XmlNode xn in xnList)
                {
                    PackageItem item = new PackageItem();
                    item.Title               = xn.SelectSingleNode("pkgTitle").InnerText;
                    item.PackageName         = xn.SelectSingleNode("pkgName").InnerText;
                    item.AppName             = xn.SelectSingleNode("AppName").InnerText;
                    item.ResourceDelete      = xn.SelectSingleNode("ResourceDelete").InnerText;
                    item.ResourceEncrypt     = xn.SelectSingleNode("ResourceEncrypt").InnerText;
                    item.ResourceNormal      = xn.SelectSingleNode("ResourceNormal").InnerText;
                    item.WinPhoneDescription = xn.SelectSingleNode("WinPhoneDescription").InnerText;
                    item.WinPhoneProductID   = xn.SelectSingleNode("WinPhoneProductID").InnerText;

                    XmlNodeList metaDataList = xn.SelectNodes("metaData/item");
                    foreach (XmlNode metaData in metaDataList)
                    {
                        string k = metaData.Attributes["name"].Value;
                        string v = metaData.Attributes["value"].Value;
                        item.MetaData.Add(k, v);
                    }

                    PackageList.Add(item);
                }
            }


            {
                XmlDocument xd = new XmlDocument();
                xd.Load(Path.Combine(Application.StartupPath, "config/enableList.xml"));

                XmlNodeList xnList = xd.SelectNodes("config/enableList/item");
                foreach (XmlNode xn in xnList)
                {
                    switch (xn.Attributes["name"].Value)
                    {
                    case "EnableMM":
                        EnableMM = xn.Attributes["value"].Value.Equals("true");
                        break;

                    case "EnableCopyFile":
                        EnableCopyFile = xn.Attributes["value"].Value.Equals("true");
                        break;

                    case "DeleteTemp":
                        DeleteTemp = xn.Attributes["value"].Value.Equals("true");
                        break;

                    default:
                        break;
                    }
                }

                xnList = xd.SelectNodes("config/encryptConfig/item");
                foreach (XmlNode xn in xnList)
                {
                    switch (xn.Attributes["name"].Value)
                    {
                    case "AllExts":
                    {
                        EncryptCfg.AllExts.Clear();
                        string   attrValue = xn.Attributes["value"].Value;
                        string[] strArr    = attrValue.Split(';');
                        foreach (string item in strArr)
                        {
                            EncryptCfg.AllExts.Add("." + item);
                        }
                    }
                    break;

                    case "PartExts":
                    {
                        EncryptCfg.PartExts.Clear();
                        string   attrValue = xn.Attributes["value"].Value;
                        string[] strArr    = attrValue.Split(';');
                        foreach (string item in strArr)
                        {
                            EncryptCfg.PartExts.Add("." + item);
                        }
                    }
                    break;

                    case "PartLength":
                        EncryptCfg.PartLength = Convert.ToInt32(xn.Attributes["value"].Value);
                        break;

                    default:
                        break;
                    }
                }


                CopyFileList.Clear();
                xnList = xd.SelectNodes("config/copyFileList/item");
                foreach (XmlNode xn in xnList)
                {
                    CopyFileList.Add(xn.Attributes["name"].Value);
                }

                ResourceFileList.Clear();
                xnList = xd.SelectNodes("config/resourceFileList/item");
                foreach (XmlNode xn in xnList)
                {
                    ResourceFileList.Add(xn.Attributes["name"].Value);
                }

                WinPhoneFileList.Clear();
                xnList = xd.SelectNodes("config/winPhoneFileList/item");
                foreach (XmlNode xn in xnList)
                {
                    WinPhoneFileList.Add(xn.Attributes["name"].Value);
                }
            }
        }