Skip to content

Commit

Permalink
More improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
gus33000 committed Oct 5, 2024
1 parent ccc3e53 commit b27b74c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions Img2Ffu.Library/Reader/Data/ImageFlash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ public ulong GetDataBlockCount()
ulong dataBlockCount = 0;
foreach (Store store in Stores)
{
dataBlockCount += (ulong)store.WriteDescriptors.Count;
dataBlockCount += (ulong)store.WriteDescriptors.LongCount();
}
return dataBlockCount;
}

public Span<byte> GetDataBlock(Stream Stream, ulong dataBlockIndex)
{
ulong dataBlockIndexOffset = 0;
for (ulong storeIndex = 0; storeIndex < (ulong)Stores.Count; storeIndex++)
for (ulong storeIndex = 0; storeIndex < (ulong)Stores.LongCount(); storeIndex++)
{
ulong storeDataBlockCount = GetStoreDataBlockCount(storeIndex);
if (dataBlockIndexOffset + storeDataBlockCount > dataBlockIndex)
Expand All @@ -155,7 +155,7 @@ public Span<byte> GetDataBlock(Stream Stream, ulong dataBlockIndex)

public ulong GetStoreDataBlockCount(ulong storeIndex)
{
return (ulong)Stores[(int)storeIndex].WriteDescriptors.Count;
return (ulong)Stores[(int)storeIndex].WriteDescriptors.LongCount();
}

public byte[] GetStoreDataBlock(Stream Stream, ulong storeIndex, ulong dataBlockIndex)
Expand Down
2 changes: 1 addition & 1 deletion Img2Ffu.Library/Reader/Data/WriteDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public byte[] GetBytes()
{
List<byte> bytes = [];

BlockDataEntry.LocationCount = (uint)DiskLocations.Count;
BlockDataEntry.LocationCount = (uint)DiskLocations.LongCount();

bytes.AddRange(BlockDataEntry.GetBytes());

Expand Down
8 changes: 4 additions & 4 deletions Img2Ffu.Library/Reader/FullFlashUpdateReaderStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ public FullFlashUpdateReaderStream(string FFUFilePath, ulong storeIndex)
catch { }
}

public static int GetStoreCount(string FFUFilePath)
public static ulong GetStoreCount(string FFUFilePath)
{
using FileStream ffuStream = File.Open(FFUFilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
SignedImage ffuFile = new(ffuStream);
return ffuFile.Image.Stores.Count;
return (ulong)ffuFile.Image.Stores.LongCount();
}

private static (int minSectorCount, int minSectorSize)[] ExtractImageManifestStoreInformation(SignedImage ffuFile)
Expand Down Expand Up @@ -146,7 +146,7 @@ private static (int minSectorCount, int minSectorSize)[] ExtractImageManifestSto
long blockMaxStart = 0;
long blockMaxEnd = 0;

for (int i = 0; i < store.WriteDescriptors.Count; i++)
for (int i = 0; i < store.WriteDescriptors.LongCount(); i++)
{
WriteDescriptor writeDescriptor = store.WriteDescriptors[i];
foreach (DiskLocation diskLocation in writeDescriptor.DiskLocations)
Expand Down Expand Up @@ -354,7 +354,7 @@ public void CopyTo(Stream DestinationStream, Action<ulong, ulong> ProgressCallBa
for (int i = 0; i < store.WriteDescriptors.Count; i++)
{
WriteDescriptor writeDescriptor = store.WriteDescriptors[i];
totalBytes += (ulong)writeDescriptor.DiskLocations.Count;
totalBytes += (ulong)writeDescriptor.DiskLocations.LongCount();
}

totalBytes *= (ulong)blockSize * 2u;
Expand Down

0 comments on commit b27b74c

Please sign in to comment.