Ejemplo n.º 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.Close();
                }
                if (inpB != null)
                {
                    inpB.Close();
                }
            }

            return(matches);
        }
Ejemplo n.º 2
0
 private void CheckAllDirectoryContents(DirectoryEntry dir)
 {
     IEnumerator<Entry> it = dir.Entries;
     //foreach (Entry entry in dir)
     while (it.MoveNext())
     {
         Entry entry = it.Current;
         if (entry is DirectoryEntry)
         {
             CheckAllDirectoryContents((DirectoryEntry)entry);
         }
         else
         {
             DocumentNode doc = (DocumentNode)entry;
             DocumentInputStream dis = new DocumentInputStream(doc);
             try
             {
                 int numBytes = dis.Available();
                 byte[] data = new byte[numBytes];
                 dis.Read(data);
             }
             finally
             {
                 dis.Close();
             }
         }
     }
 }
Ejemplo n.º 3
0
 public override int Read()
 {
     return(delegate1.Read());
 }
Ejemplo n.º 4
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.Close();
                if (inpB != null) inpB.Close();
            }

            return matches;
        }