public static void Build(DirectoryEntry rootEntry)
 {
     if (rootEntry.Members.Count > 0)
     {
         rootEntry.MembersTreeNodeDID = DirectoryTree.BuildStorageEntry(rootEntry);
     }
 }
        private static int BuildStorageEntry(DirectoryEntry storageEntry)
        {
            RedBlackTree <DirectoryEntry> redBlackTree = new RedBlackTree <DirectoryEntry>();

            foreach (DirectoryEntry directoryEntry in storageEntry.Members.Values)
            {
                redBlackTree.Add(directoryEntry);
            }
            foreach (RedBlackTreeNode <DirectoryEntry> current in redBlackTree.InorderTreeWalk(redBlackTree.Root))
            {
                DirectoryEntry directoryEntry = current.Data;
                directoryEntry.NodeColor     = DirectoryTree.GetNodeColor(current.Color);
                directoryEntry.LeftChildDID  = DirectoryTree.GetNodeID(current.Left);
                directoryEntry.RightChildDID = DirectoryTree.GetNodeID(current.Right);
                if (directoryEntry.Members.Count > 0)
                {
                    directoryEntry.EntryType          = 1;
                    directoryEntry.MembersTreeNodeDID = DirectoryTree.BuildStorageEntry(directoryEntry);
                }
                else
                {
                    directoryEntry.EntryType          = 2;
                    directoryEntry.MembersTreeNodeDID = -1;
                }
            }
            return(redBlackTree.Root.Data.ID);
        }
        void SaveDirectoryEntries()
        {
            DirectoryTree.Build(RootStorage);
            DirectoryStream.Position = 0;
            BinaryWriter writer = new BinaryWriter(DirectoryStream, Encoding.Unicode);

            for (int id = 0; id < DirectoryEntries.Count; id++)
            {
                WriteDirectoryEntry(writer, DirectoryEntries[id]);
            }
            WriteStreamData(Header.FirstSectorIDofDirectoryStream, DirectoryStream.ToArray());
        }
Exemple #4
0
        private void SaveDirectoryEntries()
        {
            DirectoryTree.Build(this.RootStorage);
            this.DirectoryStream.Position = 0L;
            BinaryWriter writer = new BinaryWriter(this.DirectoryStream, Encoding.Unicode);

            checked
            {
                for (int i = 0; i < this.DirectoryEntries.Count; i++)
                {
                    CompoundDocument.WriteDirectoryEntry(writer, this.DirectoryEntries[i]);
                }
                this.WriteStreamData(this.Header.FirstSectorIDofDirectoryStream, this.DirectoryStream.ToArray());
            }
        }