private static void ExtractPSARC(string filename, string path, Stream inputStream, Platform platform, bool isExternalFile = true) { string name = Path.GetFileNameWithoutExtension(filename); if (isExternalFile) { name += String.Format("_{0}", platform.platform.ToString()); } var psarc = new PSARC.PSARC(); psarc.Read(inputStream); foreach (var entry in psarc.Entries) { var fullfilename = Path.Combine(path, name, entry.Name); entry.Data.Seek(0, SeekOrigin.Begin); if (Path.GetExtension(entry.Name).ToLower() == ".psarc") { ExtractPSARC(fullfilename, Path.Combine(path, name), entry.Data, platform, false); } else { Directory.CreateDirectory(Path.GetDirectoryName(fullfilename)); using (var fileStream = File.Create(fullfilename)) { entry.Data.CopyTo(fileStream); entry.Data.Seek(0, SeekOrigin.Begin); entry.Data.Close(); //allow tmp file to be deleted. } } } }
/// <summary> /// Loads archive file to memory. /// </summary> /// <param name="fileName">Path of the .psarc file to open.</param> public PsarcBrowser(string fileName) { archive = new PSARC.PSARC(); platform = fileName.GetPlatform(); using (var stream = File.OpenRead(fileName)) { archive.Read(stream); } }
/// <summary> /// Loads archive file to memory. /// </summary> /// <param name="fileName">Path of the .psarc file to open.</param> public PsarcBrowser(string fileName) { archive = new PSARC.PSARC(); platform = fileName.GetPlatform(); using (var stream = File.OpenRead(fileName)) { archive.Read(stream); } }
private static void ExtractPSARC(string filename, string savePath, Stream inputStream, Platform platform, bool isExternalFile = true) { string psarcFilename = Path.GetFileNameWithoutExtension(filename); if (isExternalFile) { psarcFilename += String.Format("_{0}", platform.platform); } var destpath = Path.Combine(savePath, psarcFilename); if (Directory.Exists(destpath) && isExternalFile) { DirectoryExtension.SafeDelete(destpath); } var psarc = new PSARC.PSARC(); psarc.Read(inputStream, true); var step = Math.Round(1.0 / (psarc.TOC.Count + 2) * 100, 3); double progress = 0; GlobalExtension.ShowProgress("Inflating Entries ..."); foreach (var entry in psarc.TOC) { // custom InflateEntries // var debugMe = "Check the TOC"; var fullfilename = Path.Combine(destpath, entry.Name); if (Path.GetExtension(entry.Name).ToLower() == ".psarc") { psarc.InflateEntry(entry); ExtractPSARC(fullfilename, destpath, entry.Data, platform, false); } else { Directory.CreateDirectory(Path.GetDirectoryName(fullfilename)); psarc.InflateEntry(entry, fullfilename); if (entry.Data != null) { entry.Data.Dispose(); //Close(); } } if (!String.IsNullOrEmpty(psarc.ErrMSG)) { throw new InvalidDataException(psarc.ErrMSG); } progress += step; GlobalExtension.UpdateProgress.Value = (int)progress; } // GlobalExtension.HideProgress(); }
private static void ExtractPSARC(string filename, string savePath, Stream inputStream, Platform platform, bool isExternalFile = true) { string psarcFilename = Path.GetFileNameWithoutExtension(filename); if (isExternalFile) { psarcFilename += String.Format("_{0}", platform.platform); } var destpath = Path.Combine(savePath, psarcFilename); if (Directory.Exists(destpath) && isExternalFile) { DirectoryExtension.SafeDelete(destpath); } var psarc = new PSARC.PSARC(); psarc.Read(inputStream, true); foreach (var entry in psarc.TOC) {// custom InflateEntries var fullfilename = Path.Combine(destpath, entry.Name); if (Path.GetExtension(entry.Name).ToLower() == ".psarc") { psarc.InflateEntry(entry); ExtractPSARC(fullfilename, destpath, entry.Data, platform, false); } else { Directory.CreateDirectory(Path.GetDirectoryName(fullfilename)); psarc.InflateEntry(entry, fullfilename); if (entry.Data != null) { entry.Data.Close(); } } if (!String.IsNullOrEmpty(psarc.ErrMSG)) { throw new InvalidDataException(psarc.ErrMSG); } } }
private static void ExtractPSARC(string filename, string savePath, Stream inputStream, Platform platform, bool isExternalFile = true) { string psarcFilename = Path.GetFileNameWithoutExtension(filename); if (isExternalFile) psarcFilename += String.Format("_{0}", platform.platform); var destpath = Path.Combine(savePath, psarcFilename); if (Directory.Exists(destpath) && isExternalFile) DirectoryExtension.SafeDelete(destpath); var psarc = new PSARC.PSARC(); psarc.Read(inputStream, true); var step = Math.Round(1.0 / (psarc.TOC.Count + 2) * 100, 3); double progress = 0; GlobalExtension.ShowProgress("Inflating Entries ..."); foreach (var entry in psarc.TOC) {// custom InflateEntries var fullfilename = Path.Combine(destpath, entry.Name); if (Path.GetExtension(entry.Name).ToLower() == ".psarc") { psarc.InflateEntry(entry); ExtractPSARC(fullfilename, destpath, entry.Data, platform, false); } else { Directory.CreateDirectory(Path.GetDirectoryName(fullfilename)); psarc.InflateEntry(entry, fullfilename); if (entry.Data != null) { entry.Data.Dispose(); //Close(); } } if (!String.IsNullOrEmpty(psarc.ErrMSG)) throw new InvalidDataException(psarc.ErrMSG); progress += step; GlobalExtension.UpdateProgress.Value = (int)progress; } // GlobalExtension.HideProgress(); }
private static void ExtractPSARC(string filename, string path, Stream inputStream, Platform platform, bool isExternalFile = true) { string name = Path.GetFileNameWithoutExtension(filename); if (isExternalFile) name += String.Format("_{0}", platform.platform.ToString()); var psarc = new PSARC.PSARC(); psarc.Read(inputStream); foreach (var entry in psarc.Entries) { var fullfilename = Path.Combine(path, name, entry.Name); entry.Data.Seek(0, SeekOrigin.Begin); if (Path.GetExtension(entry.Name).ToLower() == ".psarc") { ExtractPSARC(fullfilename, Path.Combine(path, name), entry.Data, platform, false); } else { Directory.CreateDirectory(Path.GetDirectoryName(fullfilename)); using (var fileStream = File.Create(fullfilename)) { entry.Data.CopyTo(fileStream); entry.Data.Seek(0, SeekOrigin.Begin); entry.Data.Close(); //allow tmp file to be deleted. } } } }