public FolderManager(FileSystemNodeStorage fileSystemNodeStorage, IEqualityComparer <string> namesComparer, NodeResolver nodeResolver, IFreeBlockManager freeBlockManager, IFolderEnumeratorRegistry folderEnumeratorRegistry, IFileSystemObjectLockingManager lockingManager, BlockReferenceListsEditor blockReferenceListsEditor, PathBuilder pathBuilder, IFileSystemArtifactNamesValidator nameValidator, IPathValidator pathValidator)
        {
            if (fileSystemNodeStorage == null)
            {
                throw new ArgumentNullException("fileSystemNodeStorage");
            }
            if (namesComparer == null)
            {
                throw new ArgumentNullException("namesComparer");
            }
            if (nodeResolver == null)
            {
                throw new ArgumentNullException("nodeResolver");
            }
            if (freeBlockManager == null)
            {
                throw new ArgumentNullException("freeBlockManager");
            }
            if (folderEnumeratorRegistry == null)
            {
                throw new ArgumentNullException("folderEnumeratorRegistry");
            }
            if (lockingManager == null)
            {
                throw new ArgumentNullException("lockingManager");
            }
            if (blockReferenceListsEditor == null)
            {
                throw new ArgumentNullException("blockReferenceListsEditor");
            }
            if (pathBuilder == null)
            {
                throw new ArgumentNullException("pathBuilder");
            }
            if (nameValidator == null)
            {
                throw new ArgumentNullException("nameValidator");
            }
            if (pathValidator == null)
            {
                throw new ArgumentNullException("pathValidator");
            }

            _fileSystemNodeStorage     = fileSystemNodeStorage;
            _pathValidator             = pathValidator;
            _nameValidator             = nameValidator;
            _pathBuilder               = pathBuilder;
            _blockReferenceListsEditor = blockReferenceListsEditor;
            _lockingManager            = lockingManager;
            _folderEnumeratorRegistry  = folderEnumeratorRegistry;
            _freeBlockManager          = freeBlockManager;
            _nodeResolver              = nodeResolver;
            _namesComparer             = namesComparer;
        }
