mirror of
https://github.com/reactos/reactos.git
synced 2025-06-04 08:50:27 +00:00
Update to new fmifs types.
Implement partition format progress bar. svn path=/trunk/; revision=8332
This commit is contained in:
parent
951f5f360f
commit
95033dafab
5 changed files with 196 additions and 50 deletions
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: format.c,v 1.2 2003/08/18 17:39:26 ekohl Exp $
|
||||
/* $Id: format.c,v 1.3 2004/02/23 11:58:27 ekohl Exp $
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS text-mode setup
|
||||
* FILE: subsys/system/usetup/format.c
|
||||
|
@ -28,28 +28,104 @@
|
|||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <ntdll/rtl.h>
|
||||
#include <fslib/vfatlib.h>
|
||||
|
||||
#include "usetup.h"
|
||||
#include "console.h"
|
||||
#include "progress.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
#include <fslib/vfatlib.h>
|
||||
|
||||
|
||||
PPROGRESSBAR ProgressBar = NULL;
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
|
||||
BOOLEAN STDCALL
|
||||
FormatCallback (CALLBACKCOMMAND Command,
|
||||
ULONG Modifier,
|
||||
PVOID Argument)
|
||||
{
|
||||
// DPRINT1 ("FormatCallback() called\n");
|
||||
|
||||
switch (Command)
|
||||
{
|
||||
case PROGRESS:
|
||||
{
|
||||
PULONG Percent;
|
||||
|
||||
Percent = (PULONG)Argument;
|
||||
DPRINT ("%lu percent completed\n", *Percent);
|
||||
|
||||
ProgressSetStep (ProgressBar, *Percent);
|
||||
}
|
||||
break;
|
||||
|
||||
// case OUTPUT:
|
||||
// {
|
||||
// PTEXTOUTPUT Output;
|
||||
// output = (PTEXTOUTPUT) Argument;
|
||||
// fprintf(stdout, "%s", output->Output);
|
||||
// }
|
||||
// break;
|
||||
|
||||
case DONE:
|
||||
{
|
||||
DPRINT ("Done\n");
|
||||
// PBOOLEAN Success;
|
||||
// status = (PBOOLEAN) Argument;
|
||||
// if ( *status == FALSE )
|
||||
// {
|
||||
// wprintf(L"FormatEx was unable to complete successfully.\n\n");
|
||||
// Error = TRUE;
|
||||
// }
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
DPRINT ("Unknown callback %lu\n", (ULONG)Command);
|
||||
break;
|
||||
}
|
||||
|
||||
// DPRINT1 ("FormatCallback() done\n");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
FormatPartition(PUNICODE_STRING DriveRoot)
|
||||
FormatPartition (PUNICODE_STRING DriveRoot)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
SHORT xScreen;
|
||||
SHORT yScreen;
|
||||
|
||||
VfatInitialize();
|
||||
GetScreenSize(&xScreen, &yScreen);
|
||||
|
||||
ProgressBar = CreateProgressBar (6,
|
||||
yScreen - 14,
|
||||
xScreen - 7,
|
||||
yScreen - 10);
|
||||
|
||||
ProgressSetStepCount (ProgressBar, 100);
|
||||
|
||||
VfatInitialize ();
|
||||
|
||||
Status = VfatFormat (DriveRoot,
|
||||
0, // MediaFlag
|
||||
NULL, // Label
|
||||
TRUE, // QuickFormat
|
||||
0, // ClusterSize
|
||||
NULL); // Callback
|
||||
DPRINT1("VfatFormat() status 0x%.08x\n", Status);
|
||||
0, /* MediaFlag */
|
||||
NULL, /* Label */
|
||||
TRUE, /* QuickFormat */
|
||||
0, /* ClusterSize */
|
||||
(PFMIFSCALLBACK)FormatCallback); /* Callback */
|
||||
|
||||
VfatCleanup();
|
||||
VfatCleanup ();
|
||||
|
||||
DestroyProgressBar (ProgressBar);
|
||||
ProgressBar = NULL;
|
||||
|
||||
DPRINT ("VfatFormat() status 0x%.08x\n", Status);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $Id: makefile,v 1.14 2003/11/14 17:13:33 weiden Exp $
|
||||
# $Id: makefile,v 1.15 2004/02/23 11:58:27 ekohl Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
|
@ -18,9 +18,9 @@ TARGET_INSTALLDIR = system32
|
|||
|
||||
TARGET_CFLAGS = -D__NTAPP__ -I$(PATH_TO_TOP)/lib/zlib -Wall -Werror -Wno-format
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o bootsup.o cabinet.o console.o drivesup.o \
|
||||
TARGET_OBJECTS = bootsup.o cabinet.o console.o drivesup.o \
|
||||
filequeue.o filesup.o format.o fslist.o infcache.o \
|
||||
inicache.o partlist.o progress.o registry.o
|
||||
inicache.o partlist.o progress.o registry.o usetup.o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
|
||||
static VOID
|
||||
DrawBorder(PPROGRESS Bar)
|
||||
DrawBorder(PPROGRESSBAR Bar)
|
||||
{
|
||||
COORD coPos;
|
||||
ULONG Written;
|
||||
|
@ -86,7 +86,7 @@ DrawBorder(PPROGRESS Bar)
|
|||
|
||||
|
||||
static VOID
|
||||
DrawProgressBar(PPROGRESS Bar)
|
||||
DrawProgressBar(PPROGRESSBAR Bar)
|
||||
{
|
||||
CHAR TextBuffer[8];
|
||||
COORD coPos;
|
||||
|
@ -122,17 +122,17 @@ DrawProgressBar(PPROGRESS Bar)
|
|||
|
||||
|
||||
|
||||
PPROGRESS
|
||||
PPROGRESSBAR
|
||||
CreateProgressBar(SHORT Left,
|
||||
SHORT Top,
|
||||
SHORT Right,
|
||||
SHORT Bottom)
|
||||
{
|
||||
PPROGRESS Bar;
|
||||
PPROGRESSBAR Bar;
|
||||
|
||||
Bar = (PPROGRESS)RtlAllocateHeap(ProcessHeap,
|
||||
0,
|
||||
sizeof(PROGRESS));
|
||||
Bar = (PPROGRESSBAR)RtlAllocateHeap(ProcessHeap,
|
||||
0,
|
||||
sizeof(PROGRESSBAR));
|
||||
if (Bar == NULL)
|
||||
return(NULL);
|
||||
|
||||
|
@ -156,7 +156,7 @@ CreateProgressBar(SHORT Left,
|
|||
|
||||
|
||||
VOID
|
||||
DestroyProgressBar(PPROGRESS Bar)
|
||||
DestroyProgressBar(PPROGRESSBAR Bar)
|
||||
{
|
||||
RtlFreeHeap(ProcessHeap,
|
||||
0,
|
||||
|
@ -164,7 +164,7 @@ DestroyProgressBar(PPROGRESS Bar)
|
|||
}
|
||||
|
||||
VOID
|
||||
ProgressSetStepCount(PPROGRESS Bar,
|
||||
ProgressSetStepCount(PPROGRESSBAR Bar,
|
||||
ULONG StepCount)
|
||||
{
|
||||
Bar->CurrentStep = 0;
|
||||
|
@ -175,7 +175,7 @@ ProgressSetStepCount(PPROGRESS Bar,
|
|||
|
||||
|
||||
VOID
|
||||
ProgressNextStep(PPROGRESS Bar)
|
||||
ProgressNextStep(PPROGRESSBAR Bar)
|
||||
{
|
||||
CHAR TextBuffer[8];
|
||||
COORD coPos;
|
||||
|
@ -243,4 +243,74 @@ ProgressNextStep(PPROGRESS Bar)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
ProgressSetStep (PPROGRESSBAR Bar,
|
||||
ULONG Step)
|
||||
{
|
||||
CHAR TextBuffer[8];
|
||||
COORD coPos;
|
||||
ULONG Written;
|
||||
ULONG NewPercent;
|
||||
ULONG NewPos;
|
||||
|
||||
if (Step > Bar->StepCount)
|
||||
return;
|
||||
|
||||
Bar->CurrentStep = Step;
|
||||
|
||||
/* Calculate new percentage */
|
||||
NewPercent = (ULONG)(((100.0 * (float)Bar->CurrentStep) / (float)Bar->StepCount) + 0.5);
|
||||
|
||||
/* Redraw precentage if changed */
|
||||
if (Bar->Percent != NewPercent)
|
||||
{
|
||||
Bar->Percent = NewPercent;
|
||||
|
||||
sprintf(TextBuffer, "%-3lu%%", Bar->Percent);
|
||||
|
||||
coPos.X = Bar->Left + (Bar->Width - 2) / 2;
|
||||
coPos.Y = Bar->Top;
|
||||
WriteConsoleOutputCharacters(TextBuffer,
|
||||
4,
|
||||
coPos);
|
||||
}
|
||||
|
||||
/* Calculate bar position */
|
||||
NewPos = (ULONG)((((float)(Bar->Width - 2) * 2.0 * (float)Bar->CurrentStep) / (float)Bar->StepCount) + 0.5);
|
||||
|
||||
/* Redraw bar if changed */
|
||||
if (Bar->Pos != NewPos)
|
||||
{
|
||||
Bar->Pos = NewPos;
|
||||
|
||||
for (coPos.Y = Bar->Top + 2; coPos.Y <= Bar->Bottom - 1; coPos.Y++)
|
||||
{
|
||||
coPos.X = Bar->Left + 1;
|
||||
FillConsoleOutputCharacter(0xDB,
|
||||
Bar->Pos / 2,
|
||||
coPos,
|
||||
&Written);
|
||||
coPos.X += Bar->Pos/2;
|
||||
|
||||
if (NewPos & 1)
|
||||
{
|
||||
FillConsoleOutputCharacter(0xDD,
|
||||
1,
|
||||
coPos,
|
||||
&Written);
|
||||
coPos.X++;
|
||||
}
|
||||
|
||||
if (coPos.X <= Bar->Right - 1)
|
||||
{
|
||||
FillConsoleOutputCharacter(' ',
|
||||
Bar->Right - coPos.X,
|
||||
coPos,
|
||||
&Written);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: progress.h,v 1.2 2003/02/27 14:42:43 ekohl Exp $
|
||||
/* $Id: progress.h,v 1.3 2004/02/23 11:58:27 ekohl Exp $
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS text-mode setup
|
||||
* FILE: subsys/system/usetup/partlist.h
|
||||
|
@ -42,25 +42,29 @@ typedef struct _PROGRESS
|
|||
|
||||
ULONG StepCount;
|
||||
ULONG CurrentStep;
|
||||
} PROGRESS, *PPROGRESS;
|
||||
} PROGRESSBAR, *PPROGRESSBAR;
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
PPROGRESS
|
||||
PPROGRESSBAR
|
||||
CreateProgressBar(SHORT Left,
|
||||
SHORT Top,
|
||||
SHORT Right,
|
||||
SHORT Bottom);
|
||||
|
||||
VOID
|
||||
DestroyProgressBar(PPROGRESS Bar);
|
||||
DestroyProgressBar(PPROGRESSBAR Bar);
|
||||
|
||||
VOID
|
||||
ProgressSetStepCount(PPROGRESS Bar,
|
||||
ProgressSetStepCount(PPROGRESSBAR Bar,
|
||||
ULONG StepCount);
|
||||
|
||||
VOID
|
||||
ProgressNextStep(PPROGRESS Bar);
|
||||
ProgressNextStep(PPROGRESSBAR Bar);
|
||||
|
||||
VOID
|
||||
ProgressSetStep (PPROGRESSBAR Bar,
|
||||
ULONG Step);
|
||||
|
||||
#endif /* __PROGRESS_H__ */
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* ReactOS kernel
|
||||
* Copyright (C) 2002, 2003 ReactOS Team
|
||||
* Copyright (C) 2002, 2003, 2004 ReactOS Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -84,7 +84,7 @@ typedef struct _COPYCONTEXT
|
|||
{
|
||||
ULONG TotalOperations;
|
||||
ULONG CompletedOperations;
|
||||
PPROGRESS ProgressBar;
|
||||
PPROGRESSBAR ProgressBar;
|
||||
} COPYCONTEXT, *PCOPYCONTEXT;
|
||||
|
||||
|
||||
|
@ -492,6 +492,7 @@ CheckUnattendedSetup()
|
|||
InfCloseFile(UnattendInf);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get pointer 'InstallationDirectory' key */
|
||||
if (!InfGetData(&Context, NULL, &Value))
|
||||
{
|
||||
|
@ -688,19 +689,15 @@ IntroPage(PINPUT_RECORD Ir)
|
|||
SetTextXY(6, 12, "computer and prepares the second part of the setup.");
|
||||
|
||||
SetTextXY(8, 15, "\x07 Press ENTER to install ReactOS.");
|
||||
|
||||
SetTextXY(8, 17, "\x07 Press E to start the emergency console.");
|
||||
|
||||
SetTextXY(8, 19, "\x07 Press R to repair ReactOS.");
|
||||
|
||||
SetTextXY(8, 21, "\x07 Press F3 to quit without installing ReactOS.");
|
||||
|
||||
|
||||
SetStatusText(" ENTER = Continue F3 = Quit");
|
||||
|
||||
if (IsUnattendedSetup)
|
||||
{
|
||||
return(INSTALL_INTRO_PAGE);
|
||||
return INSTALL_INTRO_PAGE;
|
||||
}
|
||||
|
||||
while(TRUE)
|
||||
|
@ -711,24 +708,24 @@ IntroPage(PINPUT_RECORD Ir)
|
|||
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
|
||||
{
|
||||
if (ConfirmQuit(Ir) == TRUE)
|
||||
return(QUIT_PAGE);
|
||||
return QUIT_PAGE;
|
||||
break;
|
||||
}
|
||||
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
|
||||
{
|
||||
return(INSTALL_INTRO_PAGE);
|
||||
return INSTALL_INTRO_PAGE;
|
||||
}
|
||||
else if (toupper(Ir->Event.KeyEvent.uChar.AsciiChar) == 'E') /* E */
|
||||
{
|
||||
return(EMERGENCY_INTRO_PAGE);
|
||||
return EMERGENCY_INTRO_PAGE;
|
||||
}
|
||||
else if (toupper(Ir->Event.KeyEvent.uChar.AsciiChar) == 'R') /* R */
|
||||
{
|
||||
return(REPAIR_INTRO_PAGE);
|
||||
return REPAIR_INTRO_PAGE;
|
||||
}
|
||||
}
|
||||
|
||||
return(INTRO_PAGE);
|
||||
return INTRO_PAGE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1930,8 +1927,8 @@ FormatPartitionPage (PINPUT_RECORD Ir)
|
|||
wcscpy (PathBuffer, SourceRootPath.Buffer);
|
||||
wcscat (PathBuffer, L"\\loader\\fat32.bin");
|
||||
|
||||
DPRINT1 ("Install FAT32 bootcode: %S ==> %S\n", PathBuffer,
|
||||
DestinationRootPath.Buffer);
|
||||
DPRINT ("Install FAT32 bootcode: %S ==> %S\n", PathBuffer,
|
||||
DestinationRootPath.Buffer);
|
||||
Status = InstallFat32BootCodeToDisk (PathBuffer,
|
||||
DestinationRootPath.Buffer);
|
||||
if (!NT_SUCCESS (Status))
|
||||
|
@ -1946,8 +1943,8 @@ FormatPartitionPage (PINPUT_RECORD Ir)
|
|||
wcscpy (PathBuffer, SourceRootPath.Buffer);
|
||||
wcscat (PathBuffer, L"\\loader\\fat.bin");
|
||||
|
||||
DPRINT1 ("Install FAT bootcode: %S ==> %S\n", PathBuffer,
|
||||
DestinationRootPath.Buffer);
|
||||
DPRINT ("Install FAT bootcode: %S ==> %S\n", PathBuffer,
|
||||
DestinationRootPath.Buffer);
|
||||
Status = InstallFat16BootCodeToDisk (PathBuffer,
|
||||
DestinationRootPath.Buffer);
|
||||
if (!NT_SUCCESS (Status))
|
||||
|
@ -3334,7 +3331,6 @@ BootLoaderPage(PINPUT_RECORD Ir)
|
|||
}
|
||||
|
||||
|
||||
|
||||
static PAGE_NUMBER
|
||||
QuitPage(PINPUT_RECORD Ir)
|
||||
{
|
||||
|
@ -3534,9 +3530,6 @@ NtProcessStartup(PPEB Peb)
|
|||
Page = RepairIntroPage(&Ir);
|
||||
break;
|
||||
|
||||
case REBOOT_PAGE:
|
||||
break;
|
||||
|
||||
|
||||
/* Emergency pages */
|
||||
case EMERGENCY_INTRO_PAGE:
|
||||
|
@ -3555,6 +3548,9 @@ NtProcessStartup(PPEB Peb)
|
|||
case QUIT_PAGE:
|
||||
Page = QuitPage(&Ir);
|
||||
break;
|
||||
|
||||
case REBOOT_PAGE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue