public override void Rebuild(string outputFolder) { var outputPath = System.IO.Path.Combine(outputFolder, RelativePath); Directory.CreateDirectory(System.IO.Path.GetDirectoryName(outputPath)); var subtitles = GetSubtitles(); using (var fsInput = new FileStream(Path, FileMode.Open)) using (var input = new ExtendedBinaryReader(fsInput, FileEncoding, Endianness.BigEndian)) using (var fsOutput = new FileStream(outputPath, FileMode.Create)) using (var output = new ExtendedBinaryWriter(fsOutput, FileEncoding, Endianness.BigEndian)) { output.Write(input.ReadBytes(32)); var firstString = input.PeekInt32(); long outputOffset = firstString; var subtitle = ReadSubtitle(input); outputOffset = WriteSubtitle(output, subtitles, subtitle.Offset, outputOffset); subtitle = ReadSubtitle(input); outputOffset = WriteSubtitle(output, subtitles, subtitle.Offset, outputOffset); output.Write(input.ReadBytes(24)); var dds = ReadSubtitle(input); WriteString(output, dds, outputOffset); output.Write(input.ReadBytes(firstString - (int)input.Position)); output.WritePadding(16); } }
public override void Rebuild(string outputFolder) { var outputPath = System.IO.Path.Combine(outputFolder, RelativePath); Directory.CreateDirectory(System.IO.Path.GetDirectoryName(outputPath)); var subtitles = GetSubtitles(); using (var fsInput = new FileStream(Path, FileMode.Open)) using (var input = new ExtendedBinaryReader(fsInput, FileEncoding, Endianness.BigEndian)) using (var fsOutput = new FileStream(outputPath, FileMode.Create)) using (var output = new ExtendedBinaryWriter(fsOutput, FileEncoding, Endianness.BigEndian)) { output.Write(input.ReadBytes(6)); var groupCount = input.ReadInt16(); output.Write(groupCount); output.Write(input.ReadBytes(4)); var groupsOffset = input.ReadInt32(); output.Write(groupsOffset); long outputOffset = input.PeekInt32(); var firstStringOffset = outputOffset; while (input.Position < groupsOffset) { var offset = input.ReadInt32(); if (offset > 0 && offset < input.Length) { outputOffset = WriteSubtitle(output, subtitles, offset, outputOffset); } else { output.Write(offset); } } output.Write(input.ReadBytes((int)(groupsOffset - (int)input.Position))); for (var i = 0; i < groupCount; i++) { var offsets = new int[_groupSize]; for (var j = 0; j < _groupSize; j++) { offsets[j] = input.ReadInt32(); } for (var j = 0; j < 6; j++) { output.Write(offsets[j]); } outputOffset = WriteSubtitle(output, subtitles, offsets[6], outputOffset); output.Write(offsets[7]); } output.Write(input.ReadBytes((int)(firstStringOffset - input.Position))); } }
protected override IList <Subtitle> GetSubtitles() { var result = new List <Subtitle>(); using (var fs = new FileStream(Path, FileMode.Open)) using (var input = new ExtendedBinaryReader(fs, FileEncoding, Endianness.BigEndian)) { input.Skip(StartOffset); var tableEnd = input.PeekInt32(); while (input.Position < tableEnd) { var subtitle = ReadSubtitle(input); subtitle.PropertyChanged += SubtitlePropertyChanged; result.Add(subtitle); } } LoadChanges(result); return(result); }
public override void Rebuild(string outputFolder) { var outputPath = System.IO.Path.Combine(outputFolder, RelativePath); Directory.CreateDirectory(System.IO.Path.GetDirectoryName(outputPath)); var subtitles = GetSubtitles(); var used = new Dictionary <long, long>(); using (var fsInput = new FileStream(Path, FileMode.Open)) using (var input = new ExtendedBinaryReader(fsInput, FileEncoding, Endianness.BigEndian)) using (var fsOutput = new FileStream(outputPath, FileMode.Create)) using (var output = new ExtendedBinaryWriter(fsOutput, FileEncoding, Endianness.BigEndian)) { output.Write(input.ReadBytes(4)); var count = input.ReadInt32(); output.Write(count); output.Write(input.ReadBytes(8)); long outputOffset = input.PeekInt32(); for (var i = 0; i < count; i++) { var offset = input.ReadInt32(); outputOffset = WriteString(output, subtitles, used, offset, outputOffset); offset = input.ReadInt32(); outputOffset = WriteString(output, subtitles, used, offset, outputOffset); var pointer = input.ReadInt32(); output.Write(pointer); var numLines = input.ReadInt32(); output.Write(numLines); offset = input.ReadInt32(); outputOffset = WriteString(output, subtitles, used, offset, outputOffset); offset = input.ReadInt32(); outputOffset = WriteString(output, subtitles, used, offset, outputOffset); output.Write(input.ReadBytes(4)); offset = input.ReadInt32(); outputOffset = WriteString(output, subtitles, used, offset, outputOffset); var pos = input.Position; input.Seek(pointer, SeekOrigin.Begin); output.Seek(pointer, SeekOrigin.Begin); for (var j = 0; j < numLines; j++) { offset = input.ReadInt32(); outputOffset = WriteString(output, subtitles, used, offset, outputOffset); } input.Seek(pos, SeekOrigin.Begin); output.Seek(pos, SeekOrigin.Begin); output.Write(input.ReadBytes(36)); } } }
public override void Rebuild(string outputFolder) { var outputPath = System.IO.Path.Combine(outputFolder, RelativePath); Directory.CreateDirectory(System.IO.Path.GetDirectoryName(outputPath)); var subtitles = GetSubtitles(); using (var fsInput = new FileStream(Path, FileMode.Open)) using (var input = new ExtendedBinaryReader(fsInput, FileEncoding, Endianness.BigEndian)) using (var fsOutput = new FileStream(outputPath, FileMode.Create)) using (var output = new ExtendedBinaryWriter(fsOutput, FileEncoding, Endianness.BigEndian)) { output.Write(input.ReadBytes(6)); var groupCount = input.ReadInt16(); output.Write(groupCount); output.Write(input.ReadBytes(8)); long outputOffset = input.PeekInt32(); var firstStringOffset = outputOffset; for (var i = 0; i < 43; i++) { var offset = input.ReadInt32(); outputOffset = WriteSubtitle(output, subtitles, offset, outputOffset); } output.Write(input.ReadBytes(0x108 - (int)input.Position)); // barkeeper var barKeeperOffset = input.ReadInt32(); outputOffset = WriteSubtitle(output, subtitles, barKeeperOffset, outputOffset); output.Write(input.ReadBytes(0x110 - (int)input.Position)); for (var i = 0; i < groupCount; i++) { var offsets = new int[22]; for (var j = 0; j < 22; j++) { offsets[j] = input.ReadInt32(); } for (var j = 0; j < 8; j++) { output.Write(offsets[j]); } outputOffset = WriteSubtitle(output, subtitles, offsets[8], outputOffset); for (var j = 9; j < 14; j++) { output.Write(offsets[j]); } for (var j = 14; j < 22; j++) { outputOffset = WriteSubtitle(output, subtitles, offsets[j], outputOffset); } } output.Write(input.ReadBytes((int)(firstStringOffset - input.Position))); } }