Пример #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void verifyFilesHaveSameContent(org.neo4j.io.fs.FileSystemAbstraction fileSystem, java.io.File original, java.io.File other) throws java.io.IOException
        public static void VerifyFilesHaveSameContent(FileSystemAbstraction fileSystem, File original, File other)
        {
            const int bufferBatchSize = 32 * 1024;

            File[] files = fileSystem.ListFiles(original);
            foreach (File originalFile in files)
            {
                File otherFile = new File(other, originalFile.Name);
                if (!fileSystem.IsDirectory(originalFile))
                {
                    using (StoreChannel originalChannel = fileSystem.Open(originalFile, OpenMode.READ), StoreChannel otherChannel = fileSystem.Open(otherFile, OpenMode.READ))
                    {
                        ByteBuffer buffer = ByteBuffer.allocate(bufferBatchSize);
                        while (true)
                        {
                            if (!readAndFlip(originalChannel, buffer, bufferBatchSize))
                            {
                                break;
                            }
                            sbyte[] originalBytes = new sbyte[buffer.limit()];
                            buffer.get(originalBytes);

                            if (!readAndFlip(otherChannel, buffer, bufferBatchSize))
                            {
                                fail("Files have different sizes");
                            }

                            sbyte[] otherBytes = new sbyte[buffer.limit()];
                            buffer.get(otherBytes);

                            assertArrayEquals("Different content in " + originalFile, originalBytes, otherBytes);
                        }
                    }
                }
            }
        }
 public override bool IsDirectory(File file)
 {
     return(@delegate.IsDirectory(file));
 }