public static bool TryParse(byte[] entry, out HlsDosDirEntry hdde) { try { hdde = new HlsDosDirEntry( entry, Encoding.ASCII.GetString(entry).Substring(0, Encoding.ASCII.GetString(entry).IndexOf((char)0)), SwapEndianness32Bit(BitConverter.ToUInt32(entry, 32)), SwapEndianness32Bit(BitConverter.ToUInt32(entry, 36)), SwapEndianness32Bit(BitConverter.ToUInt32(entry, 40)), SwapEndianness16Bit(BitConverter.ToUInt16(entry, 44))); return(true); } catch { hdde = null; return(false); } }
private string _getDirectory() { /* The directory is contained in the first 10 sectors * starting at byte 42 with an entry siz eof 46 bytes */ var bytDir = _adfFile.GetSectors(0, 10); var intStartOfDirectory = 42; var intEntrySize = 46; StringBuilder sbText = new StringBuilder(); //read directory int idx = intStartOfDirectory; //first directory entry while (bytDir[idx] != 0) { //get entry byte[] bytEntry = new byte[intEntrySize]; Buffer.BlockCopy(bytDir, idx, bytEntry, 0, intEntrySize); if (HlsDosDirEntry.TryParse(bytEntry, out var hdde)) { //output to trace Trace.WriteLine(hdde.GetHexLine()); //collect dir entries sbText.Append(hdde.GetTextLine()); sbText.Append(Environment.NewLine); } //goto next entry idx += intEntrySize; } //output to trace Trace.WriteLine(sbText.ToString()); return(sbText.ToString()); }