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 /* Enable this define to hide FAT32 choice in case FAT is already present */
33 #define HIDE_FAT32_CHOICE
35 /* FUNCTIONS ****************************************************************/
39 IN OUT PFILE_SYSTEM_LIST List
,
42 PFILE_SYSTEM_ITEM Item
;
44 Item
= (PFILE_SYSTEM_ITEM
)RtlAllocateHeap(ProcessHeap
, 0, sizeof(*Item
));
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
->FileSystem
= FileSystem
;
60 Item
->QuickFormat
= FALSE
;
61 InsertTailList(&List
->ListHead
, &Item
->ListEntry
);
65 InitializeFileSystemList(
66 IN OUT PFILE_SYSTEM_LIST List
,
67 IN BOOLEAN ForceFormat
)
69 PCWSTR FileSystemName
;
72 #ifdef HIDE_FAT32_CHOICE
73 BOOLEAN FatPresent
= FALSE
;
75 /* Check whether the FAT filesystem is present */
77 while (GetRegisteredFileSystems(Index
++, &FileSystemName
))
79 if (wcsicmp(FileSystemName
, L
"FAT") == 0)
89 while (GetRegisteredFileSystems(Index
++, &FileSystemName
))
91 #ifdef HIDE_FAT32_CHOICE
92 /* USETUP only: If the FAT filesystem is present, show it, but
93 * don't display FAT32. The FAT formatter will automatically
94 * determine whether to use FAT12/16 or FAT32. */
95 if (FatPresent
&& wcsicmp(FileSystemName
, L
"FAT32") == 0)
98 AddProvider(List
, FileSystemName
);
103 /* Add the 'Keep existing filesystem' dummy provider */
104 AddProvider(List
, NULL
);
109 CreateFileSystemList(
112 IN BOOLEAN ForceFormat
,
113 IN PCWSTR SelectFileSystem
)
115 PFILE_SYSTEM_LIST List
;
116 PFILE_SYSTEM_ITEM Item
;
117 PLIST_ENTRY ListEntry
;
119 List
= (PFILE_SYSTEM_LIST
)RtlAllocateHeap(ProcessHeap
, 0, sizeof(*List
));
125 List
->Selected
= NULL
;
126 InitializeListHead(&List
->ListHead
);
128 InitializeFileSystemList(List
, ForceFormat
);
130 /* Search for SelectFileSystem in list */
131 ListEntry
= List
->ListHead
.Flink
;
132 while (ListEntry
!= &List
->ListHead
)
134 Item
= CONTAINING_RECORD(ListEntry
, FILE_SYSTEM_ITEM
, ListEntry
);
135 if (Item
->FileSystem
&& wcsicmp(SelectFileSystem
, Item
->FileSystem
) == 0)
137 List
->Selected
= Item
;
140 ListEntry
= ListEntry
->Flink
;
143 List
->Selected
= CONTAINING_RECORD(List
->ListHead
.Flink
, FILE_SYSTEM_ITEM
, ListEntry
);
149 DestroyFileSystemList(
150 IN PFILE_SYSTEM_LIST List
)
152 PLIST_ENTRY ListEntry
;
153 PFILE_SYSTEM_ITEM Item
;
155 ListEntry
= List
->ListHead
.Flink
;
156 while (!IsListEmpty(&List
->ListHead
))
158 ListEntry
= RemoveHeadList(&List
->ListHead
);
159 Item
= CONTAINING_RECORD(ListEntry
, FILE_SYSTEM_ITEM
, ListEntry
);
160 RtlFreeHeap(ProcessHeap
, 0, Item
);
163 RtlFreeHeap(ProcessHeap
, 0, List
);
168 IN PFILE_SYSTEM_LIST List
)
170 PLIST_ENTRY ListEntry
;
171 PFILE_SYSTEM_ITEM Item
;
177 ListEntry
= List
->ListHead
.Flink
;
178 while (ListEntry
!= &List
->ListHead
)
180 Item
= CONTAINING_RECORD(ListEntry
, FILE_SYSTEM_ITEM
, ListEntry
);
182 coPos
.X
= List
->Left
;
183 coPos
.Y
= List
->Top
+ (SHORT
)Index
;
184 FillConsoleOutputAttribute(StdOutput
,
185 FOREGROUND_WHITE
| BACKGROUND_BLUE
,
189 FillConsoleOutputCharacterA(StdOutput
,
195 if (Item
->FileSystem
)
197 snprintf(Buffer
, sizeof(Buffer
),
198 MUIGetString(Item
->QuickFormat
? STRING_FORMATDISK1
199 : STRING_FORMATDISK2
),
204 snprintf(Buffer
, sizeof(Buffer
), MUIGetString(STRING_KEEPFORMAT
));
207 if (ListEntry
== &List
->Selected
->ListEntry
)
209 CONSOLE_SetInvertedTextXY(List
->Left
,
210 List
->Top
+ (SHORT
)Index
,
215 CONSOLE_SetTextXY(List
->Left
,
216 List
->Top
+ (SHORT
)Index
,
220 ListEntry
= ListEntry
->Flink
;
225 ScrollDownFileSystemList(
226 IN PFILE_SYSTEM_LIST List
)
228 if (List
->Selected
->ListEntry
.Flink
!= &List
->ListHead
)
230 List
->Selected
= CONTAINING_RECORD(List
->Selected
->ListEntry
.Flink
, FILE_SYSTEM_ITEM
, ListEntry
);
231 DrawFileSystemList(List
);
236 ScrollUpFileSystemList(
237 IN PFILE_SYSTEM_LIST List
)
239 if (List
->Selected
->ListEntry
.Blink
!= &List
->ListHead
)
241 List
->Selected
= CONTAINING_RECORD(List
->Selected
->ListEntry
.Blink
, FILE_SYSTEM_ITEM
, ListEntry
);
242 DrawFileSystemList(List
);