Example #1
0
        public Ole2Storage AddStorage(string name)
        {
            Ole2Storage storage = new Ole2Storage(name);

            this.elements.Add(storage);
            return(storage);
        }
Example #2
0
 internal bool VisitAllHelper(int level, VisitDirectoryEntryHandler visitEntryMethod, ArrayList levelTags)
 {
     foreach (Ole2DirectoryEntry entry in this)
     {
         VisitDirectoryEntryArgs args = new VisitDirectoryEntryArgs(entry, this, level, true, true, true, ArrayList.FixedSize(levelTags));
         visitEntryMethod(args);
         if (!args.ContinueVisiting)
         {
             return(false);
         }
         if (args.VisitChildren)
         {
             Ole2Storage storage = entry as Ole2Storage;
             if (storage != null)
             {
                 levelTags.Add(null);
                 bool flag = storage.VisitAllHelper(level + 1, visitEntryMethod, levelTags);
                 levelTags.RemoveAt(levelTags.Count - 1);
                 if (!flag)
                 {
                     return(false);
                 }
             }
         }
         if (!args.VisitSiblings)
         {
             break;
         }
     }
     return(true);
 }
Example #3
0
 public void ImportTree(Ole2Storage storage, bool loadOnDemand)
 {
     if (storage == null)
     {
         throw new CompoundFileException("Storage argument can't be null (Nothing).");
     }
     storage.VisitAll(new VisitDirectoryEntryHandler(Ole2Storage.CopyEntry), this);
     if (!loadOnDemand)
     {
         this.CacheAllStreams();
     }
 }
Example #4
0
 private static void AddTreeMembers(Ole2Storage storage, ArrayList nodes, int nodeDID)
 {
     CompoundFileData.RedBlackTreeNode node = nodes[nodeDID] as RedBlackTreeNode;
     if (node.LeftDID != -1)
     {
         AddTreeMembers(storage, nodes, node.LeftDID);
     }
     storage.Add(node.DirectoryEntry);
     if (node.RightDID != -1)
     {
         AddTreeMembers(storage, nodes, node.RightDID);
     }
 }
Example #5
0
        private static void CopyEntry(VisitDirectoryEntryArgs args)
        {
            Ole2Storage storage      = args.LevelTags[args.Level - 1] as Ole2Storage;//.get_Item(args.Level - 1);
            Ole2Stream  currentEntry = args.CurrentEntry as Ole2Stream;

            if (currentEntry != null)
            {
                SourceStreamHolder holder = new SourceStreamHolder(currentEntry);
                storage.AddStream(currentEntry.Name, currentEntry.Size, new GetStreamDataHandler(holder.CopyStreamData));
            }
            else
            {
                Ole2Storage storage2 = args.CurrentEntry as Ole2Storage;
                args.LevelTags[args.Level] = storage.AddStorage(storage2.Name);
            }
        }
Example #6
0
        private CompoundFileData.RedBlackTreeNode ReadDirectoryNode(BinaryReader br)
        {
            CompoundFileData.RedBlackTreeNode node = null;
            int num;

            char[] chArray = new char[0x20];
            for (num = 0; num < 0x20; num++)
            {
                chArray[num] = (char)br.ReadUInt16();
            }
            num = 0;
            while (num < 0x20)
            {
                if (chArray[num] == null)
                {
                    break;
                }
                num++;
            }
            string name = new string(chArray, 0, num);

            br.ReadUInt16();
            CompoundFileData.DirectoryEntryType type = (DirectoryEntryType)br.ReadByte();
            br.ReadByte();
            int num2 = br.ReadInt32();
            int num3 = br.ReadInt32();
            int num4 = br.ReadInt32();

            byte[] buffer  = br.ReadBytes(0x10);
            byte[] buffer2 = br.ReadBytes(4);
            byte[] buffer3 = br.ReadBytes(8);
            byte[] buffer4 = br.ReadBytes(8);
            int    readSID = br.ReadInt32();
            int    size    = br.ReadInt32();

            byte[] buffer5 = br.ReadBytes(4);
            if (type != CompoundFileData.DirectoryEntryType.Empty)
            {
                Ole2DirectoryEntry root;
                node = new CompoundFileData.RedBlackTreeNode {
                    LeftDID    = num2,
                    RightDID   = num3,
                    MembersDID = num4
                };
                switch (type)
                {
                case CompoundFileData.DirectoryEntryType.UserStorage:
                    root = new Ole2Storage(name);
                    break;

                case CompoundFileData.DirectoryEntryType.UserStream:
                    root = new Ole2Stream(name, size, readSID, this);
                    break;

                case CompoundFileData.DirectoryEntryType.RootStorage:
                    base.shortStreamContainerSize = size;
                    base.shortStreamContainerSID  = readSID;
                    this.ole2File.root            = new Ole2Storage(name);
                    root = this.ole2File.root;
                    break;

                default:
                    root = null;
                    break;
                }
                root.UniqueIdentifier      = buffer;
                root.UserFlags             = buffer2;
                root.TimeStampCreation     = buffer3;
                root.TimeStampModification = buffer4;
                root.NotUsed        = buffer5;
                node.DirectoryEntry = root;
            }
            return(node);
        }