/// <summary> /// Function that checks for existant files that hasnt been detected by reading Fhsks file it because they are new. /// </summary> /// <param name="lfs">Pre-computed LoadedFileStatus list</param> /// <param name="currentDD">Specific DirectoryData to correct.</param> public static void AddNewFiles(List <LoadedFileStatus> lfs, DirectoryData currentDD) { string[] files = Directory.GetFiles(currentDD.RootPath, "*", SearchOption.AllDirectories); for (int i = 0; i < files.Length; i++) { string buff = files[i].Replace(currentDD.RootPath, ""); if (!currentDD.CheckFileExistanceByRelativePath(buff)) { currentDD.AddFileData(files[i]); lfs.Add(LoadedFileStatus.NotTouched); } } }
/// <summary> /// Function that forms a SyncData list that represents the list of conflict statements which says if the file does exist in any of the directories or /// if its old or if its up to date. /// </summary> /// <param name="SourceData">The directory being synchronized.</param> /// <param name="TargetData">The comparing directory to be synchronized with.</param> /// <returns>SyncData list that represents the list of conflict statements which says if the file does exist in any of the directories or /// if its old or if its up to date.</returns> public static List <SyncData> FormConflictFileDataList(DirectoryData SourceData, DirectoryData TargetData) { List <SyncData> result = new List <SyncData>(); foreach (var item in SourceData.Files) { if (TargetData.CheckFileExistanceByRelativePath(item.RelativePath)) { if (item.Hash == TargetData.FindFileGetFileHash(item.RelativePath)) { continue; } SyncConflictState currentItemSCS = CompareFileDateTimeToState(item, TargetData.FindFileGetFileData(item.RelativePath)); currentItemSCS |= CompareFileSizesToState(item, TargetData.FindFileGetFileData(item.RelativePath)); if (currentItemSCS != SyncConflictState.UpToDate) { result.Add(new SyncData(item, currentItemSCS)); } } else { result.Add(new SyncData(item, SyncConflictState.DoesntExistInTarget)); } } List <FileData> FilesNonExistantInSource = TargetData.Files.FindAll(x => SourceData.Files.FindIndex(y => y.RelativePath == x.RelativePath) == -1); for (int i = 0; i < FilesNonExistantInSource.Count; i++) { result.Add(new SyncData(FilesNonExistantInSource[i], SyncConflictState.DoesntExistInSource)); } return(result); }