/// <summary> /// A class that represents a file within an RAF archive. Creates an entry that only exists in memory. /// </summary> /// <param name="raf">Pointer to the owning RAFArchive</param> /// <param name="fileName">Full path of the file, ie. DATA/Characters/Ahri/Ahri.skn</param> /// <param name="offsetDatFile">Offset to the entry data offsets</param> /// <param name="fileSize">Length of the file in bytes</param> public RAFFileListEntry(RAFArchive raf, string fileName, UInt32 offsetDatFile, UInt32 fileSize) { m_raf = raf; FileName = fileName; m_fileOffset = offsetDatFile; m_fileSize = fileSize; }
private void CreateFileDicts(RAFArchive raf, UInt32 offsetFileList, UInt32 offsetStringTable) { //The file list starts with a uint stating how many files we have var fileListCount = BitConverter.ToUInt32(m_content.SubArray((Int32)offsetFileList, 4), 0); //After the file list count, we have the actual data. offsetFileList += 4; for (var currentOffset = offsetFileList; currentOffset < offsetFileList + 16 * fileListCount; currentOffset += 16) { var entry = new RAFFileListEntry(raf, ref raf.m_content, currentOffset, offsetStringTable); raf.m_fileDictFull.Add(entry.FileName.ToLower(), entry); var fi = new FileInfo(entry.FileName); if (!raf.m_fileDictShort.ContainsKey(fi.Name.ToLower())) { raf.m_fileDictShort.Add(fi.Name.ToLower(), new List <RAFFileListEntry> { entry }); } else { raf.m_fileDictShort[fi.Name.ToLower()].Add(entry); } } }
/// <summary> /// Allows the easy manipulation of RAF archives. With this class the user can pretend there is only one giant RAF /// archive /// </summary> /// <param name="rafFilePaths">An array whose values are the paths to each RAF file you want to be combined together</param> public RAFMasterFileList(String[] rafFilePaths) { foreach (var path in rafFilePaths) { var raf = new RAFArchive(path); m_fileDictFull = CombineFileDicts(m_fileDictFull, raf.FileDictFull); m_fileDictShort = CombineFileDicts(m_fileDictShort, raf.FileDictShort); } }
/// <summary> /// A class that represents a file within an RAF archive /// </summary> /// <param name="raf">Pointer to the owning RAFArchive</param> /// <param name="directoryFileContent">Pointer to the content of the .raf.dat file</param> /// <param name="offsetDirectoryEntry">Offset to the entry data offsets</param> /// <param name="offsetStringTable">Offset to the entry's file name</param> public RAFFileListEntry(RAFArchive raf, ref byte[] directoryFileContent, UInt32 offsetDirectoryEntry, UInt32 offsetStringTable) { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); m_raf = raf; m_fileOffset = BitConverter.ToUInt32(directoryFileContent, (int) offsetDirectoryEntry + 4); m_fileSize = BitConverter.ToUInt32(directoryFileContent, (int) offsetDirectoryEntry + 8); var strIndex = BitConverter.ToUInt32(directoryFileContent, (int) offsetDirectoryEntry + 12); var entryOffset = offsetStringTable + 8 + strIndex*8; var entryValueOffset = BitConverter.ToUInt32(directoryFileContent, (int) entryOffset); var entryValueSize = BitConverter.ToUInt32(directoryFileContent, (int) entryOffset + 4); var stringBytes = directoryFileContent.SubArray((int) (entryValueOffset + offsetStringTable), (int) entryValueSize - 1); FileName = Encoding.ASCII.GetString(stringBytes); }
/// <summary> /// A class that represents a file within an RAF archive /// </summary> /// <param name="raf">Pointer to the owning RAFArchive</param> /// <param name="directoryFileContent">Pointer to the content of the .raf.dat file</param> /// <param name="offsetDirectoryEntry">Offset to the entry data offsets</param> /// <param name="offsetStringTable">Offset to the entry's file name</param> public RAFFileListEntry(RAFArchive raf, ref byte[] directoryFileContent, UInt32 offsetDirectoryEntry, UInt32 offsetStringTable) { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); m_raf = raf; m_fileOffset = BitConverter.ToUInt32(directoryFileContent, (int)offsetDirectoryEntry + 4); m_fileSize = BitConverter.ToUInt32(directoryFileContent, (int)offsetDirectoryEntry + 8); var strIndex = BitConverter.ToUInt32(directoryFileContent, (int)offsetDirectoryEntry + 12); var entryOffset = offsetStringTable + 8 + strIndex * 8; var entryValueOffset = BitConverter.ToUInt32(directoryFileContent, (int)entryOffset); var entryValueSize = BitConverter.ToUInt32(directoryFileContent, (int)entryOffset + 4); var stringBytes = directoryFileContent.SubArray((int)(entryValueOffset + offsetStringTable), (int)entryValueSize - 1); FileName = Encoding.ASCII.GetString(stringBytes); }
private void CreateFileDicts(RAFArchive raf, UInt32 offsetFileList, UInt32 offsetStringTable) { //The file list starts with a uint stating how many files we have var fileListCount = BitConverter.ToUInt32(m_content.SubArray((Int32) offsetFileList, 4), 0); //After the file list count, we have the actual data. offsetFileList += 4; for (var currentOffset = offsetFileList; currentOffset < offsetFileList + 16*fileListCount; currentOffset += 16) { var entry = new RAFFileListEntry(raf, ref raf.m_content, currentOffset, offsetStringTable); raf.m_fileDictFull.Add(entry.FileName.ToLower(), entry); var fi = new FileInfo(entry.FileName); if (!raf.m_fileDictShort.ContainsKey(fi.Name.ToLower())) raf.m_fileDictShort.Add(fi.Name.ToLower(), new List<RAFFileListEntry> {entry}); else raf.m_fileDictShort[fi.Name.ToLower()].Add(entry); } }