diff --git a/DATFromDir/DATFromDir.cs b/DATFromDir/DATFromDir.cs index 1a7f6b3d..ca15d71e 100644 --- a/DATFromDir/DATFromDir.cs +++ b/DATFromDir/DATFromDir.cs @@ -492,9 +492,9 @@ namespace SabreTools long extractedsize = Convert.ToInt64(gzsize, 16); // Only try to add if the file size is greater than 2.5 GiB - if (filesize >= (2.5 * 1024 * 1024 * 1024)) + if (filesize >= (2.5 * Constants.GibiByte)) { - // ISIZE is mod 2^32, so we add that if the ISIZE is smaller than the filesize and header + // ISIZE is mod 4GiB, so we add that if the ISIZE is smaller than the filesize and header if (extractedsize < (filesize - neededHeaderSize)) { _logger.Log("Filename: '" + Path.GetFullPath(item) + "'\nExtracted file size: " + @@ -502,7 +502,7 @@ namespace SabreTools } while (extractedsize < (filesize - neededHeaderSize)) { - extractedsize += (long)Math.Pow(2, 32); + extractedsize += (4 * Constants.GibiByte); } _logger.Log("Final file size: " + extractedsize + "\nExtracted CRC: " + gzcrc + "\nExtracted MD5: " + gzmd5 + "\nSHA-1: " + Path.GetFileNameWithoutExtension(item)); diff --git a/SabreHelper/Data/Constants.cs b/SabreHelper/Data/Constants.cs index 4d5a4176..81a6bb20 100644 --- a/SabreHelper/Data/Constants.cs +++ b/SabreHelper/Data/Constants.cs @@ -1,4 +1,6 @@ -namespace SabreTools.Helper +using System; + +namespace SabreTools.Helper { public class Constants { @@ -47,5 +49,19 @@ public static string HeaderPatternCMP = @"(^.*?) \($"; public static string ItemPatternCMP = @"^\s*(\S*?) (.*)"; public static string EndPatternCMP = @"^\s*\)\s*$"; + + // Byte (1024-based) size comparisons + public static long KibiByte = 1024; + public static long MibiByte = (long)Math.Pow(KibiByte, 2); + public static long GibiByte = (long)Math.Pow(KibiByte, 3); + public static long TibiByte = (long)Math.Pow(KibiByte, 4); + public static long PibiByte = (long)Math.Pow(KibiByte, 5); + + // Byte (1000-based) size comparisons + public static long KiloByte = 1000; + public static long MegaByte = (long)Math.Pow(KiloByte, 2); + public static long GigaByte = (long)Math.Pow(KiloByte, 2); + public static long TeraByte = (long)Math.Pow(KiloByte, 2); + public static long PetaByte = (long)Math.Pow(KiloByte, 2); } }