Пример #1
0
 internal CompoundFileStream(CompoundFileStorage storage, int pageSize)
 {
     this.storage = storage;
     this.position = 0;
     this.length = storage.Length;
     this.pageSize = pageSize;
 }
Пример #2
0
        /// <summary>
        /// Returns pair of item name and storage.
        /// </summary>
        /// <param name="storage">A Compound File storage.</param>
        /// <param name="parentPath">Name prefix.</param>
        /// <returns>Pairs of item name and storage.</returns>
        private static IEnumerable<KeyValuePair<string, CompoundFileStorage>> ListStorage(CompoundFileStorage storage, string parentPath)
        {
            string name = storage.Name.ToEscapedString();
            yield return new KeyValuePair<string, CompoundFileStorage>(parentPath + name, storage);

            foreach (CompoundFileStorage child in storage.GetStorages())
            {
                foreach (KeyValuePair<string, CompoundFileStorage> result in ListStorage(child, parentPath + name + "/"))
                {
                    yield return result;
                }
            }
        }
Пример #3
0
 private void ValidateRootStorage()
 {
     if (rootStorage.ObjectType != CompoundFileObjectType.Root)
     {
         rootStorage = null;
         throw new CompoundFileException("Invalid root storage");
     }
 }
Пример #4
0
        /// <summary>
        /// Gets Root storage.
        /// </summary>
        /// <returns>Root storage.</returns>
        public CompoundFileStorage GetRootStorage()
        {
            if (rootStorage == null)
            {
                const int RootDirectoryStreamID = 0;
                rootStorage = new CompoundFileStorage(this, RootDirectoryStreamID, new uint[0]);

                ValidateRootStorage();
            }
            return rootStorage;
        }
Пример #5
0
 internal MiniFATStream(CompoundFileStorage storage)
     : base(storage, storage.System.GetMiniSectorSize())
 {
 }
Пример #6
0
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     if (disposing)
     {
         storage = null;    // lost the storage and system
         page = null;
     }
 }
        private void AppendChild(List<CompoundFileStorage> collection, uint streamID, Dictionary<uint, CompoundFileStorage> processed, IEnumerable<uint> ancestors)
        {
            if (processed.ContainsKey(streamID))
                throw new CompoundFileException("Circular structure: siblings");

            CompoundFileStorage item = new CompoundFileStorage(System, streamID, ancestors);
            processed.Add(streamID, item);

            if (item.Entry.LeftSiblingID != DirectoryStreamIds.NOSTREAM)
            {
                AppendChild(collection, item.Entry.LeftSiblingID, processed, ancestors);
            }
            if (item.ObjectType != CompoundFileObjectType.Unknown)
            {
                // skiping unknown
                collection.Add(item);
            }
            if (item.Entry.RightSiblingID != DirectoryStreamIds.NOSTREAM)
            {
                AppendChild(collection, item.Entry.RightSiblingID, processed, ancestors);
            }
        }