/// <summary> /// Check hash mods /// </summary> /// <param name="folder"></param> /// <param name="isSteam"></param> /// <returns></returns> private static void generateHashFiles(List <ModelFileInfo> result, ref string rootFolder, string folder, bool level0 = false) { if (!level0) { var dirs = Directory.GetDirectories(folder); foreach (var subDir in dirs) { generateHashFiles(result, ref rootFolder, subDir); } } var files = Directory.GetFiles(folder); int fileNamePos = rootFolder.Length + 1; var computeHash = new FastComputeHash(); foreach (var file in files.Where(x => ApproveExt(x))) { var mfi = new ModelFileInfo() { FileName = file.Substring(fileNamePos) }; GetCheckSum(mfi, file, computeHash); #if DEBUG /* * if (mfi.FileName.Contains("armony")) * { * Loger.Log($"generateHashFiles Harmony: {FileName} {Hash}"); * }*/ #endif result.Add(mfi); } computeHash.Wait(); }
public static void ReHashFiles(List <ModelFileInfo> rep, string folder, List <string> fileNames) { var dir = rep.ToDictionary(f => f.FileName); var computeHash = new FastComputeHash(); foreach (var fileName in fileNames) { ModelFileInfo mfi; if (!dir.TryGetValue(fileName, out mfi)) { mfi = new ModelFileInfo() { FileName = fileName, }; rep.Add(mfi); } var file = Path.Combine(folder, fileName); var oldHash = mfi.Hash; //if (MainHelper.DebugMode) Loger.Log($"ReHashFile b {file} {(oldHash == null ? "" : Convert.ToBase64String(oldHash))}" + $"->{(mfi.Hash == null ? "" : Convert.ToBase64String(mfi.Hash))}"); GetCheckSum(mfi, file, computeHash); //if (MainHelper.DebugMode) Loger.Log($"ReHashFile e {file} {(oldHash == null ? "" : Convert.ToBase64String(oldHash))}" + $"->{(mfi.Hash == null ? "" : Convert.ToBase64String(mfi.Hash))}"); } computeHash.Wait(); for (int i = 0; i < rep.Count; i++) { if (rep[i].Hash == null) { rep.RemoveAt(i--); } } computeHash.Wait(); }