internal CompoundFileStream(CompoundFileStorage storage, int pageSize) { this.storage = storage; this.position = 0; this.length = storage.Length; this.pageSize = pageSize; }
/// <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; } } }
private void ValidateRootStorage() { if (rootStorage.ObjectType != CompoundFileObjectType.Root) { rootStorage = null; throw new CompoundFileException("Invalid root storage"); } }
/// <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; }
internal MiniFATStream(CompoundFileStorage storage) : base(storage, storage.System.GetMiniSectorSize()) { }
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); } }