/// <summary> /// Initializes arc from binary reader /// </summary> /// <param name="reader"></param> private bool Init(ExtBinaryReader reader) { if (!HashDict.Initialized) { HashDict.Init(); } if (reader.BaseStream.Length < Marshal.SizeOf <_sArcHeader>()) { return(false); } header = reader.ReadType <_sArcHeader>(); if (header.Magic != Magic) { throw new InvalidDataException("ARC magic does not match"); } reader.BaseStream.Seek(header.FileSystemOffset, SeekOrigin.Begin); if (header.FileDataOffset < 0x8824AF68) { Version = 0x00010000; ReadFileSystemV1(ReadCompressedTable(reader)); } else { ReadFileSystem(ReadCompressedTable(reader)); } //reader.BaseStream.Seek(header.FileSystemSearchOffset, SeekOrigin.Begin); //ReadSearchTable(ReadCompressedTable(reader)); return(true); }
private List <string> GetFileListV2() { var filePaths = new List <string>(fileInfoV2.Length); foreach (var fileInfo in fileInfoV2) { var path = fileInfoPath[fileInfo.PathIndex]; string pathString = HashDict.GetString(path.Parent, (int)(path.Unk5 & 0xFF)); if (pathString.StartsWith("0x")) { pathString += "/"; } string filename = HashDict.GetString(path.FileName, (int)(path.Unk6 & 0xFF)); if (filename.StartsWith("0x")) { filename += HashDict.GetString(path.Extension); } filePaths.Add(pathString + filename); } return(filePaths); }
public void PrintDirectoryInfo(string directory) { uint hash = CRC32.Crc32C(directory); int count = -1; foreach (var dir in directoryHashGroup) { //Console.WriteLine(HashDict.GetString(dir.Hash) + " " + dir.index.ToString("X")); count++; if (dir.Hash == hash) { var direct = directoryList[dir.index >> 8]; Console.WriteLine(directory); Console.WriteLine("Sub Folders:"); for (int i = direct.ChildDirectoryStartIndex; i < direct.ChildDirectoryStartIndex + direct.ChildDirectoryCount; i++) { var hashGroup = directoryChildHashGroup[i]; Console.WriteLine("\t" + HashDict.GetString(hashGroup.Hash)); } Console.WriteLine("Sub Files:"); for (int i = direct.FileInformationStartIndex; i < direct.FileInformationStartIndex + direct.FileInformationCount; i++) { var fileinfo = fileInfoV2[i]; var fileindex = fileInfoIndex[fileinfo.IndexIndex]; //redirect if ((fileinfo.Flags & 0x00000010) == 0x10) { fileinfo = fileInfoV2[fileindex.FileInformationIndex]; } var path = fileInfoPath[fileinfo.PathIndex]; var subindex = fileInfoSubIndex[fileinfo.SubIndexIndex]; var subfile = subFiles[subindex.SubFileIndex]; var directoryOffset = directoryOffsets[subindex.DirectoryOffsetIndex]; //regional if ((fileinfo.Flags & 0x00008000) == 0x8000) { subindex = fileInfoSubIndex[fileinfo.SubIndexIndex + 2]; subfile = subFiles[subindex.SubFileIndex]; directoryOffset = directoryOffsets[subindex.DirectoryOffsetIndex]; } Console.WriteLine("\t" + HashDict.GetString(path.Parent) + HashDict.GetString(path.FileName)); Console.WriteLine("\t\t" + i + " " + fileinfo.SubIndexIndex + " " + path.DirectoryIndex + " " + fileinfo.IndexIndex + " " + (header.FileDataOffset + directoryOffset.Offset + (subfile.Offset << 2)).ToString("X") + " " + subfile.CompSize.ToString("X") + " " + subfile.DecompSize.ToString("X") + " " + subfile.Flags.ToString("X") + " " + fileinfo.Flags.ToString("X") + " " + subindex.SubFileIndex + " " + directoryOffset.SubDataStartIndex + " " + subindex.FileInformationIndexAndFlag.ToString("X")); } break; } } }
/// <summary> /// returns an unorganized list of the stream files in the arc /// </summary> /// <returns></returns> public List <string> GetStreamFileList() { var files = new List <string>(streamNameToHash.Length); foreach (var fileinfo in streamNameToHash) { files.Add(HashDict.GetString(fileinfo.Hash, (int)(fileinfo.NameIndex & 0xFF))); } return(files); }
private string GetFilePathFromInfo(_sFileInformationV2 file) { var path = fileInfoPath[file.PathIndex]; string pathString = HashDict.GetString(path.Parent, (int)(path.Unk5 & 0xFF)); string filename = HashDict.GetString(path.FileName, (int)(path.Unk6 & 0xFF)); if (filename.StartsWith("0x")) { filename += HashDict.GetString(path.Extension); } return(pathString + filename); }
/// <summary> /// returns an unorganized list of the files in the arc excluding stream files /// </summary> /// <returns></returns> public List <string> GetFileListV1() { var files = new List <string>(fileInfoV1.Length); foreach (var fileinfo in fileInfoV1) { string pathString = HashDict.GetString(fileinfo.Parent, (int)(fileinfo.Unk5 & 0xFF)); if (pathString.StartsWith("0x")) { pathString += "/"; } files.Add(pathString + HashDict.GetString(fileinfo.Hash2, (int)(fileinfo.Unk6 & 0xFF))); } return(files); }
/// <summary> /// Returns an unorganized list of the files in the arc, excluding stream files. /// </summary> /// <returns>An unorganized list of the files in the arc, excluding stream files.</returns> public List <string> GetFileListV1() { var files = new List <string>(fileInfoV1.Length); foreach (var fileInfo in fileInfoV1) { string pathString = HashDict.GetString(fileInfo.Parent, (int)(fileInfo.Unk5 & 0xFF)); string filename = HashDict.GetString(fileInfo.Hash2, (int)(fileInfo.Unk6 & 0xFF)); if (filename.StartsWith("0x")) { filename += HashDict.GetString(fileInfo.Extension); } files.Add(pathString + filename); } return(files); }
public long MaxOffset() { long max = 0; foreach (var fi in fileInfoV2) { var path = fileInfoPath[fi.PathIndex]; var subindex = fileInfoSubIndex[fi.SubIndexIndex]; var subfile = subFiles[subindex.SubFileIndex]; var directoryOffset = directoryOffsets[subindex.DirectoryOffsetIndex]; max = Math.Max(max, header.FileDataOffset + directoryOffset.Offset + (subfile.Offset << 2)); if (header.FileDataOffset + directoryOffset.Offset + (subfile.Offset << 2) > header.FileDataOffset2) { Console.WriteLine(HashDict.GetString(path.FileName)); } } return(max); }
/// <summary> /// returns an unorganized list of the files in the arc excluding stream files /// </summary> /// <returns></returns> public List <string> GetFileList() { if (Version == 0x00010000) { return(GetFileListV1()); } var files = new List <string>(fileInfoV2.Length); foreach (var fileinfo in fileInfoV2) { var path = fileInfoPath[fileinfo.PathIndex]; string pathString = HashDict.GetString(path.Parent, (int)(path.Unk5 & 0xFF)); if (pathString.StartsWith("0x")) { pathString += "/"; } files.Add(pathString + HashDict.GetString(path.FileName, (int)(path.Unk6 & 0xFF))); } return(files); }