コード例 #1
0
 /// <summary>
 /// Overwrites the entry data, assuming the size is the exact same.
 /// </summary>
 /// <param name="entry">File entry to overwrite</param>
 /// <param name="data">Data to write</param>
 public void SetData(SFATEntry entry, byte[] data)
 {
     if (data.Length != entry.FileDataLength)
     {
         throw new ArgumentException(nameof(data.Length));
     }
     SetData(entry.FileDataStart, data);
 }
コード例 #2
0
        /// <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;
            byte[] data = GetData(t);
            string name = GetFileName(t);

            string 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);
        }
コード例 #3
0
 /// <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);
コード例 #4
0
 /// <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);