예제 #1
0
파일: IrosArc.cs 프로젝트: professorlust/7h
 public static void Create(IrosArc original, IrosArc updated, System.IO.Stream patchOutput, CompressType compress, Action<double, string> onProgress) {
     string[] deleted = original.AllFileNames()
         .Except(updated.AllFileNames(), StringComparer.InvariantCultureIgnoreCase)
         .ToArray();
     List<IrosArc.ArchiveCreateEntry> pentries = new List<IrosArc.ArchiveCreateEntry>();
     if (deleted.Any()) {
         onProgress(0, "Adding deleted entries");
         byte[] deldata = System.Text.Encoding.Unicode.GetBytes(String.Join("\n", deleted));
         pentries.Add(new IrosArc.ArchiveCreateEntry() {
             Filename = "%IrosPatch:Deleted",
             GetData = () => deldata
         });
     }
     foreach (string newFile in updated.AllFileNames().Except(original.AllFileNames(), StringComparer.InvariantCultureIgnoreCase)) {
         onProgress(0, "Adding new entries");
         string fn = newFile;
         pentries.Add(new IrosArc.ArchiveCreateEntry() {
             Filename = fn,
             GetData = () => updated.GetBytes(fn)
         });
     }
     foreach (string check in original.AllFileNames().Intersect(updated.AllFileNames())) {
         onProgress(0, "Checking " + check);
         if (!Same(original.GetBytes(check), updated.GetBytes(check))) {
             string fn = check;
             pentries.Add(new IrosArc.ArchiveCreateEntry() {
                 Filename = fn,
                 GetData = () => updated.GetBytes(fn)
             });
         }
     }
     IrosArc.Create(patchOutput, pentries, ArchiveFlags.Patch, compress, onProgress);
 }