/// <summary> /// Constructs a KIFINT entry with the specified file name, entry data, parent KIFINT archive. /// </summary> /// <param name="fileName"> /// The cached name of the file. Calling <see cref="KifintArchive.KIFENTRY.FileName"/> is wasteful. /// </param> /// <param name="kifEntry">The decrypted data for the entry.</param> /// <param name="kifint">The parent KIFINT arhive.</param> internal KifintEntry(string fileName, KIFENTRY kifEntry, KifintArchive kifint) { Kifint = kifint; FileName = fileName; Offset = kifEntry.Offset; Length = kifEntry.Length; }
/// <summary> /// Constructs the KIFINT archive list and sorts the entry file names. /// </summary> /// <param name="kifint">The associated KIFINT archive.</param> public KifintList(KifintArchive kifint) { StringComparer comparer = StringComparer.InvariantCultureIgnoreCase; FilePath = kifint.FilePath; Entries = kifint.Entries.Values.Select(e => e.FileName) .OrderBy(e => e, comparer) .ToImmutableArrayLW(); }
/// <summary> /// Reads the KIFINT archive from the stream. For use with <see cref="KifintLookup"/>. /// </summary> /// <param name="reader">The reader for the current stream.</param> /// <param name="version">The current version being read.</param> /// <param name="kifint">The KIFINT archive containing this entry.</param> /// <returns>The loaded cached KIFINT.</returns> internal static KifintEntry Read(BinaryReader reader, int version, KifintArchive kifint) { return(new KifintEntry { Kifint = kifint, FileName = reader.ReadString(), Offset = reader.ReadUInt32(), Length = reader.ReadInt32(), }); }
/// <summary> /// Extracts the KIFINT entry to a fixed stream of <paramref name="kifintStream"/>. /// </summary> /// <param name="kifintStream">The stream to the open KIFINT archive.</param> /// <param name="leaveOpen"> /// True if the KIFINT archive stream should be left open even after closing the returned stream. /// </param> /// <returns> /// A fixed stream containing the data of the decrypted entry. This stream must always be disposed of, because /// it's not guaranteed to be a fixed stream of <paramref name="kifintStream"/>. This is the case when the /// length is small enough for extracting bytes to be more efficient. /// </returns> /// /// <exception cref="ArgumentNullException"> /// <paramref name="kifintStream"/> is null. /// </exception> public Stream ExtractToStream(KifintStream kifintStream, bool leaveOpen) { if (CatDebug.StreamExtract) { return(KifintArchive.ExtractToStream(kifintStream, this, leaveOpen)); } else { return(new MemoryStream(ExtractToBytes(kifintStream))); } }
/// <summary> /// Constructs and opens the file stream for the specified KIFINT archive and closes the existing stream if /// there is one. /// </summary> /// <param name="kifint">The KIFINT archive to open the stream for.</param> /// /// <exception cref="ArgumentNullException"> /// <paramref name="kifint"/> is null. /// </exception> public KifintStream(KifintArchive kifint) { Open(kifint); }
/// <summary> /// Extracts the KIFINT entry to a <see cref="byte"/>[]. /// </summary> /// <param name="kifintStream">The stream to the open KIFINT archive.</param> /// <returns>A byte array containing the data of the decrypted entry.</returns> /// /// <exception cref="ArgumentNullException"> /// <paramref name="kifintStream"/> is null. /// </exception> public byte[] ExtractToBytes(KifintStream kifintStream) { return(KifintArchive.ExtractToBytes(kifintStream, this)); }
/// <summary> /// Extracts the KIFINT entry to a <see cref="byte"/>[]. /// </summary> /// <returns>A byte array containing the data of the decrypted entry.</returns> public byte[] ExtractToBytes() { using (KifintStream kifintStream = new KifintStream()) return(KifintArchive.ExtractToBytes(kifintStream, this)); }