public List <IWriteFile> ReadHeader(FileStream stream, ppFormat format, byte[] SMFigTable) { List <IWriteFile> subfiles = null; stream.Position = 0; BinaryReader binaryReader = new BinaryReader(stream); DecryptHeaderBytes(binaryReader.ReadBytes(1), SMFigTable); // first byte int numFiles = BitConverter.ToInt32(DecryptHeaderBytes(binaryReader.ReadBytes(4), SMFigTable), 0); byte[] buf = DecryptHeaderBytes(binaryReader.ReadBytes(numFiles * 268), SMFigTable); subfiles = new List <IWriteFile>(numFiles); for (int i = 0; i < numFiles; i++) { int offset = i * 268; ppSubfile subfile = new ppSubfile(stream.Name); subfile.ppFormat = format; subfile.Name = Utility.EncodingShiftJIS.GetString(buf, offset, 260).TrimEnd(new char[] { '\0' }); subfile.size = BitConverter.ToUInt32(buf, offset + 260); subfile.offset = BitConverter.ToUInt32(buf, offset + 264); subfiles.Add(subfile); } return(subfiles); }
public override List <IWriteFile> ReadHeader(string path, ppFormat format) { List <IWriteFile> subfiles = null; using (BinaryReader reader = new BinaryReader(File.OpenRead(path))) { byte[] versionHeader = reader.ReadBytes(8); int version = BitConverter.ToInt32(ppHeader_SMRetail.DecryptHeaderBytes(reader.ReadBytes(4)), 0); ppHeader_SMRetail.DecryptHeaderBytes(reader.ReadBytes(1)); // first byte int numFiles = BitConverter.ToInt32(ppHeader_SMRetail.DecryptHeaderBytes(reader.ReadBytes(4)), 0); byte[] buf = ppHeader_SMRetail.DecryptHeaderBytes(reader.ReadBytes(numFiles * 288)); subfiles = new List <IWriteFile>(numFiles); for (int i = 0; i < numFiles; i++) { int offset = i * 288; ppSubfile subfile = new ppSubfile(path); subfile.ppFormat = format; subfile.Name = Utility.EncodingShiftJIS.GetString(buf, offset, 260).TrimEnd(new char[] { '\0' }); subfile.size = BitConverter.ToUInt32(buf, offset + 260); subfile.offset = BitConverter.ToUInt32(buf, offset + 264); Metadata metadata = new Metadata(); metadata.LastBytes = new byte[20]; System.Array.Copy(buf, offset + 268, metadata.LastBytes, 0, 20); subfile.Metadata = metadata; subfiles.Add(subfile); } } return(subfiles); }
public ppParser(string path, ppFormat format) { this.Format = format; this.FilePath = path; using (FileStream stream = File.OpenRead(path)) { this.Subfiles = format.ppHeader.ReadHeader(stream, format); } }
public static ppParser OpenPP([DefaultVar] string path) { ppFormat format = ppFormat.GetFormat(path); if (format == null) { throw new Exception("Couldn't auto-detect the ppFormat"); } return(new ppParser(path, format)); }
public ppParser(string path, ppFormat format) { this.Format = format; this.FilePath = path; if (File.Exists(path)) { this.Subfiles = format.ppHeader.ReadHeader(path, format); } else { this.Subfiles = new List <IWriteFile>(); } }
public ppParser(string path, ppFormat format) { this.Format = format; this.FilePath = path; if (File.Exists(path)) { this.Subfiles = format.ppHeader.ReadHeader(path, format); } else { this.Subfiles = new List<IWriteFile>(); } }
public static ppFormat GetFormat(string path) { ppHeader header = null; for (int i = 0; i < ppHeader.Array.Length; i++) { try { if ((header = ppHeader.Array[i].TryHeader(path)) != null) { break; } } catch { } } ppFormat resultFormat = null; if (header != null) { if (header.ppFormats.Length == 1) { resultFormat = header.ppFormats[0]; } else { List <IWriteFile> subfiles = header.ReadHeader(path, null); for (int i = 0; i < subfiles.Count; i++) { if ((resultFormat = TryFile((ppSubfile)subfiles[i], header.ppFormats)) != null) { break; } } } if (resultFormat == null) { resultFormat = header.ppFormats[0]; Report.ReportLog("Couldn't auto-detect the ppFormat for " + path + ". Using " + resultFormat.Name + " instead"); } } return(resultFormat); }
public static object OpenPP([DefaultVar] string path) { using (FileStream stream = File.OpenRead(path)) { ppHeader header; ppFormat format = ppFormat.GetFormat(stream, out header); if (format == null) { if (header == null) { throw new Exception("Couldn't auto-detect the ppFormat"); } return(header); } return(new ppParser(stream, format)); } }
public override List <IWriteFile> ReadHeader(FileStream stream, ppFormat format) { List <IWriteFile> subfiles = null; stream.Position = 0; BinaryReader reader = new BinaryReader(stream); byte[] versionHeader = reader.ReadBytes(8); Version = BitConverter.ToInt32(ppHeader_SMRetail.DecryptHeaderBytes(reader.ReadBytes(4)), 0); ppHeader_SMRetail.DecryptHeaderBytes(reader.ReadBytes(1)); // first byte int numFiles = BitConverter.ToInt32(ppHeader_SMRetail.DecryptHeaderBytes(reader.ReadBytes(4)), 0); byte[] buf = ppHeader_SMRetail.DecryptHeaderBytes(reader.ReadBytes(numFiles * 288)); subfiles = new List <IWriteFile>(numFiles); for (int i = 0; i < numFiles; i++) { int offset = i * 288; ppSubfile subfile = new ppSubfile(stream.Name); subfile.ppFormat = format; int length = 260; for (int j = 0; j < length; j++) { if (buf[offset + j] == 0x00) { length = j; break; } } subfile.Name = Utility.EncodingShiftJIS.GetString(buf, offset, length); subfile.size = BitConverter.ToUInt32(buf, offset + 260); subfile.offset = BitConverter.ToUInt32(buf, offset + 264); Metadata metadata = new Metadata(); metadata.LastBytes = new byte[20]; System.Array.Copy(buf, offset + 268, metadata.LastBytes, 0, 20); subfile.Metadata = metadata; subfiles.Add(subfile); } return(subfiles); }
public static ppFormat GetFormat(FileStream stream, out ppHeader header) { header = null; for (int i = 0; i < ppHeader.Array.Length; i++) { try { if ((header = ppHeader.Array[i].TryHeader(stream)) != null) { break; } } catch { } } ppFormat resultFormat = null; if (header != null) { if (header.ppFormats.Length == 1) { resultFormat = header.ppFormats[0]; } else { List <IWriteFile> subfiles = header.ReadHeader(stream, null); for (int i = 0; i < subfiles.Count; i++) { if ((resultFormat = TryFile(stream, (ppSubfile)subfiles[i], header.ppFormats)) != null) { break; } } } } return(resultFormat); }
public override List <IWriteFile> ReadHeader(FileStream stream, ppFormat format) { List <IWriteFile> subfiles = null; stream.Position = 0; BinaryReader binaryReader = new BinaryReader(stream); int numFiles = binaryReader.ReadInt32(); subfiles = new List <IWriteFile>(numFiles); binaryReader.ReadInt32(); // total size // get filenames for (int i = 0; i < numFiles; i++) { byte[] nameBuf = binaryReader.ReadBytes(0x20); for (int j = 0; j < nameBuf.Length; j++) { nameBuf[j] = (byte)(~nameBuf[j] + 1); } ppSubfile subfile = new ppSubfile(stream.Name); subfile.ppFormat = format; subfile.Name = Utility.EncodingShiftJIS.GetString(nameBuf).TrimEnd(new char[] { '\0' }); subfiles.Add(subfile); } // get filesizes uint offset = HeaderSize(numFiles); // start of first file data for (int i = 0; i < numFiles; i++) { ppSubfile subfile = (ppSubfile)subfiles[i]; subfile.offset = offset; subfile.size = binaryReader.ReadUInt32(); offset += subfile.size; } return(subfiles); }
public List<IWriteFile> ReadHeader(FileStream stream, ppFormat format, byte[] SMFigTable) { List<IWriteFile> subfiles = null; stream.Position = 0; BinaryReader binaryReader = new BinaryReader(stream); DecryptHeaderBytes(binaryReader.ReadBytes(1), SMFigTable); // first byte int numFiles = BitConverter.ToInt32(DecryptHeaderBytes(binaryReader.ReadBytes(4), SMFigTable), 0); byte[] buf = DecryptHeaderBytes(binaryReader.ReadBytes(numFiles * 268), SMFigTable); subfiles = new List<IWriteFile>(numFiles); for (int i = 0; i < numFiles; i++) { int offset = i * 268; ppSubfile subfile = new ppSubfile(stream.Name); subfile.ppFormat = format; subfile.Name = Utility.EncodingShiftJIS.GetString(buf, offset, 260).TrimEnd(new char[] { '\0' }); subfile.size = BitConverter.ToUInt32(buf, offset + 260); subfile.offset = BitConverter.ToUInt32(buf, offset + 264); subfiles.Add(subfile); } return subfiles; }
public override List<IWriteFile> ReadHeader(FileStream stream, ppFormat format) { List<IWriteFile> subfiles = null; stream.Position = 0; BinaryReader binaryReader = new BinaryReader(stream); int numFiles = binaryReader.ReadInt32(); subfiles = new List<IWriteFile>(numFiles); binaryReader.ReadInt32(); // total size // get filenames for (int i = 0; i < numFiles; i++) { byte[] nameBuf = binaryReader.ReadBytes(0x20); for (int j = 0; j < nameBuf.Length; j++) { nameBuf[j] = (byte)(~nameBuf[j] + 1); } ppSubfile subfile = new ppSubfile(stream.Name); subfile.ppFormat = format; subfile.Name = Utility.EncodingShiftJIS.GetString(nameBuf).TrimEnd(new char[] { '\0' }); subfiles.Add(subfile); } // get filesizes uint offset = HeaderSize(numFiles); // start of first file data for (int i = 0; i < numFiles; i++) { ppSubfile subfile = (ppSubfile)subfiles[i]; subfile.offset = offset; subfile.size = binaryReader.ReadUInt32(); offset += subfile.size; } return subfiles; }
public override List <IWriteFile> ReadHeader(string path, ppFormat format) { return(ReadHeader(path, format, InitTableFigure())); }
public ppParser(string path, ppFormat format) { this.Format = format; this.FilePath = path; this.Subfiles = format.ppHeader.ReadHeader(path, format); }
public override List<IWriteFile> ReadHeader(FileStream stream, ppFormat format) { return ReadHeader(stream, format, null); }
public abstract List <IWriteFile> ReadHeader(FileStream stream, ppFormat format);
public abstract List <IWriteFile> ReadHeader(string path, ppFormat format);
public ppParser(FileStream stream, ppFormat format) { this.Format = format; this.FilePath = stream.Name; this.Subfiles = format.ppHeader.ReadHeader(stream, format); }
public override List <IWriteFile> ReadHeader(FileStream stream, ppFormat format) { return(ReadHeader(stream, format, InitTableFigure())); }
public override List<IWriteFile> ReadHeader(FileStream stream, ppFormat format) { return ReadHeader(stream, format, InitTableFigure()); }
private static ppFormat TryFile(ppSubfile subfile, ppFormat[] formats) { Func<ppSubfile, bool> tryFunc = null; string ext = Path.GetExtension(subfile.Name).ToLower(); if (ext == ".xx") { tryFunc = new Func<ppSubfile, bool>(TryFileXX); } else if (ext == ".xa") { tryFunc = new Func<ppSubfile, bool>(TryFileXA); } else if (ext == ".bmp") { tryFunc = new Func<ppSubfile, bool>(TryFileBMP); } else if (ext == ".tga") { tryFunc = new Func<ppSubfile, bool>(TryFileTGA); } else if (ext == ".ema") { tryFunc = new Func<ppSubfile, bool>(TryFileEMA); } else if (Utility.ImageSupported(ext)) { tryFunc = new Func<ppSubfile, bool>(TryFileImage); } else if (ext == ".lst") { tryFunc = new Func<ppSubfile, bool>(TryFileLst); } else if (ext == ".wav" || ext == ".ogg") { tryFunc = new Func<ppSubfile, bool>(TryFileSound); } if (tryFunc != null) { for (int i = 0; i < formats.Length; i++) { subfile.ppFormat = formats[i]; if (tryFunc(subfile)) { return subfile.ppFormat; } } } return null; }
public abstract List<IWriteFile> ReadHeader(FileStream stream, ppFormat format);
public override List<IWriteFile> ReadHeader(string path, ppFormat format) { return ReadHeader(path, format, InitTableFigure()); }
public override List<IWriteFile> ReadHeader(FileStream stream, ppFormat format) { List<IWriteFile> subfiles = null; stream.Position = 0; BinaryReader reader = new BinaryReader(stream); byte[] versionHeader = reader.ReadBytes(8); Version = BitConverter.ToInt32(ppHeader_SMRetail.DecryptHeaderBytes(reader.ReadBytes(4)), 0); ppHeader_SMRetail.DecryptHeaderBytes(reader.ReadBytes(1)); // first byte int numFiles = BitConverter.ToInt32(ppHeader_SMRetail.DecryptHeaderBytes(reader.ReadBytes(4)), 0); byte[] buf = ppHeader_SMRetail.DecryptHeaderBytes(reader.ReadBytes(numFiles * 288)); subfiles = new List<IWriteFile>(numFiles); for (int i = 0; i < numFiles; i++) { int offset = i * 288; ppSubfile subfile = new ppSubfile(stream.Name); subfile.ppFormat = format; int length = 260; for (int j = 0; j < length; j++) { if (buf[offset + j] == 0x00) { length = j; break; } } subfile.Name = Utility.EncodingShiftJIS.GetString(buf, offset, length); subfile.size = BitConverter.ToUInt32(buf, offset + 260); subfile.offset = BitConverter.ToUInt32(buf, offset + 264); Metadata metadata = new Metadata(); metadata.LastBytes = new byte[20]; System.Array.Copy(buf, offset + 268, metadata.LastBytes, 0, 20); subfile.Metadata = metadata; subfiles.Add(subfile); } return subfiles; }
public abstract List<IWriteFile> ReadHeader(string path, ppFormat format);
public override List <IWriteFile> ReadHeader(string path, ppFormat format) { return(ReadHeader(path, format, null)); }
public override List<IWriteFile> ReadHeader(string path, ppFormat format) { return ReadHeader(path, format, null); }
private static ppFormat TryFile(Stream stream, ppSubfile subfile, ppFormat[] formats) { Func<Stream, ppSubfile, bool> tryFunc = null; string ext = Path.GetExtension(subfile.Name).ToLower(); if (ext == ".xx") { tryFunc = new Func<Stream, ppSubfile, bool>(TryFileXX); } else if (ext == ".xa") { tryFunc = new Func<Stream, ppSubfile, bool>(TryFileXA); } else if (ext == ".svi") { tryFunc = new Func<Stream, ppSubfile, bool>(TryFileSVI); } else if (ext == ".sviex") { tryFunc = new Func<Stream, ppSubfile, bool>(TryFileSVIEX); } else if (ext == ".bmp") { tryFunc = new Func<Stream, ppSubfile, bool>(TryFileBMP); } else if (ext == ".tga") { tryFunc = new Func<Stream, ppSubfile, bool>(TryFileTGA); } else if (ext == ".ema") { tryFunc = new Func<Stream, ppSubfile, bool>(TryFileEMA); } else if (Utility.ImageSupported(ext)) { tryFunc = new Func<Stream, ppSubfile, bool>(TryFileImage); } else if (ext == ".lst") { tryFunc = new Func<Stream, ppSubfile, bool>(TryFileLst); } else if (ext == ".wav" || ext == ".ogg") { tryFunc = new Func<Stream, ppSubfile, bool>(TryFileSound); } if (tryFunc != null) { for (int i = 0; i < formats.Length; i++) { subfile.ppFormat = formats[i]; stream.Position = subfile.offset; if (tryFunc(subfile.ppFormat.ReadStream(new PartialStream(stream, subfile.size)), subfile)) { return subfile.ppFormat; } } } return null; }
public override List<IWriteFile> ReadHeader(string path, ppFormat format) { List<IWriteFile> subfiles = null; using (BinaryReader reader = new BinaryReader(File.OpenRead(path))) { byte[] versionHeader = reader.ReadBytes(8); int version = BitConverter.ToInt32(ppHeader_SMRetail.DecryptHeaderBytes(reader.ReadBytes(4)), 0); ppHeader_SMRetail.DecryptHeaderBytes(reader.ReadBytes(1)); // first byte int numFiles = BitConverter.ToInt32(ppHeader_SMRetail.DecryptHeaderBytes(reader.ReadBytes(4)), 0); byte[] buf = ppHeader_SMRetail.DecryptHeaderBytes(reader.ReadBytes(numFiles * 288)); subfiles = new List<IWriteFile>(numFiles); for (int i = 0; i < numFiles; i++) { int offset = i * 288; ppSubfile subfile = new ppSubfile(path); subfile.ppFormat = format; subfile.Name = Utility.EncodingShiftJIS.GetString(buf, offset, 260).TrimEnd(new char[] { '\0' }); subfile.size = BitConverter.ToInt32(buf, offset + 260); subfile.offset = BitConverter.ToInt32(buf, offset + 264); Metadata metadata = new Metadata(); metadata.LastBytes = new byte[20]; System.Array.Copy(buf, offset + 268, metadata.LastBytes, 0, 20); subfile.Metadata = metadata; subfiles.Add(subfile); } } return subfiles; }
public override List <IWriteFile> ReadHeader(FileStream stream, ppFormat format) { return(ReadHeader(stream, format, null)); }