public static PboFile FromStream(Stream input, PboLoadMode mode = PboLoadMode.Immediate) { var pbo = new PboFile(); while (input.Position < input.Length) { var e = new PboEntry(); e.ReadHeader(input); if (e.Path.Length == 0) { if (pbo._entries.Count != 0) { //this is the end of header marker break; } //this is a header extension so slurp up strings while (BinaryFile.ReadString(input).Length != 0) { } //System.Console.WriteLine("skipping " + config); ; } else { pbo._entries.Add(e); } } foreach (var pf in pbo) { pf.ReadBody(input, -1, mode); } return(pbo); }
/// <summary> /// Constructs a new PboFile from a mission folder /// </summary> /// <remarks> /// All files in the specified folder are added to the PboFile with the same /// relative directory structure as on disk /// The name of the folder is used as the MissionName and Path is set to the parent /// folder of the mission. /// </remarks> /// <param name="folder">Path of mission folder</param> /// <returns>A new PboFile object</returns> public static PboFile FromFolder(string folder) { var pbo = new PboFile { _createdFromFolder = true, _sourceFolder = System.IO.Path.GetDirectoryName(folder), MissionName = System.IO.Path.GetFileName(folder) }; var src = Directory.EnumerateFiles(folder, "*.*", SearchOption.AllDirectories).ToList(); foreach (var f in src) { pbo.AddFileFromFolder(f, folder); } return(pbo); }