/// <summary> /// Exports the entry data for a given <see cref="SFATEntry"/> at a provided path with its assigned <see cref="SFATEntry"/> file name via the <see cref="SFNT"/> name table. /// </summary> /// <param name="t">Entry to export</param> /// <param name="outpath">Path to export to. If left null, will output to the <see cref="SARC"/> FilePath, if it is assigned.</param> public string ExportFile(SFATEntry t, string?outpath = null) { outpath ??= FilePath; if (outpath == null) { throw new ArgumentNullException(nameof(outpath)); } byte[] data = GetData(t); string name = GetFileName(t); var dir = Path.GetDirectoryName(name); if (dir == null) { throw new ArgumentException(name); } string location = Path.Combine(outpath, dir); Directory.CreateDirectory(location); var filepath = Path.Combine(outpath, name); File.WriteAllBytes(filepath, data); return(filepath); }
/// <summary> /// Gets the entry data for a given <see cref="SFATEntry"/>, /// </summary> /// <param name="entry">Entry to fetch data for</param> /// <returns>Data array</returns> public byte[] GetData(SFATEntry entry) => GetData(entry.FileDataStart, entry.FileDataLength);
/// <summary> /// Gets the entry filename for a given <see cref="SFATEntry"/>. /// </summary> /// <param name="entry">Entry to fetch data for</param> /// <returns>File Name</returns> public string GetFileName(SFATEntry entry) => GetFileName(entry.FileNameOffset);