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: Casper S. Hornstrup (chorns@users.sourceforge.net)
32 /* FUNCTIONS ****************************************************************/
36 IN OUT PFILE_SYSTEM_LIST List
,
37 IN PCWSTR FileSystemName
, // Redundant, I need to check whether this is reaaaaally needed....
38 IN PFILE_SYSTEM FileSystem
)
40 PFILE_SYSTEM_ITEM Item
;
42 Item
= (PFILE_SYSTEM_ITEM
)RtlAllocateHeap(ProcessHeap
, 0, sizeof(*Item
));
46 Item
->FileSystemName
= FileSystemName
;
47 Item
->FileSystem
= FileSystem
;
48 Item
->QuickFormat
= TRUE
;
49 InsertTailList(&List
->ListHead
, &Item
->ListEntry
);
54 Item
= (PFILE_SYSTEM_ITEM
)RtlAllocateHeap(ProcessHeap
, 0, sizeof(*Item
));
58 Item
->FileSystemName
= FileSystemName
;
59 Item
->FileSystem
= FileSystem
;
60 Item
->QuickFormat
= FALSE
;
61 InsertTailList(&List
->ListHead
, &Item
->ListEntry
);
65 InitializeFileSystemList(
66 IN PFILE_SYSTEM_LIST List
)
69 PFILE_SYSTEM FileSystems
;
71 FileSystems
= GetRegisteredFileSystems(&Count
);
72 if (!FileSystems
|| Count
== 0)
77 AddProvider(List
, FileSystems
->FileSystemName
, FileSystems
);
86 IN BOOLEAN ForceFormat
,
87 IN PCWSTR SelectFileSystem
)
89 PFILE_SYSTEM_LIST List
;
90 PFILE_SYSTEM_ITEM Item
;
91 PLIST_ENTRY ListEntry
;
93 List
= (PFILE_SYSTEM_LIST
)RtlAllocateHeap(ProcessHeap
, 0, sizeof(*List
));
99 List
->Selected
= NULL
;
100 InitializeListHead(&List
->ListHead
);
102 InitializeFileSystemList(List
);
105 /* Add the 'Keep existing filesystem' dummy provider */
106 AddProvider(List
, NULL
, NULL
);
109 /* Search for SelectFileSystem in list */
110 ListEntry
= List
->ListHead
.Flink
;
111 while (ListEntry
!= &List
->ListHead
)
113 Item
= CONTAINING_RECORD(ListEntry
, FILE_SYSTEM_ITEM
, ListEntry
);
114 if (Item
->FileSystemName
&& wcscmp(SelectFileSystem
, Item
->FileSystemName
) == 0)
116 List
->Selected
= Item
;
119 ListEntry
= ListEntry
->Flink
;
122 List
->Selected
= CONTAINING_RECORD(List
->ListHead
.Flink
, FILE_SYSTEM_ITEM
, ListEntry
);
128 DestroyFileSystemList(
129 IN PFILE_SYSTEM_LIST List
)
131 PLIST_ENTRY ListEntry
;
132 PFILE_SYSTEM_ITEM Item
;
134 ListEntry
= List
->ListHead
.Flink
;
135 while (!IsListEmpty(&List
->ListHead
))
137 ListEntry
= RemoveHeadList(&List
->ListHead
);
138 Item
= CONTAINING_RECORD(ListEntry
, FILE_SYSTEM_ITEM
, ListEntry
);
139 RtlFreeHeap(ProcessHeap
, 0, Item
);
142 RtlFreeHeap(ProcessHeap
, 0, List
);
147 IN PFILE_SYSTEM_LIST List
)
149 PLIST_ENTRY ListEntry
;
150 PFILE_SYSTEM_ITEM Item
;
156 ListEntry
= List
->ListHead
.Flink
;
157 while (ListEntry
!= &List
->ListHead
)
159 Item
= CONTAINING_RECORD(ListEntry
, FILE_SYSTEM_ITEM
, ListEntry
);
161 coPos
.X
= List
->Left
;
162 coPos
.Y
= List
->Top
+ (SHORT
)Index
;
163 FillConsoleOutputAttribute(StdOutput
,
164 FOREGROUND_WHITE
| BACKGROUND_BLUE
,
168 FillConsoleOutputCharacterA(StdOutput
,
174 if (Item
->FileSystemName
)
176 if (Item
->QuickFormat
)
177 snprintf(Buffer
, sizeof(Buffer
), MUIGetString(STRING_FORMATDISK1
), Item
->FileSystemName
);
179 snprintf(Buffer
, sizeof(Buffer
), MUIGetString(STRING_FORMATDISK2
), Item
->FileSystemName
);
183 snprintf(Buffer
, sizeof(Buffer
), MUIGetString(STRING_KEEPFORMAT
));
186 if (ListEntry
== &List
->Selected
->ListEntry
)
187 CONSOLE_SetInvertedTextXY(List
->Left
,
188 List
->Top
+ (SHORT
)Index
,
191 CONSOLE_SetTextXY(List
->Left
,
192 List
->Top
+ (SHORT
)Index
,
195 ListEntry
= ListEntry
->Flink
;
200 ScrollDownFileSystemList(
201 IN PFILE_SYSTEM_LIST List
)
203 if (List
->Selected
->ListEntry
.Flink
!= &List
->ListHead
)
205 List
->Selected
= CONTAINING_RECORD(List
->Selected
->ListEntry
.Flink
, FILE_SYSTEM_ITEM
, ListEntry
);
206 DrawFileSystemList(List
);
211 ScrollUpFileSystemList(
212 IN PFILE_SYSTEM_LIST List
)
214 if (List
->Selected
->ListEntry
.Blink
!= &List
->ListHead
)
216 List
->Selected
= CONTAINING_RECORD(List
->Selected
->ListEntry
.Blink
, FILE_SYSTEM_ITEM
, ListEntry
);
217 DrawFileSystemList(List
);