public override bool Equals(object obj) { ByteArrFile iv2 = (ByteArrFile)obj;// as IntVector2; //if(iv2==null) return false; return((name.Equals(iv2.name)) && (bytes.Equals(iv2.bytes))); }
public static List <ByteArrFile> GetAllFiles(byte[] dumpedWad) { List <ByteArrFile> files = new List <ByteArrFile>(); //IWAD? PWAD? who the f**k cares. It's a bunch of lumps in any case //everything in little endian order //0x00 4 identification The ASCII characters "IWAD" or "PWAD". Defines whether the WAD is an IWAD or a PWAD. //0x04 4 numlumps An integer specifying the number of lumps in the WAD. //0x08 4 infotableofs An integer holding a pointer to the location of the directory. int fileCount = System.BitConverter.ToInt32(GetSubArray(ref dumpedWad, 0x04, 4), 0); int namesPosition = System.BitConverter.ToInt32(GetSubArray(ref dumpedWad, 0x08, 4), 0); // Debug.Log(fileCount+" "+namesPosition); //0x00 4 filepos An integer holding a pointer to the start of the lump's data in the file. //0x04 4 size An integer representing the size of the lump in bytes. //0x08 8 name An ASCII string defining the lump's name. Only the characters A-Z //(uppercase), 0-9, and [ ] - _ should be used in lump names //(an exception has to be made for some of the Arch-Vile sprites, which use "\"). When a string is less than 8 bytes long, it should be null-padded to the tight byte. int queryLength = namesPosition + fileCount * 16; for (int q = namesPosition; q < queryLength; q += 16) { int filePos = System.BitConverter.ToInt32(GetSubArray(ref dumpedWad, q, 4), 0); int fileSize = System.BitConverter.ToInt32(GetSubArray(ref dumpedWad, q + 4, 4), 0); byte[] arr2 = GetSubArray(ref dumpedWad, q + 8, 8); int mArrq = 8; for (int ar2c = 0; ar2c < arr2.Length; ar2c++) { if (arr2[ar2c] == 0x00)//all wad names are 8 bytes, unused bytes get filled out with 0x00s which causes resulting strings to have junk at their tail. { mArrq = ar2c; break; } } string name = System.Text.Encoding.ASCII.GetString(GetSubArray(ref arr2, 0, mArrq)); //string name=System.BitConverter.ToString(GetSubArray(ref dumpedWad, q+8, 8)); ByteArrFile tFile = new ByteArrFile(name); if (fileSize != 0) { tFile.bytes = GetSubArray(ref dumpedWad, filePos, fileSize); } files.Add(tFile); } return(files); }
private void OpenFile_Click(object sender, EventArgs e) { //OpenFileDialog.InitialDirectory = "c:\\"; OpenFileDialog.FileName = ""; OpenFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; OpenFileDialog.FilterIndex = 2; OpenFileDialog.RestoreDirectory = true; //var dialog = OpenFileDialog.ShowDialog(); //Stream myStream; if (OpenFileDialog.ShowDialog() == DialogResult.OK) { string fileName = OpenFileDialog.FileName; //string[] FileLines = File.ReadAllLines(fileName); ByteArrFile bar = new ByteArrFile("textmap"); bar.bytes = File.ReadAllBytes(fileName); List <string> fl = UDMF_TextmapEx.ReadFileToNodes(bar); //fl.AddRange(FileLines); OurMap = UDMF_TextmapEx.ReadFile(fl); Console.WriteLine("Passed"); } }
public static List <string> ReadFileToNodes(ByteArrFile bfile) { List <string> file = new List <string>(); MemoryStream ms = new MemoryStream(bfile.bytes); try { using (StreamReader sr = new StreamReader(ms)) { string q = sr.ReadToEnd(); MatchCollection mc = Regex.Matches(q, @".+\n{[^}]*}", RegexOptions.IgnoreCase); for (int b = 0; b < mc.Count; b++) { file.Add(mc[b].Value); } } } catch (Exception e) { Console.WriteLine("File could not be read:"); throw new System.Exception(e.Message); } return(file); }
public static byte[] GetBEVal(ref byte[] arr, int pos, int length) { byte[] t = GetSubArray(ref arr, pos, length); ByteArrFile.ReverseBytes(ref t); return(t); }