Пример #2
0
        private VirtualFileSystem(
            IVirtualDisk virtualDisk,
            VirtualFileSystemInfo fileSystemInfo,
            FileSystemNodeStorage fileSystemNodeStorage,
            IEqualityComparer <string> namesComparer,
            NodeResolver nodeResolver,
            IFreeBlockManager freeBlockManager,
            IFolderEnumeratorRegistry folderEnumeratorRegistry,
            BlockReferenceListsEditor blockReferenceListsEditor,
            PathBuilder pathBuilder,
            IFileSystemArtifactNamesValidator nameValidator,
            IPathValidator pathValidator,
            FileManager fileManager,
            FolderManager folderManager)
        {
            if (fileSystemInfo == null)
            {
                throw new ArgumentNullException("fileSystemInfo");
            }
            if (fileSystemNodeStorage == null)
            {
                throw new ArgumentNullException("fileSystemNodeStorage");
            }
            if (namesComparer == null)
            {
                throw new ArgumentNullException("namesComparer");
            }
            if (nodeResolver == null)
            {
                throw new ArgumentNullException("nodeResolver");
            }
            if (freeBlockManager == null)
            {
                throw new ArgumentNullException("freeBlockManager");
            }
            if (folderEnumeratorRegistry == null)
            {
                throw new ArgumentNullException("folderEnumeratorRegistry");
            }
            if (blockReferenceListsEditor == null)
            {
                throw new ArgumentNullException("blockReferenceListsEditor");
            }
            if (pathBuilder == null)
            {
                throw new ArgumentNullException("pathBuilder");
            }
            if (nameValidator == null)
            {
                throw new ArgumentNullException("nameValidator");
            }
            if (pathValidator == null)
            {
                throw new ArgumentNullException("pathValidator");
            }
            if (folderManager == null)
            {
                throw new ArgumentNullException("folderManager");
            }

            _virtualDisk              = virtualDisk;
            _folderManager            = folderManager;
            _folderManager            = folderManager;
            _folderManager            = folderManager;
            _folderManager            = folderManager;
            _fileManager              = fileManager;
            _pathBuilder              = pathBuilder;
            _folderEnumeratorRegistry = folderEnumeratorRegistry;
            _nodeResolver             = nodeResolver;
            _freeBlockManager         = freeBlockManager;
            _fileSystemInfo           = fileSystemInfo;
            _namesComparer            = namesComparer;
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="disk"></param>
        /// <param name="namesComparer"></param>
        /// <param name="nodeResolver"></param>
        /// <param name="pathBuilder"></param>
        /// <param name="namesValidator"></param>
        /// <param name="pathValidator"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="InconsistentDataDetectedException"></exception>
        internal static VirtualFileSystem CreateFromDisk(IVirtualDisk disk, IEqualityComparer <string> namesComparer, NodeResolver nodeResolver, PathBuilder pathBuilder, IFileSystemArtifactNamesValidator namesValidator, IPathValidator pathValidator)
        {
            if (disk == null)
            {
                throw new ArgumentNullException("disk");
            }
            if (namesComparer == null)
            {
                throw new ArgumentNullException("namesComparer");
            }
            if (nodeResolver == null)
            {
                throw new ArgumentNullException("nodeResolver");
            }
            if (pathBuilder == null)
            {
                throw new ArgumentNullException("pathBuilder");
            }
            if (namesValidator == null)
            {
                throw new ArgumentNullException("namesValidator");
            }
            if (pathValidator == null)
            {
                throw new ArgumentNullException("pathValidator");
            }

            VirtualFileSystemInfo fileSystemInfo;
            var fileSystemNodeStorage = new FileSystemNodeStorage(disk);

            const int headerBlockIndex = VirtualDiskFormatter.FileSystemHeaderBlockIndex;
            const int freeBlockBitmapStartingBlockIndex = VirtualDiskFormatter.FreeSpaceStartingBlockIndex;

            var header = fileSystemNodeStorage.ReadFileSystemHeader(headerBlockIndex);

            fileSystemInfo = new VirtualFileSystemInfo(header.Version, disk.BlockSizeInBytes, header.RootBlockOffset, freeBlockBitmapStartingBlockIndex);

            var freeSpaceBitmapStore = new FreeSpaceBitmapStore(disk, VirtualDiskFormatter.FreeSpaceStartingBlockIndex);

            int bitmapSize;
            var freeSpaceMap = freeSpaceBitmapStore.ReadMap(out bitmapSize);

            var freeSpaceBitArray = new BitArray(freeSpaceMap)
            {
                Length = bitmapSize
            };

            var freeBlockManagerBitArrayBased = new FreeBlockManagerBitArrayBased(freeSpaceBitArray,
                                                                                  fileSystemInfo.FirstNonReservedDiskBlockIndex,
                                                                                  bitmapSize);

            IFreeBlockManager freeBlockManager = new FreeBlockManagerDiskWriting(freeSpaceBitmapStore, freeBlockManagerBitArrayBased);

            IFolderEnumeratorRegistry folderEnumeratorRegistry = new FolderEnumeratorRegistry();

            IFileSystemObjectLockingManager lockingManager = new FileSystemObjectLockingManager();

            var blockReferenceEditor = new BlockReferenceListsEditor(disk, freeBlockManager, fileSystemNodeStorage);

            //Note: много общих коллабораторов у трех классов. Недорефакторено.

            var fileManager   = new FileManager(disk, fileSystemNodeStorage, namesComparer, nodeResolver, freeBlockManager, folderEnumeratorRegistry, lockingManager, blockReferenceEditor, pathBuilder, namesValidator, pathValidator);
            var folderManager = new FolderManager(fileSystemNodeStorage, namesComparer, nodeResolver, freeBlockManager, folderEnumeratorRegistry, lockingManager, blockReferenceEditor, pathBuilder, namesValidator, pathValidator);

            return(new VirtualFileSystem(disk, fileSystemInfo, fileSystemNodeStorage, namesComparer, nodeResolver, freeBlockManager, folderEnumeratorRegistry, blockReferenceEditor, pathBuilder, namesValidator, pathValidator, fileManager, folderManager));
        }