public void extractFolder(ushort tag, string foldername, string pathname) { //if (br == null) br = new BinaryReader(new FileStream(_filename, FileMode.Open)); ushort num = 0; while (true) { br.BaseStream.Seek((PIRS_BASE + pirs_offset) + (num * 0x40), SeekOrigin.Begin); PirsEntry entry = new PirsEntry(); entry = getEntry(); if (String.IsNullOrWhiteSpace(entry.Filename.Trim())) { //br.Close(); return; } if (((entry.Cluster == 0) && (entry.Size == 0)) && (entry.Parent == tag)) { extractFolder(num, entry.Filename, pathname + @"\" + foldername); } else if ((entry.Cluster != 0) && (entry.Parent == tag)) { extractFile((long)entry.Cluster, (long)entry.Size, pathname + @"\" + foldername + @"\" + entry.Filename); } num = (ushort)(num + 1); } }
PirsEntry getEntry() { PirsEntry entry = new PirsEntry(); entry.Filename = readString(0x27); //Console.WriteLine(entry.FileName.Length); if (!String.IsNullOrWhiteSpace(entry.Filename.Trim())) { entry.Flags = br.ReadByte(); if (getBit(entry.Flags, 7)) { entry.Folder = true; } else { entry.Folder = false; } br.ReadBytes(0x3); entry.Blocklen = Oper.ByteArrayToInt(br.ReadBytes(0x3)); entry.Cluster = br.ReadInt32() >> 8; entry.Parent = (ushort)Convert.ToUInt32(Oper.ByteArrayToString(br.ReadBytes(2)), 16); entry.Size = Oper.ByteArrayToInt(br.ReadBytes(0x4)); entry.UpdateTime = dosDateTime(Oper.ByteArrayToInt(br.ReadBytes(0x4))); entry.AccessTime = dosDateTime(Oper.ByteArrayToInt(br.ReadBytes(0x4))); long pos = br.BaseStream.Position; entry.CRC = getCRC(br, entry.Cluster, entry.Size); br.BaseStream.Seek(pos, SeekOrigin.Begin); } return(entry); }
void getFiles() { int num = 0; if (!stealth) { Console.WriteLine("Getting Files.."); } while (true) { br.BaseStream.Seek(pirs_start + (num * 0x40), SeekOrigin.Begin); PirsEntry entry = new PirsEntry(); entry = getEntry(); if (String.IsNullOrWhiteSpace(entry.Filename.Trim())) { return; } if ((entry.Cluster != 0) || ((entry.Cluster == 0) && (entry.Size == 0))) { list.Add(entry); } num++; } }
private bool isFolder(PirsEntry p) { return(p.Folder); }