예제 #1
0
        private void ReadMft(ScanningState state, NtfsReader ntfs, Dictionary <uint, FileNodeIndexes> fileNodes,
                             CancellationToken token)
        {
            foreach (INtfsNode node in ntfs.EnumerateNodes(state.RootPath))
            {
                string fullPath = PathUtils.TrimSeparatorDotEnd(node.FullName);
                bool   isRoot   = (node.NodeIndex == node.ParentNodeIndex);
                if (!isRoot && SkipFile(state, Path.GetFileName(fullPath), fullPath))
                {
                    continue;
                }
                FileNodeBase child;
                if (isRoot)
                {
                    child = state.Root;

                    /*state.Root = new RootNode(document, node, IsSingle);
                     * child = state.Root;
                     * // Let the user know that the root was found
                     * SetupRoot(state.Root, rootSetup);*/
                }
                else if (node.Attributes.HasFlag(FileAttributes.Directory))
                {
                    if (!state.IsDrive && state.RootPath == node.FullName.ToUpperInvariant())
                    {
                        child = state.Root;

                        /*state.Root = new RootNode(document, node, IsSingle);
                         * child = state.Root;
                         * // Let the user know that the root was found
                         * SetupRoot(state.Root, rootSetup);*/
                    }
                    else
                    {
                        child = new FolderNode(node);
                    }
                }
                else
                {
                    FileNode file = new FileNode(node);
                    child = file;
                    if (!node.Attributes.HasFlag(FileAttributes.ReparsePoint))
                    {
                        state.ScannedSize += child.Size;
                        totalScannedSize  += child.Size;
                    }
                    file.extRecord = extensions.Include(GetExtension(file.Name), child.Size);
                }
                fileNodes[node.NodeIndex] = new FileNodeIndexes(child, node);
                SuspendCheck();
                if (token.IsCancellationRequested)
                {
                    return;
                }
            }
        }
        private void ReadMft(ScanningState state, NtfsReader ntfs, FileNodeIndexes[] fileItemsLookup,
                             List <FileNodeIndexes> fileItems, CancellationToken token)
        {
            foreach (INtfsNode node in ntfs.EnumerateNodes(state.RootPath))
            {
                string fullPath = PathUtils.TrimSeparatorDotEnd(node.FullName);
                bool   isRoot   = (node.NodeIndex == node.ParentNodeIndex);
                if (!isRoot && SkipFile(state, Path.GetFileName(fullPath), fullPath))
                {
                    continue;
                }
                FileItemBase child;
                bool         reparsePoint = node.Attributes.HasFlag(FileAttributes.ReparsePoint);
                if (isRoot)
                {
                    child = state.Root;
                }
                else if (node.Attributes.HasFlag(FileAttributes.Directory))
                {
                    if (!state.IsDrive && state.RootPath == node.FullName.ToUpperInvariant())
                    {
                        child = state.Root;
                    }
                    else
                    {
                        child = new FolderItem(new ScanFileInfo(node));
                    }
                }
                else
                {
                    ExtensionItem extension = Extensions.GetOrAddFromPath(node.Name);
                    FileItem      file      = new FileItem(new ScanFileInfo(node), extension);
                    child = file;
                    if (!reparsePoint)
                    {
                        TotalScannedSize += child.Size;
                    }
                }
                FileNodeIndexes indexes = new FileNodeIndexes(child, node);
                fileItemsLookup[node.NodeIndex] = indexes;

                if (!reparsePoint)
                {
                    fileItems.Add(indexes);
                }

                if (AsyncChecks(token))
                {
                    return;
                }
            }
        }