Exemple #1
0
        public static MD5Lib AddToDictionary(MD5Lib md5, string[] files, string[] dirs, int length, FilesInfo path, ref float progressStat)
        {
            float counter = 0;

            try
            {
                foreach (string filename in files)
                {
                    string file = filename.Substring(length).ToString().Replace(@"\", "/");
                    path.FilePath = filename.ToString().Replace(@"\", "/");
                    path.FileMD5  = FileHelper.FindMD5(filename);
                    md5.Files.Add(file, path);
                    progressStat = counter / files.Length;
                    counter++;
                }

                foreach (string dir in dirs)
                {
                    string subdir = dir.Substring(length).ToString().Replace(@"\", "/");
                    path.FilePath = dir.ToString().Replace(@"\", "/");
                    path.FileMD5  = "";
                    md5.Files.Add(subdir, path);
                }
            }
            catch (Exception ex)
            {
                Debug.Log(ex.Message);
            }
            return(md5);
        }
Exemple #2
0
        public static PatchInfo DictionaryCompare(MD5Lib lib1, MD5Lib lib2, string version, string path_OldStandAlone)
        {
            PatchInfo patch = new PatchInfo
            {
                patchversion = version
            };

            foreach (KeyValuePair <string, FilesInfo> item in lib2.Files)
            {
                if (lib1.Files.ContainsKey(item.Key) && item.Value.FileMD5 != lib1.Files[item.Key].FileMD5)
                {
                    patch.filesToReplace.Add(item.Value.FilePath, lib1.Files[item.Key].FilePath);
                }
            }

            IEnumerable <string> intersection = lib1.Files.Keys.Except(lib2.Files.Keys);

            IterateDifferenceBetweenDictionaries(intersection, lib1, "", patch.filesToDelete);

            IEnumerable <string> inter = lib2.Files.Keys.Except(lib1.Files.Keys);

            IterateDifferenceBetweenDictionaries(inter, lib2, path_OldStandAlone, patch.filesToReplace);

            return(patch);
        }
Exemple #3
0
        public static PatchInfo DifferAllFiles(string[] files1, string[] files2, string[] dir1, string[] dir2, string version,
                                               string path_OldStandAlone, string path_NewStandAlone, ref float progressStat)
        {
            MD5Lib    md5_1    = new MD5Lib();
            MD5Lib    md5_2    = new MD5Lib();
            FilesInfo md_path1 = new FilesInfo();
            FilesInfo md_path2 = new FilesInfo();

            md5_1 = AddToDictionary(md5_1, files1, dir1, path_OldStandAlone.Length, md_path1, ref progressStat);
            md5_2 = AddToDictionary(md5_2, files2, dir2, path_NewStandAlone.Length, md_path2, ref progressStat);
            return(DictionaryCompare(md5_1, md5_2, version, path_OldStandAlone));
        }
Exemple #4
0
 private static void IterateDifferenceBetweenDictionaries(IEnumerable <string> enumerable, MD5Lib files, string path, Dictionary <string, string> where)
 {
     foreach (string item in enumerable)
     {
         where.Add(files.Files[item].FilePath, path + item);
     }
 }