Exemple #1
0
        /**
         * Checks to see if two Documents have the same name
         *  and the same contents. (Their parent directories are
         *  not checked)
         */
        public static bool AreDocumentsIdentical(DocumentEntry docA, DocumentEntry docB)
        {
            if (!docA.Name.Equals(docB.Name))
            {
                // Names don't match, not the same
                return(false);
            }
            if (docA.Size != docB.Size)
            {
                // Wrong sizes, can't have the same contents
                return(false);
            }

            bool matches = true;
            DocumentInputStream inpA = null, inpB = null;

            try
            {
                inpA = new DocumentInputStream(docA);
                inpB = new DocumentInputStream(docB);

                int readA, readB;
                do
                {
                    readA = inpA.Read();
                    readB = inpB.Read();
                    if (readA != readB)
                    {
                        matches = false;
                        break;
                    }
                } while (readA != -1 && readB != -1);
            }
            finally
            {
                if (inpA != null)
                {
                    inpA.Dispose();
                }
                if (inpB != null)
                {
                    inpB.Dispose();
                }
            }

            return(matches);
        }
Exemple #2
0
 public override int Read()
 {
     return(delegate1.Read());
 }