mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 12:53:09 +00:00
[SETUPLIB] Introduce defines for size units.
[USETUP] Use them in the code. svn path=/branches/setup_improvements/; revision=75508
This commit is contained in:
parent
a95581c4c2
commit
9348fe1f7e
3 changed files with 58 additions and 46 deletions
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
/* Needed PSDK headers when using this library */
|
/* Needed PSDK headers when using this library */
|
||||||
#if 0
|
#if 0
|
||||||
|
|
||||||
|
@ -37,4 +39,14 @@ extern HANDLE ProcessHeap;
|
||||||
#include "regutil.h"
|
#include "regutil.h"
|
||||||
#include "registry.h"
|
#include "registry.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* DEFINES ******************************************************************/
|
||||||
|
|
||||||
|
#define KB ((ULONGLONG)1024)
|
||||||
|
#define MB (KB*KB)
|
||||||
|
#define GB (KB*KB*KB)
|
||||||
|
// #define TB (KB*KB*KB*KB)
|
||||||
|
// #define PB (KB*KB*KB*KB*KB)
|
||||||
|
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -292,21 +292,21 @@ PrintPartitionData(
|
||||||
{
|
{
|
||||||
PartSize.QuadPart = PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
|
PartSize.QuadPart = PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
|
||||||
#if 0
|
#if 0
|
||||||
if (PartSize.QuadPart >= 10737418240) /* 10 GB */
|
if (PartSize.QuadPart >= 10 * GB) /* 10 GB */
|
||||||
{
|
{
|
||||||
PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, 1073741824);
|
PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, GB);
|
||||||
Unit = MUIGetString(STRING_GB);
|
Unit = MUIGetString(STRING_GB);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (PartSize.QuadPart >= 10485760) /* 10 MB */
|
if (PartSize.QuadPart >= 10 * MB) /* 10 MB */
|
||||||
{
|
{
|
||||||
PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, 1048576);
|
PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, MB);
|
||||||
Unit = MUIGetString(STRING_MB);
|
Unit = MUIGetString(STRING_MB);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, 1024);
|
PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, KB);
|
||||||
Unit = MUIGetString(STRING_KB);
|
Unit = MUIGetString(STRING_KB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,21 +335,21 @@ PrintPartitionData(
|
||||||
|
|
||||||
PartSize.QuadPart = PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
|
PartSize.QuadPart = PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
|
||||||
#if 0
|
#if 0
|
||||||
if (PartSize.QuadPart >= 10737418240) /* 10 GB */
|
if (PartSize.QuadPart >= 10 * GB) /* 10 GB */
|
||||||
{
|
{
|
||||||
PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, 1073741824);
|
PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, GB);
|
||||||
Unit = MUIGetString(STRING_GB);
|
Unit = MUIGetString(STRING_GB);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (PartSize.QuadPart >= 10485760) /* 10 MB */
|
if (PartSize.QuadPart >= 10 * MB) /* 10 MB */
|
||||||
{
|
{
|
||||||
PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, 1048576);
|
PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, MB);
|
||||||
Unit = MUIGetString(STRING_MB);
|
Unit = MUIGetString(STRING_MB);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, 1024);
|
PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, KB);
|
||||||
Unit = MUIGetString(STRING_KB);
|
Unit = MUIGetString(STRING_KB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,14 +442,14 @@ PrintDiskData(
|
||||||
coPos.Y = ListUi->Top + 1 + ListUi->Line;
|
coPos.Y = ListUi->Top + 1 + ListUi->Line;
|
||||||
|
|
||||||
DiskSize.QuadPart = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
|
DiskSize.QuadPart = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
|
||||||
if (DiskSize.QuadPart >= 10737418240) /* 10 GB */
|
if (DiskSize.QuadPart >= 10 * GB) /* 10 GB */
|
||||||
{
|
{
|
||||||
DiskSize.QuadPart = RoundingDivide(DiskSize.QuadPart, 1073741824);
|
DiskSize.QuadPart = RoundingDivide(DiskSize.QuadPart, GB);
|
||||||
Unit = MUIGetString(STRING_GB);
|
Unit = MUIGetString(STRING_GB);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DiskSize.QuadPart = RoundingDivide(DiskSize.QuadPart, 1048576);
|
DiskSize.QuadPart = RoundingDivide(DiskSize.QuadPart, MB);
|
||||||
if (DiskSize.QuadPart == 0)
|
if (DiskSize.QuadPart == 0)
|
||||||
DiskSize.QuadPart = 1;
|
DiskSize.QuadPart = 1;
|
||||||
Unit = MUIGetString(STRING_MB);
|
Unit = MUIGetString(STRING_MB);
|
||||||
|
|
|
@ -1702,7 +1702,7 @@ IsDiskSizeValid(PPARTENTRY PartEntry)
|
||||||
ULONGLONG size;
|
ULONGLONG size;
|
||||||
|
|
||||||
size = PartEntry->SectorCount.QuadPart * PartEntry->DiskEntry->BytesPerSector;
|
size = PartEntry->SectorCount.QuadPart * PartEntry->DiskEntry->BytesPerSector;
|
||||||
size = (size + 524288) / 1048576; /* in MBytes */
|
size = (size + (512 * KB)) / MB; /* in MBytes */
|
||||||
|
|
||||||
if (size < RequiredPartitionDiskSpace)
|
if (size < RequiredPartitionDiskSpace)
|
||||||
{
|
{
|
||||||
|
@ -2215,15 +2215,15 @@ CreatePrimaryPartitionPage(PINPUT_RECORD Ir)
|
||||||
|
|
||||||
DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
|
DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
|
||||||
#if 0
|
#if 0
|
||||||
if (DiskSize >= 10737418240) /* 10 GB */
|
if (DiskSize >= 10 * GB) /* 10 GB */
|
||||||
{
|
{
|
||||||
DiskSize = DiskSize / 1073741824;
|
DiskSize = DiskSize / GB;
|
||||||
Unit = MUIGetString(STRING_GB);
|
Unit = MUIGetString(STRING_GB);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
DiskSize = DiskSize / 1048576;
|
DiskSize = DiskSize / MB;
|
||||||
if (DiskSize == 0)
|
if (DiskSize == 0)
|
||||||
DiskSize = 1;
|
DiskSize = 1;
|
||||||
|
|
||||||
|
@ -2260,7 +2260,7 @@ CreatePrimaryPartitionPage(PINPUT_RECORD Ir)
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
|
CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
|
||||||
PartitionList->CurrentPartition->SectorCount * DiskEntry->BytesPerSector / 1048576);
|
PartitionList->CurrentPartition->SectorCount * DiskEntry->BytesPerSector / MB);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION));
|
CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION));
|
||||||
|
@ -2268,7 +2268,7 @@ CreatePrimaryPartitionPage(PINPUT_RECORD Ir)
|
||||||
PartEntry = PartitionList->CurrentPartition;
|
PartEntry = PartitionList->CurrentPartition;
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
MaxSize = (PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector) / 1048576; /* in MBytes (rounded) */
|
MaxSize = (PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector) / MB; /* in MBytes (rounded) */
|
||||||
|
|
||||||
if (MaxSize > PARTITION_MAXSIZE)
|
if (MaxSize > PARTITION_MAXSIZE)
|
||||||
MaxSize = PARTITION_MAXSIZE;
|
MaxSize = PARTITION_MAXSIZE;
|
||||||
|
@ -2312,7 +2312,7 @@ CreatePrimaryPartitionPage(PINPUT_RECORD Ir)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Calculate the sector count from the size in MB */
|
/* Calculate the sector count from the size in MB */
|
||||||
SectorCount = PartSize * 1048576 / DiskEntry->BytesPerSector;
|
SectorCount = PartSize * MB / DiskEntry->BytesPerSector;
|
||||||
|
|
||||||
/* But never get larger than the unpartitioned disk space */
|
/* But never get larger than the unpartitioned disk space */
|
||||||
if (SectorCount > PartEntry->SectorCount.QuadPart)
|
if (SectorCount > PartEntry->SectorCount.QuadPart)
|
||||||
|
@ -2374,15 +2374,15 @@ CreateExtendedPartitionPage(PINPUT_RECORD Ir)
|
||||||
|
|
||||||
DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
|
DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
|
||||||
#if 0
|
#if 0
|
||||||
if (DiskSize >= 10737418240) /* 10 GB */
|
if (DiskSize >= 10 * GB) /* 10 GB */
|
||||||
{
|
{
|
||||||
DiskSize = DiskSize / 1073741824;
|
DiskSize = DiskSize / GB;
|
||||||
Unit = MUIGetString(STRING_GB);
|
Unit = MUIGetString(STRING_GB);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
DiskSize = DiskSize / 1048576;
|
DiskSize = DiskSize / MB;
|
||||||
if (DiskSize == 0)
|
if (DiskSize == 0)
|
||||||
DiskSize = 1;
|
DiskSize = 1;
|
||||||
|
|
||||||
|
@ -2419,7 +2419,7 @@ CreateExtendedPartitionPage(PINPUT_RECORD Ir)
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
|
CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
|
||||||
PartitionList->CurrentPartition->SectorCount * DiskEntry->BytesPerSector / 1048576);
|
PartitionList->CurrentPartition->SectorCount * DiskEntry->BytesPerSector / MB);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION));
|
CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION));
|
||||||
|
@ -2427,7 +2427,7 @@ CreateExtendedPartitionPage(PINPUT_RECORD Ir)
|
||||||
PartEntry = PartitionList->CurrentPartition;
|
PartEntry = PartitionList->CurrentPartition;
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
MaxSize = (PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector) / 1048576; /* in MBytes (rounded) */
|
MaxSize = (PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector) / MB; /* in MBytes (rounded) */
|
||||||
|
|
||||||
if (MaxSize > PARTITION_MAXSIZE)
|
if (MaxSize > PARTITION_MAXSIZE)
|
||||||
MaxSize = PARTITION_MAXSIZE;
|
MaxSize = PARTITION_MAXSIZE;
|
||||||
|
@ -2471,7 +2471,7 @@ CreateExtendedPartitionPage(PINPUT_RECORD Ir)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Calculate the sector count from the size in MB */
|
/* Calculate the sector count from the size in MB */
|
||||||
SectorCount = PartSize * 1048576 / DiskEntry->BytesPerSector;
|
SectorCount = PartSize * MB / DiskEntry->BytesPerSector;
|
||||||
|
|
||||||
/* But never get larger than the unpartitioned disk space */
|
/* But never get larger than the unpartitioned disk space */
|
||||||
if (SectorCount > PartEntry->SectorCount.QuadPart)
|
if (SectorCount > PartEntry->SectorCount.QuadPart)
|
||||||
|
@ -2532,15 +2532,15 @@ CreateLogicalPartitionPage(PINPUT_RECORD Ir)
|
||||||
|
|
||||||
DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
|
DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
|
||||||
#if 0
|
#if 0
|
||||||
if (DiskSize >= 10737418240) /* 10 GB */
|
if (DiskSize >= 10 * GB) /* 10 GB */
|
||||||
{
|
{
|
||||||
DiskSize = DiskSize / 1073741824;
|
DiskSize = DiskSize / GB;
|
||||||
Unit = MUIGetString(STRING_GB);
|
Unit = MUIGetString(STRING_GB);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
DiskSize = DiskSize / 1048576;
|
DiskSize = DiskSize / MB;
|
||||||
if (DiskSize == 0)
|
if (DiskSize == 0)
|
||||||
DiskSize = 1;
|
DiskSize = 1;
|
||||||
|
|
||||||
|
@ -2577,7 +2577,7 @@ CreateLogicalPartitionPage(PINPUT_RECORD Ir)
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
|
CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
|
||||||
PartitionList->CurrentPartition->SectorCount * DiskEntry->BytesPerSector / 1048576);
|
PartitionList->CurrentPartition->SectorCount * DiskEntry->BytesPerSector / MB);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION));
|
CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION));
|
||||||
|
@ -2585,7 +2585,7 @@ CreateLogicalPartitionPage(PINPUT_RECORD Ir)
|
||||||
PartEntry = PartitionList->CurrentPartition;
|
PartEntry = PartitionList->CurrentPartition;
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
MaxSize = (PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector) / 1048576; /* in MBytes (rounded) */
|
MaxSize = (PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector) / MB; /* in MBytes (rounded) */
|
||||||
|
|
||||||
if (MaxSize > PARTITION_MAXSIZE)
|
if (MaxSize > PARTITION_MAXSIZE)
|
||||||
MaxSize = PARTITION_MAXSIZE;
|
MaxSize = PARTITION_MAXSIZE;
|
||||||
|
@ -2629,7 +2629,7 @@ CreateLogicalPartitionPage(PINPUT_RECORD Ir)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Calculate the sector count from the size in MB */
|
/* Calculate the sector count from the size in MB */
|
||||||
SectorCount = PartSize * 1048576 / DiskEntry->BytesPerSector;
|
SectorCount = PartSize * MB / DiskEntry->BytesPerSector;
|
||||||
|
|
||||||
/* But never get larger than the unpartitioned disk space */
|
/* But never get larger than the unpartitioned disk space */
|
||||||
if (SectorCount > PartEntry->SectorCount.QuadPart)
|
if (SectorCount > PartEntry->SectorCount.QuadPart)
|
||||||
|
@ -2730,21 +2730,21 @@ DeletePartitionPage(PINPUT_RECORD Ir)
|
||||||
|
|
||||||
PartSize = PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
|
PartSize = PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
|
||||||
#if 0
|
#if 0
|
||||||
if (PartSize >= 10737418240) /* 10 GB */
|
if (PartSize >= 10 * GB) /* 10 GB */
|
||||||
{
|
{
|
||||||
PartSize = PartSize / 1073741824;
|
PartSize = PartSize / GB;
|
||||||
Unit = MUIGetString(STRING_GB);
|
Unit = MUIGetString(STRING_GB);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (PartSize >= 10485760) /* 10 MB */
|
if (PartSize >= 10 * MB) /* 10 MB */
|
||||||
{
|
{
|
||||||
PartSize = PartSize / 1048576;
|
PartSize = PartSize / MB;
|
||||||
Unit = MUIGetString(STRING_MB);
|
Unit = MUIGetString(STRING_MB);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PartSize = PartSize / 1024;
|
PartSize = PartSize / KB;
|
||||||
Unit = MUIGetString(STRING_KB);
|
Unit = MUIGetString(STRING_KB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2771,15 +2771,15 @@ DeletePartitionPage(PINPUT_RECORD Ir)
|
||||||
|
|
||||||
DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
|
DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
|
||||||
#if 0
|
#if 0
|
||||||
if (DiskSize >= 10737418240) /* 10 GB */
|
if (DiskSize >= 10 * GB) /* 10 GB */
|
||||||
{
|
{
|
||||||
DiskSize = DiskSize / 1073741824;
|
DiskSize = DiskSize / GB;
|
||||||
Unit = MUIGetString(STRING_GB);
|
Unit = MUIGetString(STRING_GB);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
DiskSize = DiskSize / 1048576;
|
DiskSize = DiskSize / MB;
|
||||||
if (DiskSize == 0)
|
if (DiskSize == 0)
|
||||||
DiskSize = 1;
|
DiskSize = 1;
|
||||||
|
|
||||||
|
@ -2980,27 +2980,27 @@ SelectFileSystemPage(PINPUT_RECORD Ir)
|
||||||
|
|
||||||
/* Adjust disk size */
|
/* Adjust disk size */
|
||||||
DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
|
DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
|
||||||
if (DiskSize >= 10737418240) /* 10 GB */
|
if (DiskSize >= 10 * GB) /* 10 GB */
|
||||||
{
|
{
|
||||||
DiskSize = DiskSize / 1073741824;
|
DiskSize = DiskSize / GB;
|
||||||
DiskUnit = MUIGetString(STRING_GB);
|
DiskUnit = MUIGetString(STRING_GB);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DiskSize = DiskSize / 1048576;
|
DiskSize = DiskSize / MB;
|
||||||
DiskUnit = MUIGetString(STRING_MB);
|
DiskUnit = MUIGetString(STRING_MB);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Adjust partition size */
|
/* Adjust partition size */
|
||||||
PartSize = PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
|
PartSize = PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
|
||||||
if (PartSize >= 10737418240) /* 10 GB */
|
if (PartSize >= 10 * GB) /* 10 GB */
|
||||||
{
|
{
|
||||||
PartSize = PartSize / 1073741824;
|
PartSize = PartSize / GB;
|
||||||
PartUnit = MUIGetString(STRING_GB);
|
PartUnit = MUIGetString(STRING_GB);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PartSize = PartSize / 1048576;
|
PartSize = PartSize / MB;
|
||||||
PartUnit = MUIGetString(STRING_MB);
|
PartUnit = MUIGetString(STRING_MB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue