3 * Copyright (C) 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS text-mode setup
22 * FILE: base/setup/usetup/fslist.c
23 * PURPOSE: Filesystem list functions
24 * PROGRAMMER: Eric Kohl
25 * Casper S. Hornstrup (chorns@users.sourceforge.net)
33 /* FUNCTIONS ****************************************************************/
37 IN OUT PFILE_SYSTEM_LIST List
,
38 IN PCWSTR FileSystemName
, // Redundant, I need to check whether this is reaaaaally needed....
39 IN PFILE_SYSTEM FileSystem
)
41 PFILE_SYSTEM_ITEM Item
;
43 Item
= (PFILE_SYSTEM_ITEM
)RtlAllocateHeap(ProcessHeap
, 0, sizeof(*Item
));
47 Item
->FileSystemName
= FileSystemName
;
48 Item
->FileSystem
= FileSystem
;
49 Item
->QuickFormat
= TRUE
;
50 InsertTailList(&List
->ListHead
, &Item
->ListEntry
);
55 Item
= (PFILE_SYSTEM_ITEM
)RtlAllocateHeap(ProcessHeap
, 0, sizeof(*Item
));
59 Item
->FileSystemName
= FileSystemName
;
60 Item
->FileSystem
= FileSystem
;
61 Item
->QuickFormat
= FALSE
;
62 InsertTailList(&List
->ListHead
, &Item
->ListEntry
);
66 InitializeFileSystemList(
67 IN PFILE_SYSTEM_LIST List
)
70 PFILE_SYSTEM FileSystems
;
72 FileSystems
= GetRegisteredFileSystems(&Count
);
73 if (!FileSystems
|| Count
== 0)
78 AddProvider(List
, FileSystems
->FileSystemName
, FileSystems
);
87 IN BOOLEAN ForceFormat
,
88 IN PCWSTR SelectFileSystem
)
90 PFILE_SYSTEM_LIST List
;
91 PFILE_SYSTEM_ITEM Item
;
92 PLIST_ENTRY ListEntry
;
94 List
= (PFILE_SYSTEM_LIST
)RtlAllocateHeap(ProcessHeap
, 0, sizeof(*List
));
100 List
->Selected
= NULL
;
101 InitializeListHead(&List
->ListHead
);
103 InitializeFileSystemList(List
);
106 /* Add the 'Keep existing filesystem' dummy provider */
107 AddProvider(List
, NULL
, NULL
);
110 /* Search for SelectFileSystem in list */
111 ListEntry
= List
->ListHead
.Flink
;
112 while (ListEntry
!= &List
->ListHead
)
114 Item
= CONTAINING_RECORD(ListEntry
, FILE_SYSTEM_ITEM
, ListEntry
);
115 if (Item
->FileSystemName
&& wcscmp(SelectFileSystem
, Item
->FileSystemName
) == 0)
117 List
->Selected
= Item
;
120 ListEntry
= ListEntry
->Flink
;
123 List
->Selected
= CONTAINING_RECORD(List
->ListHead
.Flink
, FILE_SYSTEM_ITEM
, ListEntry
);
129 DestroyFileSystemList(
130 IN PFILE_SYSTEM_LIST List
)
132 PLIST_ENTRY ListEntry
;
133 PFILE_SYSTEM_ITEM Item
;
135 ListEntry
= List
->ListHead
.Flink
;
136 while (!IsListEmpty(&List
->ListHead
))
138 ListEntry
= RemoveHeadList(&List
->ListHead
);
139 Item
= CONTAINING_RECORD(ListEntry
, FILE_SYSTEM_ITEM
, ListEntry
);
140 RtlFreeHeap(ProcessHeap
, 0, Item
);
143 RtlFreeHeap(ProcessHeap
, 0, List
);
148 IN PFILE_SYSTEM_LIST List
)
150 PLIST_ENTRY ListEntry
;
151 PFILE_SYSTEM_ITEM Item
;
157 ListEntry
= List
->ListHead
.Flink
;
158 while (ListEntry
!= &List
->ListHead
)
160 Item
= CONTAINING_RECORD(ListEntry
, FILE_SYSTEM_ITEM
, ListEntry
);
162 coPos
.X
= List
->Left
;
163 coPos
.Y
= List
->Top
+ (SHORT
)Index
;
164 FillConsoleOutputAttribute(StdOutput
,
165 FOREGROUND_WHITE
| BACKGROUND_BLUE
,
169 FillConsoleOutputCharacterA(StdOutput
,
175 if (Item
->FileSystemName
)
177 if (Item
->QuickFormat
)
178 snprintf(Buffer
, sizeof(Buffer
), MUIGetString(STRING_FORMATDISK1
), Item
->FileSystemName
);
180 snprintf(Buffer
, sizeof(Buffer
), MUIGetString(STRING_FORMATDISK2
), Item
->FileSystemName
);
184 snprintf(Buffer
, sizeof(Buffer
), MUIGetString(STRING_KEEPFORMAT
));
187 if (ListEntry
== &List
->Selected
->ListEntry
)
188 CONSOLE_SetInvertedTextXY(List
->Left
,
189 List
->Top
+ (SHORT
)Index
,
192 CONSOLE_SetTextXY(List
->Left
,
193 List
->Top
+ (SHORT
)Index
,
196 ListEntry
= ListEntry
->Flink
;
201 ScrollDownFileSystemList(
202 IN PFILE_SYSTEM_LIST List
)
204 if (List
->Selected
->ListEntry
.Flink
!= &List
->ListHead
)
206 List
->Selected
= CONTAINING_RECORD(List
->Selected
->ListEntry
.Flink
, FILE_SYSTEM_ITEM
, ListEntry
);
207 DrawFileSystemList(List
);
212 ScrollUpFileSystemList(
213 IN PFILE_SYSTEM_LIST List
)
215 if (List
->Selected
->ListEntry
.Blink
!= &List
->ListHead
)
217 List
->Selected
= CONTAINING_RECORD(List
->Selected
->ListEntry
.Blink
, FILE_SYSTEM_ITEM
, ListEntry
);
218 DrawFileSystemList(List
);