Copy file dates of source file too.

Get default install directory from txtsetup.sif.

svn path=/trunk/; revision=4116
This commit is contained in:
Eric Kohl 2003-02-08 00:19:32 +00:00
parent 3fad983cf2
commit 0be3b55ba5
2 changed files with 190 additions and 151 deletions

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: filesup.c,v 1.4 2003/01/17 13:18:15 ekohl Exp $ /* $Id: filesup.c,v 1.5 2003/02/08 00:19:32 ekohl Exp $
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS text-mode setup * PROJECT: ReactOS text-mode setup
* FILE: subsys/system/usetup/filesup.c * FILE: subsys/system/usetup/filesup.c
@ -48,15 +48,6 @@ CreateDirectory(PWCHAR DirectoryName)
RtlCreateUnicodeString(&PathName, RtlCreateUnicodeString(&PathName,
DirectoryName); DirectoryName);
#if 0
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
ObjectAttributes.RootDirectory = NULL;
ObjectAttributes.ObjectName = &PathName;
ObjectAttributes.Attributes = OBJ_CASE_INSENSITIVE | OBJ_INHERIT;
ObjectAttributes.SecurityDescriptor = NULL;
ObjectAttributes.SecurityQualityOfService = NULL;
#endif
InitializeObjectAttributes(&ObjectAttributes, InitializeObjectAttributes(&ObjectAttributes,
&PathName, &PathName,
OBJ_CASE_INSENSITIVE | OBJ_INHERIT, OBJ_CASE_INSENSITIVE | OBJ_INHERIT,
@ -119,10 +110,10 @@ SetupCopyFile(PWCHAR SourceFileName,
FILE_SHARE_READ, FILE_SHARE_READ,
FILE_SYNCHRONOUS_IO_ALERT | FILE_SEQUENTIAL_ONLY); FILE_SYNCHRONOUS_IO_ALERT | FILE_SEQUENTIAL_ONLY);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
CHECKPOINT1; CHECKPOINT1;
return(Status); return(Status);
} }
Status = NtQueryInformationFile(FileHandleSource, Status = NtQueryInformationFile(FileHandleSource,
&IoStatusBlock, &IoStatusBlock,
@ -130,22 +121,22 @@ CHECKPOINT1;
sizeof(FILE_STANDARD_INFORMATION), sizeof(FILE_STANDARD_INFORMATION),
FileStandardInformation); FileStandardInformation);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
CHECKPOINT1; CHECKPOINT1;
NtClose(FileHandleSource); NtClose(FileHandleSource);
return(Status); return(Status);
} }
Status = NtQueryInformationFile(FileHandleSource, Status = NtQueryInformationFile(FileHandleSource,
&IoStatusBlock,&FileBasic, &IoStatusBlock,&FileBasic,
sizeof(FILE_BASIC_INFORMATION), sizeof(FILE_BASIC_INFORMATION),
FileBasicInformation); FileBasicInformation);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
CHECKPOINT1; CHECKPOINT1;
NtClose(FileHandleSource); NtClose(FileHandleSource);
return(Status); return(Status);
} }
RtlInitUnicodeString(&FileName, RtlInitUnicodeString(&FileName,
DestinationFileName); DestinationFileName);
@ -168,11 +159,11 @@ CHECKPOINT1;
NULL, NULL,
0); 0);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
CHECKPOINT1; CHECKPOINT1;
NtClose(FileHandleSource); NtClose(FileHandleSource);
return(Status); return(Status);
} }
FilePosition.CurrentByteOffset.QuadPart = 0; FilePosition.CurrentByteOffset.QuadPart = 0;
@ -182,12 +173,12 @@ CHECKPOINT1;
sizeof(FILE_POSITION_INFORMATION), sizeof(FILE_POSITION_INFORMATION),
FilePositionInformation); FilePositionInformation);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
CHECKPOINT1; CHECKPOINT1;
NtClose(FileHandleSource); NtClose(FileHandleSource);
NtClose(FileHandleDest); NtClose(FileHandleDest);
return(Status); return(Status);
} }
Status = NtSetInformationFile(FileHandleDest, Status = NtSetInformationFile(FileHandleDest,
&IoStatusBlock, &IoStatusBlock,
@ -195,18 +186,18 @@ CHECKPOINT1;
sizeof(FILE_POSITION_INFORMATION), sizeof(FILE_POSITION_INFORMATION),
FilePositionInformation); FilePositionInformation);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
CHECKPOINT1; CHECKPOINT1;
NtClose(FileHandleSource); NtClose(FileHandleSource);
NtClose(FileHandleDest); NtClose(FileHandleDest);
return(Status); return(Status);
} }
RegionSize = PAGE_ROUND_UP(FileStandard.EndOfFile.u.LowPart); RegionSize = PAGE_ROUND_UP(FileStandard.EndOfFile.u.LowPart);
if (RegionSize > 0x100000) if (RegionSize > 0x100000)
{ {
RegionSize = 0x100000; RegionSize = 0x100000;
} }
Status = NtAllocateVirtualMemory(NtCurrentProcess(), Status = NtAllocateVirtualMemory(NtCurrentProcess(),
(PVOID *)&Buffer, (PVOID *)&Buffer,
2, 2,
@ -214,66 +205,81 @@ CHECKPOINT1;
MEM_RESERVE | MEM_COMMIT, MEM_RESERVE | MEM_COMMIT,
PAGE_READWRITE); PAGE_READWRITE);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
CHECKPOINT1; CHECKPOINT1;
NtClose(FileHandleSource); NtClose(FileHandleSource);
NtClose(FileHandleDest); NtClose(FileHandleDest);
return(Status); return(Status);
} }
while (TRUE) while (TRUE)
{
Status = NtReadFile(FileHandleSource,
NULL,
NULL,
NULL,
&IoStatusBlock,
Buffer,
RegionSize,
NULL,
NULL);
if (!NT_SUCCESS(Status))
{ {
NtFreeVirtualMemory(NtCurrentProcess(), Status = NtReadFile(FileHandleSource,
(PVOID *)&Buffer, NULL,
&RegionSize, NULL,
MEM_RELEASE); NULL,
NtClose(FileHandleSource); &IoStatusBlock,
NtClose(FileHandleDest); Buffer,
if (Status == STATUS_END_OF_FILE) RegionSize,
{ NULL,
DPRINT("STATUS_END_OF_FILE\n"); NULL);
break; if (!NT_SUCCESS(Status))
} {
NtFreeVirtualMemory(NtCurrentProcess(),
(PVOID *)&Buffer,
&RegionSize,
MEM_RELEASE);
if (Status == STATUS_END_OF_FILE)
{
DPRINT("STATUS_END_OF_FILE\n");
break;
}
CHECKPOINT1; CHECKPOINT1;
return(Status); NtClose(FileHandleSource);
NtClose(FileHandleDest);
return(Status);
}
DPRINT("Bytes read %lu\n", IoStatusBlock.Information);
Status = NtWriteFile(FileHandleDest,
NULL,
NULL,
NULL,
&IoStatusBlock,
Buffer,
IoStatusBlock.Information,
NULL,
NULL);
if (!NT_SUCCESS(Status))
{
CHECKPOINT1;
NtFreeVirtualMemory(NtCurrentProcess(),
(PVOID *)&Buffer,
&RegionSize,
MEM_RELEASE);
NtClose(FileHandleSource);
NtClose(FileHandleDest);
return(Status);
}
} }
DPRINT("Bytes read %lu\n", IoStatusBlock.Information);
Status = NtWriteFile(FileHandleDest, /* Copy file date/time from source file */
NULL, Status = NtSetInformationFile(FileHandleDest,
NULL, &IoStatusBlock,
NULL, &FileBasic,
&IoStatusBlock, sizeof(FILE_BASIC_INFORMATION),
Buffer, FileBasicInformation);
IoStatusBlock.Information, if (!NT_SUCCESS(Status))
NULL,
NULL);
if (!NT_SUCCESS(Status))
{ {
CHECKPOINT1; DPRINT("NtSetInformationFile() failed (Status %lx)\n", Status);
NtFreeVirtualMemory(NtCurrentProcess(),
(PVOID *)&Buffer,
&RegionSize,
MEM_RELEASE);
NtClose(FileHandleSource);
NtClose(FileHandleDest);
return(Status);
} }
}
return(STATUS_SUCCESS); NtClose(FileHandleSource);
NtClose(FileHandleDest);
return(Status);
} }
@ -312,10 +318,10 @@ DoesFileExist(PWSTR PathName,
0, 0,
FILE_SYNCHRONOUS_IO_ALERT); FILE_SYNCHRONOUS_IO_ALERT);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
CHECKPOINT1; CHECKPOINT1;
return(FALSE); return(FALSE);
} }
NtClose(FileHandle); NtClose(FileHandle);

