Пример #1
0
        public FilePatchInfo(FileVersion.FilePatchInfo info)
        {
            path         = info.path;
            group        = info.group;
            firstVersion = info.firstVersion;
            lastVersion  = info.lastVersion;
            content_size = info.content_size;
            content_hash = info.content_hash;
            zip_size     = info.zip_size;
            zip_hash     = info.zip_hash;

            fileUrl   = Path.GetFileNameWithoutExtension(path) + ".txt";
            fileLocal = Access.PersistentDataPatchPath + fileUrl.Replace("/", "-");
        }
Пример #2
0
        /// <summary>
        /// 最后一步形成补丁列表
        /// </summary>
        protected void UpdatePathList()
        {
            var array = Directory.GetFileSystemEntries(Environment.CurrentDirectory.Replace("\\", "/") + "/" + SaveDir,
                                                       "*-*-*-*");

            if (array.Length == 0)
            {
                return;
            }
            var dic = array.ToLookup(Path.GetFileNameWithoutExtension)
                      .ToDictionary(p => p.Key, q => new List <string>(q));

            if (dic.Count == 0)
            {
                return;
            }
            List <FilePatchInfo> svnPatchInfos = new List <FilePatchInfo>();

            bool yes = SystemConsole.ContinueY("是否对文件进行加密(y/n),然后回车:");

            foreach (KeyValuePair <string, List <string> > pair in dic)
            {
                FilePatchInfo filePatchInfo = new FilePatchInfo();
                svnPatchInfos.Add(filePatchInfo);
                filePatchInfo.path = pair.Key;

                var txt = pair.Value.FirstOrDefault(p => p.EndsWith(".txt"));
                var zip = pair.Value.FirstOrDefault(p => p.EndsWith(".zip"));

                if (txt != null && File.Exists(txt))
                {
                    filePatchInfo.content_hash = GetMD5(File.ReadAllBytes(txt));
                    filePatchInfo.content_size = new FileInfo(txt).Length;
                    if (yes)
                    {
                        EncryptFile(txt);
                    }
                    filePatchInfo.encrypt_hash = GetMD5(File.ReadAllBytes(txt));
                    filePatchInfo.encrypt_size = new FileInfo(txt).Length;
                }

                if (zip != null && File.Exists(zip))
                {
                    filePatchInfo.zip_hash = GetMD5(File.ReadAllBytes(zip));
                    filePatchInfo.zip_size = new FileInfo(zip).Length;
                }

                var xx = pair.Key.Split('-');
                filePatchInfo.group        = xx.First();
                filePatchInfo.firstVersion = xx.Skip(1).First().AsInt();
                filePatchInfo.lastVersion  = xx.Skip(2).First().AsInt();
            }

            WriteToTxt(Name, new VersionInfo()
            {
                softwareVersion = softwareVersion,
                pathInfos       = svnPatchInfos.OrderBy(p => p.group).ThenBy(p => p.firstVersion).ToList()
            });
            if (yes)
            {
                EncryptFile(Name);
            }
        }