Author: hbelusca
Date: Tue Aug 8 14:05:20 2017
New Revision: 75508
URL:
http://svn.reactos.org/svn/reactos?rev=75508&view=rev
Log:
[SETUPLIB]: Introduce defines for size units.
[USETUP]: Use them in the code.
Modified:
branches/setup_improvements/base/setup/lib/setuplib.h
branches/setup_improvements/base/setup/usetup/interface/usetup.c
branches/setup_improvements/base/setup/usetup/partlist.c
Modified: branches/setup_improvements/base/setup/lib/setuplib.h
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
==============================================================================
--- branches/setup_improvements/base/setup/lib/setuplib.h [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/lib/setuplib.h [iso-8859-1] Tue Aug 8 14:05:20
2017
@@ -7,6 +7,8 @@
*/
#pragma once
+
+/* INCLUDES *****************************************************************/
/* Needed PSDK headers when using this library */
#if 0
@@ -38,4 +40,14 @@
#include "regutil.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 */
Modified: branches/setup_improvements/base/setup/usetup/interface/usetup.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
==============================================================================
--- branches/setup_improvements/base/setup/usetup/interface/usetup.c [iso-8859-1]
(original)
+++ branches/setup_improvements/base/setup/usetup/interface/usetup.c [iso-8859-1] Tue Aug
8 14:05:20 2017
@@ -1649,7 +1649,7 @@
ULONGLONG size;
size = PartEntry->SectorCount.QuadPart *
PartEntry->DiskEntry->BytesPerSector;
- size = (size + 524288) / 1048576; /* in MBytes */
+ size = (size + (512 * KB)) / MB; /* in MBytes */
if (size < RequiredPartitionDiskSpace)
{
@@ -2096,15 +2096,15 @@
DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
#if 0
- if (DiskSize >= 10737418240) /* 10 GB */
- {
- DiskSize = DiskSize / 1073741824;
+ if (DiskSize >= 10 * GB) /* 10 GB */
+ {
+ DiskSize = DiskSize / GB;
Unit = MUIGetString(STRING_GB);
}
else
#endif
{
- DiskSize = DiskSize / 1048576;
+ DiskSize = DiskSize / MB;
if (DiskSize == 0)
DiskSize = 1;
@@ -2141,7 +2141,7 @@
#if 0
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
CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION));
@@ -2149,7 +2149,7 @@
PartEntry = PartitionList->CurrentPartition;
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)
MaxSize = PARTITION_MAXSIZE;
@@ -2193,7 +2193,7 @@
else
{
/* 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 */
if (SectorCount > PartEntry->SectorCount.QuadPart)
@@ -2255,15 +2255,15 @@
DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
#if 0
- if (DiskSize >= 10737418240) /* 10 GB */
- {
- DiskSize = DiskSize / 1073741824;
+ if (DiskSize >= 10 * GB) /* 10 GB */
+ {
+ DiskSize = DiskSize / GB;
Unit = MUIGetString(STRING_GB);
}
else
#endif
{
- DiskSize = DiskSize / 1048576;
+ DiskSize = DiskSize / MB;
if (DiskSize == 0)
DiskSize = 1;
@@ -2300,7 +2300,7 @@
#if 0
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
CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION));
@@ -2308,7 +2308,7 @@
PartEntry = PartitionList->CurrentPartition;
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)
MaxSize = PARTITION_MAXSIZE;
@@ -2352,7 +2352,7 @@
else
{
/* 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 */
if (SectorCount > PartEntry->SectorCount.QuadPart)
@@ -2413,15 +2413,15 @@
DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
#if 0
- if (DiskSize >= 10737418240) /* 10 GB */
- {
- DiskSize = DiskSize / 1073741824;
+ if (DiskSize >= 10 * GB) /* 10 GB */
+ {
+ DiskSize = DiskSize / GB;
Unit = MUIGetString(STRING_GB);
}
else
#endif
{
- DiskSize = DiskSize / 1048576;
+ DiskSize = DiskSize / MB;
if (DiskSize == 0)
DiskSize = 1;
@@ -2458,7 +2458,7 @@
#if 0
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
CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION));
@@ -2466,7 +2466,7 @@
PartEntry = PartitionList->CurrentPartition;
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)
MaxSize = PARTITION_MAXSIZE;
@@ -2510,7 +2510,7 @@
else
{
/* 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 */
if (SectorCount > PartEntry->SectorCount.QuadPart)
@@ -2611,21 +2611,21 @@
PartSize = PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
#if 0
- if (PartSize >= 10737418240) /* 10 GB */
- {
- PartSize = PartSize / 1073741824;
+ if (PartSize >= 10 * GB) /* 10 GB */
+ {
+ PartSize = PartSize / GB;
Unit = MUIGetString(STRING_GB);
}
else
#endif
- if (PartSize >= 10485760) /* 10 MB */
- {
- PartSize = PartSize / 1048576;
+ if (PartSize >= 10 * MB) /* 10 MB */
+ {
+ PartSize = PartSize / MB;
Unit = MUIGetString(STRING_MB);
}
else
{
- PartSize = PartSize / 1024;
+ PartSize = PartSize / KB;
Unit = MUIGetString(STRING_KB);
}
@@ -2652,15 +2652,15 @@
DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
#if 0
- if (DiskSize >= 10737418240) /* 10 GB */
- {
- DiskSize = DiskSize / 1073741824;
+ if (DiskSize >= 10 * GB) /* 10 GB */
+ {
+ DiskSize = DiskSize / GB;
Unit = MUIGetString(STRING_GB);
}
else
#endif
{
- DiskSize = DiskSize / 1048576;
+ DiskSize = DiskSize / MB;
if (DiskSize == 0)
DiskSize = 1;
@@ -2861,27 +2861,27 @@
/* Adjust disk size */
DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
- if (DiskSize >= 10737418240) /* 10 GB */
- {
- DiskSize = DiskSize / 1073741824;
+ if (DiskSize >= 10 * GB) /* 10 GB */
+ {
+ DiskSize = DiskSize / GB;
DiskUnit = MUIGetString(STRING_GB);
}
else
{
- DiskSize = DiskSize / 1048576;
+ DiskSize = DiskSize / MB;
DiskUnit = MUIGetString(STRING_MB);
}
/* Adjust partition size */
PartSize = PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
- if (PartSize >= 10737418240) /* 10 GB */
- {
- PartSize = PartSize / 1073741824;
+ if (PartSize >= 10 * GB) /* 10 GB */
+ {
+ PartSize = PartSize / GB;
PartUnit = MUIGetString(STRING_GB);
}
else
{
- PartSize = PartSize / 1048576;
+ PartSize = PartSize / MB;
PartUnit = MUIGetString(STRING_MB);
}
Modified: branches/setup_improvements/base/setup/usetup/partlist.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
==============================================================================
--- branches/setup_improvements/base/setup/usetup/partlist.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/usetup/partlist.c [iso-8859-1] Tue Aug 8
14:05:20 2017
@@ -292,21 +292,21 @@
{
PartSize.QuadPart = PartEntry->SectorCount.QuadPart *
DiskEntry->BytesPerSector;
#if 0
- if (PartSize.QuadPart >= 10737418240) /* 10 GB */
- {
- PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, 1073741824);
+ if (PartSize.QuadPart >= 10 * GB) /* 10 GB */
+ {
+ PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, GB);
Unit = MUIGetString(STRING_GB);
}
else
#endif
- if (PartSize.QuadPart >= 10485760) /* 10 MB */
- {
- PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, 1048576);
+ if (PartSize.QuadPart >= 10 * MB) /* 10 MB */
+ {
+ PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, MB);
Unit = MUIGetString(STRING_MB);
}
else
{
- PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, 1024);
+ PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, KB);
Unit = MUIGetString(STRING_KB);
}
@@ -335,21 +335,21 @@
PartSize.QuadPart = PartEntry->SectorCount.QuadPart *
DiskEntry->BytesPerSector;
#if 0
- if (PartSize.QuadPart >= 10737418240) /* 10 GB */
- {
- PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, 1073741824);
+ if (PartSize.QuadPart >= 10 * GB) /* 10 GB */
+ {
+ PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, GB);
Unit = MUIGetString(STRING_GB);
}
else
#endif
- if (PartSize.QuadPart >= 10485760) /* 10 MB */
- {
- PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, 1048576);
+ if (PartSize.QuadPart >= 10 * MB) /* 10 MB */
+ {
+ PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, MB);
Unit = MUIGetString(STRING_MB);
}
else
{
- PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, 1024);
+ PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, KB);
Unit = MUIGetString(STRING_KB);
}
@@ -442,14 +442,14 @@
coPos.Y = ListUi->Top + 1 + ListUi->Line;
DiskSize.QuadPart = DiskEntry->SectorCount.QuadPart *
DiskEntry->BytesPerSector;
- if (DiskSize.QuadPart >= 10737418240) /* 10 GB */
- {
- DiskSize.QuadPart = RoundingDivide(DiskSize.QuadPart, 1073741824);
+ if (DiskSize.QuadPart >= 10 * GB) /* 10 GB */
+ {
+ DiskSize.QuadPart = RoundingDivide(DiskSize.QuadPart, GB);
Unit = MUIGetString(STRING_GB);
}
else
{
- DiskSize.QuadPart = RoundingDivide(DiskSize.QuadPart, 1048576);
+ DiskSize.QuadPart = RoundingDivide(DiskSize.QuadPart, MB);
if (DiskSize.QuadPart == 0)
DiskSize.QuadPart = 1;
Unit = MUIGetString(STRING_MB);