public override void Compile() { Trace.Indent(); PblFile file = PblFile.OpenPbl(this.FileName); file.LoadDirectory(); foreach (PblEntry ent in file.Entries) { string ext = ent.Name.Substring(ent.Name.Length - 3, 3); string name = ent.Name.Substring(0, ent.Name.Length - 4); LibraryObject newobj; switch (ext) { case "srf": newobj = new ObjectFunction(this, name, ent.Size); break; case "sra": newobj = new ObjectApplication(this, name, ent.Size); break; case "srm": newobj = new ObjectMenu(this, name, ent.Size); break; case "sru": newobj = new ObjectUserObject(this, name, ent.Size); break; case "srw": newobj = new ObjectWindow(this, name, ent.Size); break; default: newobj = null; break; } if (newobj != null) { this.AddObject(newobj); newobj.Script = file.LoadEntrySyntax(ent.Name); newobj.Comments = ent.Comments; newobj.Compile(); } } Trace.Unindent(); file.Close(); }
public static PblFile OpenPbl(string name) { FileStream f = new FileStream(name, FileMode.Open); PblFile pbl_file = null; PblVersion version = PblVersion.Unknown; try { f.Seek(IDENTIFICATION_OFFSET, SeekOrigin.Begin); int b = f.ReadByte(); if (b == 0x50) { b = f.ReadByte(); if (b == 0x00) { version = PblVersion.PBL105; } else if (b == 0x6F) { version = PblVersion.PBL070; } } } finally { f.Close(); } switch (version) { case PblVersion.PBL070: pbl_file = new PblFile070(name); break; case PblVersion.PBL105: pbl_file = new PblFile105(name); break; default: throw new PblFileException("Neznámý typ souboru PBL knihovny: " + name); } return(pbl_file); }