diff --git a/SabreTools.Serialization/Models/MicrosoftCabinet/CFFILE.cs b/SabreTools.Serialization/Models/MicrosoftCabinet/CFFILE.cs index 14e47363..fd0a413e 100644 --- a/SabreTools.Serialization/Models/MicrosoftCabinet/CFFILE.cs +++ b/SabreTools.Serialization/Models/MicrosoftCabinet/CFFILE.cs @@ -60,6 +60,6 @@ /// CFFILE.szName field, but the _A_NAME_IS_UTF attribute is not set, the characters SHOULD be /// interpreted according to the current location. /// - public string? Name { get; set; } + public string Name { get; set; } } } diff --git a/SabreTools.Serialization/Models/MicrosoftCabinet/CFFOLDER.cs b/SabreTools.Serialization/Models/MicrosoftCabinet/CFFOLDER.cs index c94e10e2..905ad70f 100644 --- a/SabreTools.Serialization/Models/MicrosoftCabinet/CFFOLDER.cs +++ b/SabreTools.Serialization/Models/MicrosoftCabinet/CFFOLDER.cs @@ -51,6 +51,6 @@ /// /// Data blocks associated with this folder /// - public CFDATA[]? DataBlocks { get; set; } + public CFDATA[] DataBlocks { get; set; } } } diff --git a/SabreTools.Serialization/Models/MicrosoftCabinet/CFHEADER.cs b/SabreTools.Serialization/Models/MicrosoftCabinet/CFHEADER.cs index 3bd43b14..e333b3ee 100644 --- a/SabreTools.Serialization/Models/MicrosoftCabinet/CFHEADER.cs +++ b/SabreTools.Serialization/Models/MicrosoftCabinet/CFHEADER.cs @@ -11,7 +11,7 @@ /// Contains the characters "M", "S", "C", and "F" (bytes 0x4D, 0x53, 0x43, /// 0x46). This field is used to ensure that the file is a cabinet (.cab) file. /// - public string? Signature { get; set; } + public string Signature { get; set; } /// /// Reserved field; MUST be set to 0 (zero). diff --git a/SabreTools.Serialization/Models/MicrosoftCabinet/Cabinet.cs b/SabreTools.Serialization/Models/MicrosoftCabinet/Cabinet.cs index b5c1f949..25d79641 100644 --- a/SabreTools.Serialization/Models/MicrosoftCabinet/Cabinet.cs +++ b/SabreTools.Serialization/Models/MicrosoftCabinet/Cabinet.cs @@ -12,16 +12,16 @@ /// /// Cabinet header /// - public CFHEADER? Header { get; set; } + public CFHEADER Header { get; set; } /// /// One or more CFFOLDER entries /// - public CFFOLDER[]? Folders { get; set; } + public CFFOLDER[] Folders { get; set; } /// /// A series of one or more cabinet file (CFFILE) entries /// - public CFFILE[]? Files { get; set; } + public CFFILE[] Files { get; set; } } } diff --git a/SabreTools.Serialization/Models/MicrosoftCabinet/Constants.cs b/SabreTools.Serialization/Models/MicrosoftCabinet/Constants.cs index b4163a19..9faf5c68 100644 --- a/SabreTools.Serialization/Models/MicrosoftCabinet/Constants.cs +++ b/SabreTools.Serialization/Models/MicrosoftCabinet/Constants.cs @@ -8,4 +8,4 @@ namespace SabreTools.Data.Models.MicrosoftCabinet public const uint SignatureUInt32 = 0x4643534d; } -} \ No newline at end of file +} diff --git a/SabreTools.Serialization/Models/MicrosoftCabinet/Enums.cs b/SabreTools.Serialization/Models/MicrosoftCabinet/Enums.cs index d2725be5..6d2a5fc0 100644 --- a/SabreTools.Serialization/Models/MicrosoftCabinet/Enums.cs +++ b/SabreTools.Serialization/Models/MicrosoftCabinet/Enums.cs @@ -75,7 +75,7 @@ namespace SabreTools.Data.Models.MicrosoftCabinet /// /// Indicates that the folder index is actually zero, but that /// extraction of this file would have to begin with the cabinet named in the - /// CFHEADER.szCabinetPrev field. + /// CFHEADER.szCabinetPrev field. /// CONTINUED_FROM_PREV = 0xFFFD, diff --git a/SabreTools.Serialization/Wrappers/MicrosoftCabinet.Extraction.cs b/SabreTools.Serialization/Wrappers/MicrosoftCabinet.Extraction.cs index 122ecfa6..ccdf2f26 100644 --- a/SabreTools.Serialization/Wrappers/MicrosoftCabinet.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/MicrosoftCabinet.Extraction.cs @@ -87,7 +87,7 @@ namespace SabreTools.Serialization.Wrappers private MicrosoftCabinet? OpenNext(string? filename) { // Ignore invalid archives - if (Header == null || string.IsNullOrEmpty(filename)) + if (string.IsNullOrEmpty(filename)) return null; // Normalize the filename @@ -115,7 +115,7 @@ namespace SabreTools.Serialization.Wrappers private MicrosoftCabinet? OpenPrevious(string? filename) { // Ignore invalid archives - if (Header == null || string.IsNullOrEmpty(filename)) + if (string.IsNullOrEmpty(filename)) return null; // Normalize the filename @@ -222,7 +222,7 @@ namespace SabreTools.Serialization.Wrappers byte[] fileData = blockStream.ReadBytes((int)file.FileSize); // Ensure directory separators are consistent - string filename = file.Name!; + string filename = file.Name; if (Path.DirectorySeparatorChar == '\\') filename = filename.Replace('/', '\\'); else if (Path.DirectorySeparatorChar == '/') diff --git a/SabreTools.Serialization/Wrappers/MicrosoftCabinet.Printing.cs b/SabreTools.Serialization/Wrappers/MicrosoftCabinet.Printing.cs index 9c01b2bf..1bda9b41 100644 --- a/SabreTools.Serialization/Wrappers/MicrosoftCabinet.Printing.cs +++ b/SabreTools.Serialization/Wrappers/MicrosoftCabinet.Printing.cs @@ -23,17 +23,10 @@ namespace SabreTools.Serialization.Wrappers Print(builder, Model.Files); } - private static void Print(StringBuilder builder, CFHEADER? header) + private static void Print(StringBuilder builder, CFHEADER header) { builder.AppendLine(" Header Information:"); builder.AppendLine(" -------------------------"); - if (header == null) - { - builder.AppendLine(" No header"); - builder.AppendLine(); - return; - } - builder.AppendLine(header.Signature, " Signature"); builder.AppendLine(header.Reserved1, " Reserved 1"); builder.AppendLine(header.CabinetSize, " Cabinet size"); @@ -83,11 +76,11 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(); } - private static void Print(StringBuilder builder, CFFOLDER[]? entries) + private static void Print(StringBuilder builder, CFFOLDER[] entries) { builder.AppendLine(" Folders:"); builder.AppendLine(" -------------------------"); - if (entries == null || entries.Length == 0) + if (entries.Length == 0) { builder.AppendLine(" No folders"); builder.AppendLine(); @@ -108,7 +101,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(" Data Blocks"); builder.AppendLine(" -------------------------"); - if (entry.DataBlocks == null || entry.DataBlocks.Length == 0) + if (entry.DataBlocks.Length == 0) { builder.AppendLine(" No data blocks"); continue; @@ -130,11 +123,11 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(); } - private static void Print(StringBuilder builder, CFFILE[]? entries) + private static void Print(StringBuilder builder, CFFILE[] entries) { builder.AppendLine(" Files:"); builder.AppendLine(" -------------------------"); - if (entries == null || entries.Length == 0) + if (entries.Length == 0) { builder.AppendLine(" No files"); builder.AppendLine(); diff --git a/SabreTools.Serialization/Wrappers/MicrosoftCabinet.cs b/SabreTools.Serialization/Wrappers/MicrosoftCabinet.cs index 8135db87..db1f1166 100644 --- a/SabreTools.Serialization/Wrappers/MicrosoftCabinet.cs +++ b/SabreTools.Serialization/Wrappers/MicrosoftCabinet.cs @@ -17,25 +17,25 @@ namespace SabreTools.Serialization.Wrappers #region Extension Properties /// - public CFFILE[]? Files => Model.Files; + public CFFILE[] Files => Model.Files; /// - public int FileCount => Header?.FileCount ?? 0; + public int FileCount => Header.FileCount; /// - public CFFOLDER[]? Folders => Model.Folders; + public CFFOLDER[] Folders => Model.Folders; /// - public int FolderCount => Header?.FolderCount ?? 0; + public int FolderCount => Header.FolderCount; /// - public CFHEADER? Header => Model.Header; + public CFHEADER Header => Model.Header; /// - public string? CabinetNext => Header?.CabinetNext; + public string? CabinetNext => Header.CabinetNext; /// - public string? CabinetPrev => Header?.CabinetPrev; + public string? CabinetPrev => Header.CabinetPrev; #endregion @@ -162,7 +162,7 @@ namespace SabreTools.Serialization.Wrappers return file.FolderIndex switch { FolderIndex.CONTINUED_FROM_PREV => 0, - FolderIndex.CONTINUED_TO_NEXT => (Header?.FolderCount ?? 1) - 1, + FolderIndex.CONTINUED_TO_NEXT => Header.FolderCount - 1, FolderIndex.CONTINUED_PREV_AND_NEXT => 0, _ => (int)file.FolderIndex, }; @@ -199,8 +199,6 @@ namespace SabreTools.Serialization.Wrappers for (int i = 0; i < dataBlocks.Length; i++) { var db = dataBlocks[i]; - if (db.CompressedData == null) - continue; // Get the data to be processed byte[] blockData = db.CompressedData;