/// <summary> /// covers "Header" section in 7zFormat.txt (line 435~457) /// </summary> private void read_Header() { Console.WriteLine("[7z-parser] read Header"); Property_IDs flag = (Property_IDs)archive_file_reader.ReadByte(); //optional ArchiveProperties if (flag == Property_IDs.kArchiveProperties) { _Archive_Properties = read_Archive_Properties(); flag = (Property_IDs)archive_file_reader.ReadByte(); } //optional AdditionalStreamsInfo if (flag == Property_IDs.kAdditionalStreamsInfo) { _Additional_Streams_Info = read_Streams_info(); flag = (Property_IDs)archive_file_reader.ReadByte(); } //optional MainStreamsInfo if (flag == Property_IDs.kMainStreamsInfo) { _Main_Streams_Info = read_Streams_info(); flag = (Property_IDs)archive_file_reader.ReadByte(); } //Check kEnd assert(flag == Property_IDs.kEnd, "Expected kEnd (0x00), but got 0x" + Util.Byte_to_hex_string((byte)flag) + "\n" + "Stream position (decimal) = " + archive_file_reader.BaseStream.Position); Console.WriteLine("[7z-parser] read Header complete"); }
/// <summary> /// covers "Streams Info" section in 7zFormat.txt (line 341~358) /// </summary> private StreamsInfo read_Streams_info() { Console.WriteLine("[7z-parser] read Streams Info"); StreamsInfo streams_info = new StreamsInfo(); Property_IDs flag = (Property_IDs)archive_file_reader.ReadByte(); //handles optional PackInfo if (flag == Property_IDs.kPackInfo) { streams_info.packInfo = read_Pack_Info(); flag = (Property_IDs)archive_file_reader.ReadByte(); } else { streams_info.packInfo = null; } //handles optional CodersInfo if (flag == Property_IDs.kUnPackInfo) { streams_info.codersInfo = read_Coders_Info(); flag = (Property_IDs)archive_file_reader.ReadByte(); } else { streams_info.codersInfo = null; } //handles optional PackInfo if (flag == Property_IDs.kSubStreamsInfo) { streams_info.subStreamsInfo = read_SubStreams_info(); flag = (Property_IDs)archive_file_reader.ReadByte(); } else { streams_info.subStreamsInfo = null; } //Check kEnd assert(flag == Property_IDs.kEnd, "Expected kEnd (0x00), but got 0x" + Util.Byte_to_hex_string((byte)flag) + "\n" + "Stream position (decimal) = " + archive_file_reader.BaseStream.Position); Console.WriteLine("[7z-parser] read Header complete"); return(streams_info); }