Esempio n. 1
0
        public void AddChange(String verFileName)
        {
            WriteLine("Adding changes from {0}", verFileName);
            Stream      baseStream = new MemoryStream(_baseData);
            Stream      stream     = File.OpenRead(verFileName);
            BinaryDiff  diff       = new BinaryDiff();
            AddCopyList change     = diff.Execute(baseStream, stream);

            _changes.Add(change);
            stream.Close();
            baseStream.Close();
            WriteLine("Changes added successfully.  AddCopy byte length: {0}", change.TotalByteLength);
        }
Esempio n. 2
0
        private void GetFileLines(string strA, string strB, out Collection <string> A, out Collection <string> B)
        {
            if (this.isBinary)
            {
                using (FileStream AF = File.OpenRead(strA))
                    using (FileStream BF = File.OpenRead(strB))
                    {
                        BinaryDiff BDiff = new BinaryDiff();
                        BDiff.FootprintLength = 8;
                        AddCopyList List = BDiff.Execute(AF, BF);

                        BinaryDiffLines Lines = new BinaryDiffLines(AF, List, 8);
                        A = Lines.BaseLines;
                        B = Lines.VerLines;
                    }
            }
            else
            {
                A = Functions.GetFileTextLines(strA);
                B = Functions.GetFileTextLines(strB);
            }
        }
Esempio n. 3
0
        public void ExtractNewest(String fileName)
        {
            WriteLine("Extracting newest changes to {0}", fileName);
            // Just in case we add more than one revision; get the latest changeset.
            AddCopyList change   = LastChange;
            Stream      original = new MemoryStream(_baseData);
            Stream      newest   = File.OpenWrite(fileName);

            byte[] temp = null;

            // Shouldn't have to seek to the end of newest stream; since we
            // are just writing to it in sequence, it should always be at the end.
            foreach (object o in change)
            {
                if (o is Addition)
                {
                    Addition add = (Addition)o;
                    // Simply write the data to the newest stream.
                    newest.Write(add.arBytes, 0, add.arBytes.Length);
                }
                else if (o is Copy)
                {
                    Copy copy = (Copy)o;
                    // Seek to position in original stream and read the
                    // appropriate length, then write it to the newest stream.
                    original.Seek(copy.iBaseOffset, SeekOrigin.Begin);
                    temp = new byte[copy.iLength];
                    original.Read(temp, 0, temp.Length);
                    newest.Write(temp, 0, temp.Length);
                }
            }

            newest.Close();
            original.Close();
            WriteLine("Extracted changes successfully.");
        }