Ejemplo n.º 1
0
        public static DataStreamTestCollaboratorSet CreateCollaboratorsForTestingDataStreamsOneGigabyteDrive()
        {
            var stream = new FileStream(@"e:\tests.vhd", FileMode.Create);

            var formatter = new VirtualDiskFormatter();

            VirtualDisk disk = VirtualDisk.CreateFormattingTheStream(stream, 2048, 2048 * 500000);

            var diskStructuresManager = new FileSystemNodeStorage(disk);

            formatter.Format(disk, diskStructuresManager);

            FileSystemHeader header = diskStructuresManager.ReadFileSystemHeader(VirtualDiskFormatter.FileSystemHeaderBlockIndex);

            var nameValidator = FileSystemArtifactNamesValidator.Default;

            var pathValidator = PathValidator.Default;

            var pathBuilder = PathBuilder.Default;

            var nodeResolver = new NodeResolver(disk, diskStructuresManager, StringComparer.OrdinalIgnoreCase, header.RootBlockOffset, VirtualFileSystem.Root, VirtualFileSystem.DirectorySeparatorChar, pathValidator, pathBuilder);

            var virtualFileSystem = VirtualFileSystem.CreateFromDisk(disk, StringComparer.OrdinalIgnoreCase, nodeResolver, pathBuilder, nameValidator, pathValidator);

            var fileNodeFake = virtualFileSystem.CreateFile(@"\hey");

            return(new DataStreamTestCollaboratorSet(disk, diskStructuresManager, fileNodeFake, virtualFileSystem));
        }
Ejemplo n.º 2
0
        internal static AllCollaborators CreateAllCollaborators(int numberOfBlocks, bool createTestFile)
        {
            var stream = new MemoryStream();
            // new FileStream(@"e:\" + Guid.NewGuid().ToString("N"), FileMode.Create);

            var formatter = new VirtualDiskFormatter();

            VirtualDisk disk = VirtualDisk.CreateFormattingTheStream(stream, VirtualDisk.OnlySupportedBlockSize, VirtualDisk.OnlySupportedBlockSize * numberOfBlocks);

            var diskStructuresManager = new FileSystemNodeStorage(disk);

            formatter.Format(disk, diskStructuresManager);

            FileSystemHeader header = diskStructuresManager.ReadFileSystemHeader(VirtualDiskFormatter.FileSystemHeaderBlockIndex);

            var nameValidator = FileSystemArtifactNamesValidator.Default;

            var pathValidator = PathValidator.Default;

            var pathBuilder = PathBuilder.Default;

            var nodeResolver = new NodeResolver(disk, diskStructuresManager, StringComparer.OrdinalIgnoreCase, header.RootBlockOffset, VirtualFileSystem.Root, VirtualFileSystem.DirectorySeparatorChar, pathValidator, pathBuilder);

            var virtualFileSystem = VirtualFileSystem.CreateFromDisk(disk, StringComparer.OrdinalIgnoreCase, nodeResolver, pathBuilder, nameValidator, pathValidator);

            FileInfo fileNodeFake = null;

            if (createTestFile)
            {
                fileNodeFake = virtualFileSystem.CreateFile(@"\hey");
            }

            return(new AllCollaborators(disk, diskStructuresManager, nameValidator, pathValidator, nodeResolver, virtualFileSystem, fileNodeFake, stream));
        }
Ejemplo n.º 3
0
        public void TryFormattingADiskAndInitializingFileSystemWithIt()
        {
            Stream stream = new MemoryStream(); // System.IO.File.Open(@"c:\bs.bin", FileMode.Create);

            var formatter = new VirtualDiskFormatter();

            VirtualDisk disk = VirtualDisk.CreateFormattingTheStream(stream, 2048, 2048 * 5000);

            var diskStructuresManager = new FileSystemNodeStorage(disk);

            formatter.Format(disk, diskStructuresManager);

            FileSystemHeader header = diskStructuresManager.ReadFileSystemHeader(VirtualDiskFormatter.FileSystemHeaderBlockIndex);

            var nameValidator = new FileSystemArtifactNamesValidator(Constants.IllegalCharactersForNames, Constants.FileAndFolderMaximumNameLength);

            var pathValidator = new PathValidator(VirtualFileSystem.Root, Constants.IllegalCharactersForPaths, nameValidator, VirtualFileSystem.DirectorySeparatorChar);

            var pathBuilder = PathBuilder.Default;

            var nodeResolver = new NodeResolver(disk, diskStructuresManager, StringComparer.OrdinalIgnoreCase, header.RootBlockOffset, VirtualFileSystem.Root, VirtualFileSystem.DirectorySeparatorChar, pathValidator, pathBuilder);

            VirtualFileSystem fileSystem = VirtualFileSystem.CreateFromDisk(disk, StringComparer.OrdinalIgnoreCase, nodeResolver, pathBuilder, nameValidator, pathValidator);

            Assert.AreEqual(2048, fileSystem.FileSystemInfo.BlockSizeInBytes);
            Assert.AreEqual(new Version(1, 0, 0, 0), fileSystem.FileSystemInfo.Version);
        }