Formatting cleanup

This commit is contained in:
Matt Nadareski
2026-01-05 13:48:36 -05:00
parent 65a86d87f0
commit 2a6e193756
3 changed files with 14 additions and 17 deletions

View File

@@ -203,13 +203,13 @@ namespace SabreTools.Serialization.Readers
dataBlock.Checksum = data.ReadUInt32LittleEndian();
dataBlock.CompressedSize = data.ReadUInt16LittleEndian();
dataBlock.UncompressedSize = data.ReadUInt16LittleEndian();
if (dataReservedSize > 0)
data.SeekIfPossible(dataReservedSize, SeekOrigin.Current);
if (dataBlock.CompressedSize > 0)
data.SeekIfPossible(dataBlock.CompressedSize, SeekOrigin.Current);
return dataBlock;
}

View File

@@ -178,19 +178,18 @@ namespace SabreTools.Serialization.Wrappers
if (f == 0 && (cabinet.Files[0].FolderIndex == FolderIndex.CONTINUED_PREV_AND_NEXT
|| cabinet.Files[0].FolderIndex == FolderIndex.CONTINUED_FROM_PREV))
continue;
var folder = cabinet.Folders[f];
allExtracted &= cabinet.ExtractFolder(Filename, outputDirectory, folder, f, ignorePrev, includeDebug);
}
// Move to the next cabinet, if possible
Array.ForEach(cabinet.Folders, folder => folder.DataBlocks = []);
cabinet = cabinet.Next;
cabinet?.Prev = null;
// TODO: already-extracted data isn't being cleared from memory, at least not nearly enough.
if (cabinet?.Folders == null || cabinet.Folders.Length == 0)
break;
}
@@ -203,7 +202,7 @@ namespace SabreTools.Serialization.Wrappers
return false;
}
}
/// <summary>
/// Extract the contents of a single folder
/// </summary>
@@ -242,22 +241,21 @@ namespace SabreTools.Serialization.Wrappers
// debug output for inconsistencies would go here
continue;
}
fileList.Add(file);
}
CFFILE[] files = fileList.ToArray();
blockStream.SeekIfPossible(0, SeekOrigin.Begin);
for (int i = 0; i < files.Length; i++)
{
var file = files[i];
allExtracted &= ExtractFiles(outputDirectory, blockStream, file, includeDebug);
}
return allExtracted;
}
// TODO: this will apparently improve memory usage/performance, but it's not clear if this implementation is enough for that to happen
/// <summary>
/// Extract the contents of a single file, intended to be used with all files in a straight shot

View File

@@ -363,7 +363,7 @@ namespace SabreTools.Serialization.Wrappers
// Return all found blocks in order
return [.. prevBlocks, .. folder.DataBlocks, .. nextBlocks];
}
/// <summary>
/// Loads in all the datablocks for the current folder.
/// </summary>
@@ -390,9 +390,8 @@ namespace SabreTools.Serialization.Wrappers
offset += folder.DataBlocks[i].CompressedSize;
}
}
}
/// <summary>
/// Get all files for the current folder, plus connected spanned folders.
/// </summary>
@@ -423,7 +422,7 @@ namespace SabreTools.Serialization.Wrappers
int fileFolder = GetFolderIndex(f);
return fileFolder == folderIndex;
});
// Check if the folder spans in either direction
bool spanPrev = Array.Exists(files, f => f.FolderIndex == FolderIndex.CONTINUED_FROM_PREV || f.FolderIndex == FolderIndex.CONTINUED_PREV_AND_NEXT);
bool spanNext = Array.Exists(files, f => f.FolderIndex == FolderIndex.CONTINUED_TO_NEXT || f.FolderIndex == FolderIndex.CONTINUED_PREV_AND_NEXT);
@@ -443,7 +442,7 @@ namespace SabreTools.Serialization.Wrappers
prevFiles = Prev.GetSpannedFiles(filename, prevFolderIndex, skipNext: true) ?? [];
}
}
// If the folder spans forward and Next is not being skipped
CFFILE[] nextFiles = [];
if (!skipNext && spanNext)
@@ -459,7 +458,7 @@ namespace SabreTools.Serialization.Wrappers
nextFiles = Next.GetSpannedFiles(filename, 0, skipPrev: true) ?? [];
}
}
// Return all found files in order
return [.. prevFiles, .. files, .. nextFiles];
}