/// <summary> /// Extract the resource from the volume. /// </summary> /// <param name="container">Game container.</param> /// <param name="fileName">Volume file name.</param> /// <param name="dirEntry">Resource map entry for the resource to extract.</param> /// <param name="wasCompressed">Resource was compressed in the volume, so it was decompressed.</param> /// <returns>Binary data for the resource. This is always uncompressed. If the data is compressed in the volume, the volume decoder must decompress it.</returns> byte[] IVolumeDecoder.ExtractResource(IGameContainer container, string fileName, VolumeResourceMapEntry dirEntry, out bool wasCompressed) { if (container == null) { throw new ArgumentNullException(nameof(container)); } if (fileName == null) { throw new ArgumentNullException(nameof(fileName)); } if (fileName.Length == 0) { throw new ArgumentException(Errors.FilePathEmpty, nameof(fileName)); } if (dirEntry == null) { throw new ArgumentNullException(nameof(dirEntry)); } byte[] volumeData = container.Read(fileName); if (dirEntry.Offset >= volumeData.Length) { throw new VolumeDecoderInvalidResourceOffsetException(); } return(VolumeDecoderV3.ExtractResource(volumeData, dirEntry.Offset, out wasCompressed)); }
/// <summary> /// Load the resource map located in the specified folder. /// </summary> /// <param name="container">Game container where the resource map file(s) are located.</param> /// <returns>Resource map.</returns> VolumeResourceMap IVolumeDecoder.LoadResourceMap(IGameContainer container) { if (container == null) { throw new ArgumentNullException(nameof(container)); } return(VolumeDecoderV3.ReadResourceMap(container.Read(this.GetResourceMapFile()))); }