View file

@ -407,39 +407,39 @@ StartPage(PINPUT_RECORD Ir)
&FileName, &FileName,
TRUE); TRUE);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
PopupError("Setup failed to load the file TXTSETUP.SIF.\n", PopupError("Setup failed to load the file TXTSETUP.SIF.\n",
"ENTER = Reboot computer"); "ENTER = Reboot computer");
while(TRUE) while(TRUE)
{
ConInKey(Ir);
if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{ {
return(QUIT_PAGE); ConInKey(Ir);
if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
return(QUIT_PAGE);
}
} }
} }
}
/* Open 'Version' section */ /* Open 'Version' section */
Section = IniCacheGetSection(IniCache, Section = IniCacheGetSection(IniCache,
L"Version"); L"Version");
if (Section == NULL) if (Section == NULL)
{ {
PopupError("Setup found a corrupt TXTSETUP.SIF.\n", PopupError("Setup found a corrupt TXTSETUP.SIF.\n",
"ENTER = Reboot computer"); "ENTER = Reboot computer");
while(TRUE) while(TRUE)
{
ConInKey(Ir);
if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{ {
return(QUIT_PAGE); ConInKey(Ir);
if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
return(QUIT_PAGE);
}
} }
} }
}
/* Get pointer 'Signature' key */ /* Get pointer 'Signature' key */
@ -447,37 +447,37 @@ StartPage(PINPUT_RECORD Ir)
L"Signature", L"Signature",
&Value); &Value);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
PopupError("Setup found a corrupt TXTSETUP.SIF.\n", PopupError("Setup found a corrupt TXTSETUP.SIF.\n",
"ENTER = Reboot computer"); "ENTER = Reboot computer");
while(TRUE) while(TRUE)
{
ConInKey(Ir);
if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{ {
return(QUIT_PAGE); ConInKey(Ir);
if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
return(QUIT_PAGE);
}
} }
} }
}
/* Check 'Signature' string */ /* Check 'Signature' string */
if (_wcsicmp(Value, L"$ReactOS$") != 0) if (_wcsicmp(Value, L"$ReactOS$") != 0)
{
PopupError("Setup found an invalid signature in TXTSETUP.SIF.\n",
"ENTER = Reboot computer");
while(TRUE)
{ {
ConInKey(Ir); PopupError("Setup found an invalid signature in TXTSETUP.SIF.\n",
"ENTER = Reboot computer");
if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */ while(TRUE)
{ {
return(QUIT_PAGE); ConInKey(Ir);
}
if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
return(QUIT_PAGE);
}
}
} }
}
return(INTRO_PAGE); return(INTRO_PAGE);
} }
@ -492,9 +492,9 @@ RepairIntroPage(PINPUT_RECORD Ir)
SetTextXY(6, 12, "The repair functions are not implemented yet."); SetTextXY(6, 12, "The repair functions are not implemented yet.");
SetTextXY(8, 15, "\xf9 Press ESC to return to the main page."); SetTextXY(8, 15, "\xfa Press ESC to return to the main page.");
SetTextXY(8, 17, "\xf9 Press ENTER to reboot your computer."); SetTextXY(8, 17, "\xfa Press ENTER to reboot your computer.");
SetStatusText(" ESC = Main page ENTER = Reboot"); SetStatusText(" ESC = Main page ENTER = Reboot");
@ -531,13 +531,13 @@ IntroPage(PINPUT_RECORD Ir)
SetTextXY(6, 11, "This part of the setup copies the ReactOS Operating System to your"); SetTextXY(6, 11, "This part of the setup copies the ReactOS Operating System to your");
SetTextXY(6, 12, "computer and prepares the second part of the setup."); SetTextXY(6, 12, "computer and prepares the second part of the setup.");
SetTextXY(8, 15, "\xf9 Press ENTER to install ReactOS."); SetTextXY(8, 15, "\xfa Press ENTER to install ReactOS.");
SetTextXY(8, 17, "\xf9 Press E to start the emergency repair console."); SetTextXY(8, 17, "\xfa Press E to start the emergency repair console.");
SetTextXY(8, 19, "\xf9 Press R to repair ReactOS."); SetTextXY(8, 19, "\xfa Press R to repair ReactOS.");
SetTextXY(8, 21, "\xf9 Press F3 to quit without installing ReactOS."); SetTextXY(8, 21, "\xfa Press F3 to quit without installing ReactOS.");
SetStatusText(" ENTER = Continue F3 = Quit"); SetStatusText(" ENTER = Continue F3 = Quit");
@ -587,9 +587,9 @@ InstallIntroPage(PINPUT_RECORD Ir)
SetTextXY(8, 21, "\xf9 Press ENTER to install ReactOS."); SetTextXY(8, 21, "\xfa Press ENTER to install ReactOS.");
SetTextXY(8, 23, "\xf9 Press F3 to quit without installing ReactOS."); SetTextXY(8, 23, "\xfa Press F3 to quit without installing ReactOS.");
SetStatusText(" ENTER = Continue F3 = Quit"); SetStatusText(" ENTER = Continue F3 = Quit");
@ -626,10 +626,10 @@ SelectPartitionPage(PINPUT_RECORD Ir)
SetTextXY(6, 8, "The list below shows existing partitions and unused disk"); SetTextXY(6, 8, "The list below shows existing partitions and unused disk");
SetTextXY(6, 9, "space for new partitions."); SetTextXY(6, 9, "space for new partitions.");
SetTextXY(8, 11, "\xf9 Press UP or DOWN to select a list entry."); SetTextXY(8, 11, "\xfa Press UP or DOWN to select a list entry.");
SetTextXY(8, 13, "\xf9 Press ENTER to install ReactOS onto the selected partition."); SetTextXY(8, 13, "\xfa Press ENTER to install ReactOS onto the selected partition.");
SetTextXY(8, 15, "\xf9 Press C to create a new partition."); SetTextXY(8, 15, "\xfa Press C to create a new partition.");
SetTextXY(8, 17, "\xf9 Press D to delete an existing partition."); SetTextXY(8, 17, "\xfa Press D to delete an existing partition.");
SetStatusText(" Please wait..."); SetStatusText(" Please wait...");
@ -789,9 +789,9 @@ SelectFileSystemPage(PINPUT_RECORD Ir)
SetTextXY(6, 17, "Select a file system for the partition from the list below."); SetTextXY(6, 17, "Select a file system for the partition from the list below.");
SetTextXY(8, 19, "\xf9 Press UP or DOWN to select a file system."); SetTextXY(8, 19, "\xfa Press UP or DOWN to select a file system.");
SetTextXY(8, 21, "\xf9 Press ENTER to format the partition."); SetTextXY(8, 21, "\xfa Press ENTER to format the partition.");
SetTextXY(8, 23, "\xf9 Press ESC to select another partition."); SetTextXY(8, 23, "\xfa Press ESC to select another partition.");
/* FIXME: use a real list later */ /* FIXME: use a real list later */
SetInvertedTextXY(6, 26, " Keep current file system (no changes) "); SetInvertedTextXY(6, 26, " Keep current file system (no changes) ");
@ -861,23 +861,56 @@ CheckFileSystemPage(PINPUT_RECORD Ir)
static ULONG static ULONG
InstallDirectoryPage(PINPUT_RECORD Ir) InstallDirectoryPage(PINPUT_RECORD Ir)
{ {
PINICACHESECTION Section;
WCHAR PathBuffer[MAX_PATH]; WCHAR PathBuffer[MAX_PATH];
WCHAR InstallDir[51]; WCHAR InstallDir[51];
PWCHAR DefaultPath;
ULONG Length; ULONG Length;
NTSTATUS Status;
/* Open 'SetupData' section */
Section = IniCacheGetSection(IniCache,
L"SetupData");
if (Section == NULL)
{
PopupError("Setup failed to find the 'SetupData' section\n"
"in TXTSETUP.SIF.\n",
"ENTER = Reboot computer");
while(TRUE)
{
ConInKey(Ir);
if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
return(QUIT_PAGE);
}
}
}
/* Read the 'DefaultPath' key */
Status = IniCacheGetKey(Section,
L"DefaultPath",
&DefaultPath);
if (!NT_SUCCESS(Status))
{
wcscpy(InstallDir, L"\\reactos");
}
else
{
wcscpy(InstallDir, DefaultPath);
}
Length = wcslen(InstallDir);
SetTextXY(6, 8, "Setup installs ReactOS files onto the selected partition. Choose a"); SetTextXY(6, 8, "Setup installs ReactOS files onto the selected partition. Choose a");
SetTextXY(6, 9, "directory where you want ReactOS to be installed:"); SetTextXY(6, 9, "directory where you want ReactOS to be installed:");
wcscpy(InstallDir, L"\\reactos");
Length = wcslen(InstallDir);
SetInputTextXY(8, 11, 51, InstallDir); SetInputTextXY(8, 11, 51, InstallDir);
SetTextXY(6, 14, "To change the suggested directory, press BACKSPACE to delete"); SetTextXY(6, 14, "To change the suggested directory, press BACKSPACE to delete");
SetTextXY(6, 15, "characters and then type the directory where you want ReactOS to"); SetTextXY(6, 15, "characters and then type the directory where you want ReactOS to");
SetTextXY(6, 16, "be installed."); SetTextXY(6, 16, "be installed.");
SetStatusText(" ENTER = Continue F3 = Quit"); SetStatusText(" ENTER = Continue F3 = Quit");
while(TRUE) while(TRUE)
@ -893,7 +926,7 @@ InstallDirectoryPage(PINPUT_RECORD Ir)
} }
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */ else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{ {
/* Create 'DestinationPath' string */ /* Create 'InstallPath' string */
RtlFreeUnicodeString(&InstallPath); RtlFreeUnicodeString(&InstallPath);
RtlCreateUnicodeString(&InstallPath, RtlCreateUnicodeString(&InstallPath,
InstallDir); InstallDir);