Debian Codegraph @

Descent3/newui_filedlg.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
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 3 of the License, or
8 * (at your option) any later version.
9 *
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.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/newui_filedlg.cpp $
21 * $Revision: 22 $
22 * $Date: 10/25/99 10:46a $
23 * $Author: Matt $
24 *
25 * File Dialog using NewUI class
26 *
27 * $Log: /DescentIII/Main/newui_filedlg.cpp $
28 *
29 * 22 10/25/99 10:46a Matt
30 * Code from Duane that allows users to double-click on a directory in the
31 * file dialog to open that folder.
32 *
33 * 21 9/07/99 4:33p Jeff
34 * fixed crash due to not setting a pointer to NULL
35 *
36 * 20 5/10/99 10:23p Ardussi
37 * changes to compile on Mac
38 *
39 * 19 5/10/99 9:21p Samir
40 * Ardussi pointed out this small but significant error when checking for
41 * valid path.
42 *
43 * 18 4/20/99 3:11p Jeff
44 * handle invalid initial directory
45 *
46 * 17 4/20/99 3:07p Jeff
47 * save last directory
48 *
49 * 16 4/20/99 11:46a Samir
50 * numerous ui 'feel' fixes.
51 *
52 * 15 4/14/99 3:56a Jeff
53 * fixed case mismatch in #includes
54 *
55 * 14 2/28/99 6:14p Jeff
56 * use UID_OK and UID_CANCEL
57 *
58 * 13 2/28/99 2:57a Jeff
59 * got rid of useless hotspots
60 *
61 * 12 2/28/99 2:23a Jeff
62 * use new ui
63 *
64 * 11 1/29/99 5:22p Jeff
65 * localization
66 *
67 * 10 1/27/99 5:47p Jeff
68 * put up a message that files are being gathered...ease the fear of crash
69 *
70 * 9 1/21/99 11:15p Jeff
71 * pulled out some structs and defines from header files and moved them
72 * into seperate header files so that multiplayer dlls don't require major
73 * game headers, just those new headers. Side effect is a shorter build
74 * time. Also cleaned up some header file #includes that weren't needed.
75 * This affected polymodel.h, object.h, player.h, vecmat.h, room.h,
76 * manage.h and multi.h
77 *
78 * 8 10/08/98 4:23p Kevin
79 * Changed code to comply with memory library usage. Always use mem_malloc
80 * , mem_free and mem_strdup
81 *
82 * 7 9/28/98 4:35p Jeff
83 * general UI changes and improvements
84 *
85 * 6 9/23/98 6:19p Jeff
86 * finished up (hopefully) updating the config/ui dialogs to meet our
87 * standard. Keyboard/joystick config still needs some work
88 *
89 * 5 9/02/98 2:54p Jeff
90 * added defines for text colors to be used throughout the game...fixed up
91 * buddy menu too
92 *
93 * 4 8/19/98 2:18p Jeff
94 * changed ddio_CleanPath
95 *
96 * 3 7/30/98 12:31p Jeff
97 *
98 * 2 7/29/98 5:39p Jeff
99 * initial creation
100 *
101 * $NoKeywords: $
102 */
103
104 #include <cstdlib>
105 #include <cstring>
106 #include <filesystem>
107
108 #include "mono.h"cxx . . $ `<file>/ddebug/mono.h`/
109 #include "renderer.h"cxx . . $ `<file>/lib/renderer.h`/
110 #include "render.h"cxx . . $ `<file>/Descent3/render.h`/
111 #include "ddio.h"cxx . . $ `<file>/ddio/ddio.h`/
112 #include "descent.h"cxx . . $ `<file>/Descent3/descent.h`/
113 #include "game.h"cxx . . $ `<file>/Descent3/game.h`/
114 #include "cfile.h"cxx . . $ `<file>/cfile/cfile.h`/
115 #include "application.h"cxx . . $ `<file>/lib/application.h`/
116 #include "newui.h"cxx . . $ `<file>/Descent3/newui.h`/
117 #include "grtext.h"cxx . . $ `<file>/grtext/grtext.h`/
118 #include "gamefont.h"cxx . . $ `<file>/Descent3/gamefont.h`/
119 #include "stringtable.h"cxx . . $ `<file>/Descent3/stringtable.h`/
120 #include "ConfigItem.h"cxx . . $ `<file>/Descent3/ConfigItem.h`/ //for colors
121 #include "mem.h"cxx . . $ `<file>/mem/mem.h`/
122
123 newuiListBoxcxx . . $ newuiListBox# *path_listcxx . . $ path_list. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
124 char *path_editcxx . . $ path_edit. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
125 char *working_filenamecxx . . $ working_filename. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
126 char *working_listpathcxx . . $ working_listpath. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
127 newuiSheetcxx . . $ newuiSheet# *fdlg_working_sheetcxx . . $ fdlg_working_sheet. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
128
129 char NewuiFileDlg_lastpathcxx . . $ NewuiFileDlg_lastpath.[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!] = {'\0'};
130
131 // border size of the UI window
132 #define UI_BORDERSIZEcxx . . $ `Descent3/newui_filedlg.cpp:132:9`! 20
133
134 // returns the number of files in path p, that matches wildcard
135 // it fills in buffer (up to maxcount) with the files found
136 int GetFilesInPathcxx . . $ GetFilesInPath(9c3e5e98b18f8d37).(char **buffer, int maxcount, const char *p, const char *wildcard);
137
138 // returns the number of directories in path p
139 // it fills in buffer (up to maxcount) with the directories found
140 int GetDirectoriesInPathcxx . . $ GetDirectoriesInPath(ab39428d9351a64a).(char **buffer, int maxcount, const char *p);
141
142 // Updates the given listbox with the directories and files that match wildcards (each wildcard seperates by a ;)
143 void UpdateFileListcxx . . $ UpdateFileList(dc9e0ef26fa8a297).(newuiListBoxcxx . . $ newuiListBox# *lb, const char *path, char *wildcards);
144
145 // Callback function for listbox
146 void FileSelectCallbackcxx . . $ FileSelectCallback(d4f767463ce0a6b3).(int index);
147
148 void FDlg_EnableWaitMessagecxx . . $ FDlg_EnableWaitMessage(b45ddcbc8423892c).(bool enable) {
149 #define FDWM_HEIGHTcxx . . $ `Descent3/newui_filedlg.cpp:149:9`! 128
150 #define FDWM_WIDTHcxx . . $ `Descent3/newui_filedlg.cpp:150:9`! 256
151
152 static NewUIGameWindowcxx . . $ NewUIGameWindow# *msgbox = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
153 static bool opened = false;
154 newuiSheetcxx . . $ newuiSheet# *sheet;
155
156 if (opened == enable) {
157 Int3cxx . . $ `misc/pserror.h:247:9`!();
158 }
159
160 opened = enable;
161
162 if (enable) {
163 msgbox = new NewUIGameWindowcxx . . $ NewUIGameWindow#;
164 if (msgbox) {
165
166 msgbox->Createcxx . . $ NewUIGameWindow#Create(1559a299834bcdd5).(0, 0, FDWM_WIDTHcxx . . $ `Descent3/newui_filedlg.cpp:150:9`!, FDWM_HEIGHTcxx . . $ `Descent3/newui_filedlg.cpp:149:9`!, UIF_PROCESS_ALLcxx . . $ `ui/ui.h:348:9`! | UIF_CENTERcxx . . $ `ui/ui.h:342:9`!);
167
168 sheet = msgbox->GetSheetcxx . . $ newuiTiledWindow#GetSheet(661381a276e5b628).();
169 sheet->NewGroupcxx . . $ newuiSheet#NewGroup(465b27e37ce794b1).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 45, 25);
170 sheet->AddTextcxx . . $ newuiSheet#AddText(326aeb464d16410c).(TXT_GETTINGFILEScxx . . $ `Descent3/stringtable.h:693:9`!);
171
172 msgbox->Opencxx . . $ UIWindow#Open(49f6e7a06ebc5aa8).();
173 sheet->Realizecxx . . $ newuiSheet#Realize(49f6e7a06ebc5aa8).();
174
175 // fake a DoUI
176 DoUIFramecxx . . $ DoUIFrame(49f6e7a06ebc5aa8).();
177 rend_Flipcxx . . $ rend_Flip(49f6e7a06ebc5aa8).();
178 }
179 } else {
180
181 if (msgbox) {
182 msgbox->Closecxx . . $ UIWindow#Close(49f6e7a06ebc5aa8).();
183 msgbox->Destroycxx . . $ UIWindow#Destroy(49f6e7a06ebc5aa8).();
184 delete msgbox;
185 }
186 msgbox = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
187 }
188 }
189
190 bool IsDirectoryItemcxx . . $ IsDirectoryItem(c6b7e35ff6de5671).(char *item) {
191 if (*item != ' ')
192 return false;
193 if (*(item + 1) != '[')
194 return false;
195 if (item[strlen(item) - 1] == ']')
196 return true;
197 return false;
198 }
199 // Callback function for listbox
200 void FileSelectCallbackcxx . . $ FileSelectCallback(d4f767463ce0a6b3).(int index) {
201 if ((!path_editcxx . . $ path_edit.) || (!working_filenamecxx . . $ working_filename.) || (!path_listcxx . . $ path_list.) || (!working_listpathcxx . . $ working_listpath.))
202 return;
203
204 char file[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!];
205 path_listcxx . . $ path_list.->GetCurrentItemcxx . . $ newuiListBox#GetCurrentItem(37e8d18a243bba77).(file, _MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!);
206 if (IsDirectoryItemcxx . . $ IsDirectoryItem(c6b7e35ff6de5671).(file))
207 return; // we don't care about directories
208
209 strncpy(working_filenamecxx . . $ working_filename., file, _MAX_FNAMEcxx . . $ `linux/linux_fix.h:35:9`! - 1);
210 working_filenamecxx . . $ working_filename.[_MAX_FNAMEcxx . . $ `linux/linux_fix.h:35:9`! - 1] = '\0';
211
212 ddio_MakePathcxx . . $ ddio_MakePath(9ad4b0815420a85).(file, working_listpathcxx . . $ working_listpath., working_filenamecxx . . $ working_filename., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
213
214 strncpy(path_editcxx . . $ path_edit., file, _MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`! - 1);
215 path_editcxx . . $ path_edit.[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`! - 1] = '\0';
216 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "New Path: %s\n", path_edit);
217 fdlg_working_sheetcxx . . $ fdlg_working_sheet.->UpdateChangescxx . . $ newuiSheet#UpdateChanges(49f6e7a06ebc5aa8).();
218 }
219
220 // Displays a file/directory dialog box
221 // path - Initial path, will contain the chosen file/path on exit with true, must be at least _MAX_PATH
222 // in size title - Title of the dialog wildc - semicolon (;) seperated list of wildcards to
223 // be shown flags - see header PFDF_ for flags
224 bool DoPathFileDialogcxx . . $ DoPathFileDialog(5d8ce13d0347d7c1).(bool save_dialog, char *path, const char *title, const char *wildc, int flags) {
225 #define HS_CANCELcxx . . $ `Descent3/newui_filedlg.cpp:225:9`! 0
226 #define HS_OKcxx . . $ `Descent3/newui_filedlg.cpp:226:9`! 1
227 #define HS_UPDIRcxx . . $ `Descent3/newui_filedlg.cpp:227:9`! 0
228 #define ED_WILDCARDcxx . . $ `Descent3/newui_filedlg.cpp:228:9`! 0
229 #define ED_FILENAMEcxx . . $ `Descent3/newui_filedlg.cpp:229:9`! 1
230 #define ID_LISTBOXcxx . . $ `Descent3/newui_filedlg.cpp:230:9`! 25
231 #define ID_UPDIRcxx . . $ `Descent3/newui_filedlg.cpp:231:9`! 26
232 #define ID_WILDCARDcxx . . $ `Descent3/newui_filedlg.cpp:232:9`! 27
233 #define ID_FILENAMEcxx . . $ `Descent3/newui_filedlg.cpp:233:9`! 28
234 #define ID_CANCELcxx . . $ `Descent3/newui_filedlg.cpp:234:9`! UID_CANCELcxx . . $ `ui/ui.h:369:9`!
235 #define ID_OKcxx . . $ `Descent3/newui_filedlg.cpp:235:9`! UID_OKcxx . . $ `ui/ui.h:368:9`!
236 newuiTiledWindowcxx . . $ newuiTiledWindow# windowcxx . . $ newuiTiledWindow#newuiTiledWindow(49f6e7a06ebc5aa8).;
237 newuiSheetcxx . . $ newuiSheet# *sheet;
238 newuiListBoxcxx . . $ newuiListBox# *listbox;
239 char *edits[2];
240
241 char wildcards[256];
242 char working_path[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!];
243 char working_file[_MAX_FNAMEcxx . . $ `linux/linux_fix.h:35:9`!];
244
245 if (!path)
246 return false;
247 if (!title)
248 return false;
249 if (!wildc)
250 return false;
251
252 strcpy(wildcards, wildc);
253 strcpy(working_file, "");
254
255 // figure out the correct path
256 char oldpath[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!];
257 ddio_GetWorkingDircxx . . $ ddio_GetWorkingDir(a07d8cccb7673f5a).(oldpath, _MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!);
258 if (!ddio_SetWorkingDircxx . . $ ddio_SetWorkingDir(c5f7da30cbc0f4e9).(path)) {
259 // try to use last good path
260 if (!ddio_SetWorkingDircxx . . $ ddio_SetWorkingDir(c5f7da30cbc0f4e9).(NewuiFileDlg_lastpathcxx . . $ NewuiFileDlg_lastpath.)) {
261 strcpy(path, LocalD3Dircxx . . $ LocalD3Dir.);
262 } else {
263 strcpy(path, NewuiFileDlg_lastpathcxx . . $ NewuiFileDlg_lastpath.);
264 }
265 }
266 ddio_SetWorkingDircxx . . $ ddio_SetWorkingDir(c5f7da30cbc0f4e9).(oldpath);
267
268 // Create all the UI Items
269 window.Createcxx . . $ newuiTiledWindow#Create(9860cac3d762132).(title, 0, 0, 384, 288);
270 fdlg_working_sheetcxx . . $ fdlg_working_sheet. = sheet = window.GetSheetcxx . . $ newuiTiledWindow#GetSheet(661381a276e5b628).();
271
272 sheet->NewGroupcxx . . $ newuiSheet#NewGroup(465b27e37ce794b1).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 10, 0);
273 listbox = sheet->AddListBoxcxx . . $ newuiSheet#AddListBox(b890ce7adcd9a5ed).(268, 100, ID_LISTBOXcxx . . $ `Descent3/newui_filedlg.cpp:230:9`!);
274
275 sheet->NewGroupcxx . . $ newuiSheet#NewGroup(465b27e37ce794b1).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 0, 145);
276 edits[ED_FILENAMEcxx . . $ `Descent3/newui_filedlg.cpp:229:9`!] = sheet->AddEditBoxcxx . . $ newuiSheet#AddEditBox(56493f8cd670630f).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, _MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!, 300, ID_FILENAMEcxx . . $ `Descent3/newui_filedlg.cpp:233:9`!);
277 edits[ED_WILDCARDcxx . . $ `Descent3/newui_filedlg.cpp:228:9`!] = sheet->AddEditBoxcxx . . $ newuiSheet#AddEditBox(56493f8cd670630f).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 256, 150, ID_WILDCARDcxx . . $ `Descent3/newui_filedlg.cpp:232:9`!);
278 sheet->AddLongButtoncxx . . $ newuiSheet#AddLongButton(680bf41633375800).(TXT_UPTOPARENTDIRcxx . . $ `Descent3/stringtable.h:360:9`!, ID_UPDIRcxx . . $ `Descent3/newui_filedlg.cpp:231:9`!);
279
280 sheet->NewGroupcxx . . $ newuiSheet#NewGroup(465b27e37ce794b1).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 200, 160);
281 sheet->AddButtoncxx . . $ newuiSheet#AddButton(680bf41633375800).((save_dialog) ? TXT_SAVEcxx . . $ `Descent3/stringtable.h:400:9`! : TXT_OPENcxx . . $ `Descent3/stringtable.h:401:9`!, ID_OKcxx . . $ `Descent3/newui_filedlg.cpp:235:9`!);
282 sheet->AddButtoncxx . . $ newuiSheet#AddButton(680bf41633375800).(TXT_CANCELcxx . . $ `Descent3/stringtable.h:35:9`!, ID_CANCELcxx . . $ `Descent3/newui_filedlg.cpp:234:9`!);
283
284 working_filenamecxx . . $ working_filename. = working_file;
285 working_listpathcxx . . $ working_listpath. = working_path;
286 path_editcxx . . $ path_edit. = edits[ED_FILENAMEcxx . . $ `Descent3/newui_filedlg.cpp:229:9`!];
287 path_listcxx . . $ path_list. = listbox;
288
289 listbox->SetSelectChangeCallbackcxx . . $ newuiListBox#SetSelectChangeCallback(94eb4457dc8d4d10).(FileSelectCallbackcxx . . $ FileSelectCallback(d4f767463ce0a6b3).);
290
291 ddio_CleanPathcxx . . $ ddio_CleanPath(72c91e5e80d20bae).(working_path, path);
292 UpdateFileListcxx . . $ UpdateFileList(dc9e0ef26fa8a297).(listbox, working_path, wildcards);
293
294 strncpy(edits[ED_FILENAMEcxx . . $ `Descent3/newui_filedlg.cpp:229:9`!], working_path, _MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`! - 1);
295 edits[ED_FILENAMEcxx . . $ `Descent3/newui_filedlg.cpp:229:9`!][_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`! - 1] = '\0';
296
297 strncpy(edits[ED_WILDCARDcxx . . $ `Descent3/newui_filedlg.cpp:228:9`!], wildcards, 255);
298 edits[ED_WILDCARDcxx . . $ `Descent3/newui_filedlg.cpp:228:9`!][255] = '\0';
299
300 bool ret = false;
301 bool exit_menu = false;
302
303 sheet->SetInitialFocusedGadgetcxx . . $ newuiSheet#SetInitialFocusedGadget(68e3ae50fe6578a9).(ID_LISTBOXcxx . . $ `Descent3/newui_filedlg.cpp:230:9`!);
304
305 window.Opencxx . . $ UIWindow#Open(49f6e7a06ebc5aa8).();
306 while (!exit_menu) {
307 int res = window.DoUIcxx . . $ newuiTiledWindow#DoUI(b126dc7c1de90089).();
308
309 // handle all UI results.
310 switch (res) {
311 case ID_OKcxx . . $ `Descent3/newui_filedlg.cpp:235:9`!: {
312 strcpy(path, edits[ED_FILENAMEcxx . . $ `Descent3/newui_filedlg.cpp:229:9`!]);
313
314 if (path[0] == '\0') {
315 DoMessageBoxcxx . . $ DoMessageBox(dcc99837539e9edc).(TXT_ERRORcxx . . $ `Descent3/stringtable.h:165:9`!, TXT_ERRCHOOSEFILEcxx . . $ `Descent3/stringtable.h:361:9`!, MSGBOX_OKcxx . . $ `Descent3/newui_core.h:78:9`!);
316 } else {
317 if (stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::is_directorycxx . . $ std/filesystem/is_directory(c53a6ef3278968b1).(pathcxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).)) {
318 char newpath[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!];
319 char file[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!];
320 int selection = listbox->GetCurrentIndexcxx . . $ newuiListBox#GetCurrentIndex(b126dc7c1de90089).();
321 if ((selection >= 0) && (listbox->GetCurrentItemcxx . . $ newuiListBox#GetCurrentItem(37e8d18a243bba77).(file, _MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!))) {
322 if (*file) {
323 strcpy(working_file, "");
324
325 // ok the user double clicked on a directory
326 // convert file without the brackets
327 file[strlen(file) - 1] = '\0';
328 if (strlen(working_path) != 0)
329 ddio_MakePathcxx . . $ ddio_MakePath(9ad4b0815420a85).(newpath, working_path, file + 2, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
330 else
331 strcpy(newpath, file + 2);
332
333 UpdateFileListcxx . . $ UpdateFileList(dc9e0ef26fa8a297).(listbox, newpath, wildcards);
334 ddio_CleanPathcxx . . $ ddio_CleanPath(72c91e5e80d20bae).(working_path, newpath);
335
336 strncpy(edits[ED_FILENAMEcxx . . $ `Descent3/newui_filedlg.cpp:229:9`!], working_path, _MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`! - 1);
337 edits[ED_FILENAMEcxx . . $ `Descent3/newui_filedlg.cpp:229:9`!][_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`! - 1] = '\0';
338 }
339 }
340 // DoMessageBox(TXT_ERROR,TXT_ERRCHOOSEFILE,MSGBOX_OK);
341 } else {
342 if (flags & PFDF_FILEMUSTEXISTcxx . . $ `Descent3/newui.h:351:9`!) {
343 if (!cfexistcxx . . $ cfexist(293b0826c8d9cb54).(pathcxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).)) {
344 DoMessageBoxcxx . . $ DoMessageBox(dcc99837539e9edc).(TXT_ERRORcxx . . $ `Descent3/stringtable.h:165:9`!, TXT_ERRFILENOTEXISTcxx . . $ `Descent3/stringtable.h:362:9`!, MSGBOX_OKcxx . . $ `Descent3/newui_core.h:78:9`!);
345 } else {
346 ddio_SplitPathcxx . . $ ddio_SplitPath(b05ba7ab99603c07).(path, NewuiFileDlg_lastpathcxx . . $ NewuiFileDlg_lastpath., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
347 ret = exit_menu = true;
348 }
349 } else {
350 ddio_SplitPathcxx . . $ ddio_SplitPath(b05ba7ab99603c07).(path, NewuiFileDlg_lastpathcxx . . $ NewuiFileDlg_lastpath., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
351 ret = exit_menu = true;
352 }
353 }
354 }
355 } break;
356 case ID_CANCELcxx . . $ `Descent3/newui_filedlg.cpp:234:9`!:
357 ret = false;
358 exit_menu = true;
359 break;
360 case ID_LISTBOXcxx . . $ `Descent3/newui_filedlg.cpp:230:9`!: {
361 char newpath[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!];
362 char file[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!];
363 // check to see if the double clicked on a dir
364 int selection = listbox->GetCurrentIndexcxx . . $ newuiListBox#GetCurrentIndex(b126dc7c1de90089).();
365
366 if ((selection >= 0) && (listbox->GetCurrentItemcxx . . $ newuiListBox#GetCurrentItem(37e8d18a243bba77).(file, _MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!))) {
367 if (*file) {
368 if (IsDirectoryItemcxx . . $ IsDirectoryItem(c6b7e35ff6de5671).(file)) {
369 strcpy(working_file, "");
370
371 // ok the user double clicked on a directory
372 // convert file without the brackets
373 file[strlen(file) - 1] = '\0';
374 if (strlen(working_path) != 0)
375 ddio_MakePathcxx . . $ ddio_MakePath(9ad4b0815420a85).(newpath, working_path, file + 2, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
376 else
377 strcpy(newpath, file + 2);
378
379 UpdateFileListcxx . . $ UpdateFileList(dc9e0ef26fa8a297).(listbox, newpath, wildcards);
380 ddio_CleanPathcxx . . $ ddio_CleanPath(72c91e5e80d20bae).(working_path, newpath);
381
382 strncpy(edits[ED_FILENAMEcxx . . $ `Descent3/newui_filedlg.cpp:229:9`!], working_path, _MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`! - 1);
383 edits[ED_FILENAMEcxx . . $ `Descent3/newui_filedlg.cpp:229:9`!][_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`! - 1] = '\0';
384 } else {
385 // double click on a file
386 strcpy(working_file, file);
387 FileSelectCallbackcxx . . $ FileSelectCallback(d4f767463ce0a6b3).(selection);
388 strcpy(file, edits[ED_FILENAMEcxx . . $ `Descent3/newui_filedlg.cpp:229:9`!]);
389
390 // the user wants a file
391 if (flags & PFDF_FILEMUSTEXISTcxx . . $ `Descent3/newui.h:351:9`!) {
392 if (cfexistcxx . . $ cfexist(293b0826c8d9cb54).(filecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).)) {
393 exit_menu = true;
394 ret = true;
395 strcpy(path, file);
396 ddio_SplitPathcxx . . $ ddio_SplitPath(b05ba7ab99603c07).(path, NewuiFileDlg_lastpathcxx . . $ NewuiFileDlg_lastpath., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
397 } else {
398 // invalid file
399 DoMessageBoxcxx . . $ DoMessageBox(dcc99837539e9edc).(TXT_ERRORcxx . . $ `Descent3/stringtable.h:165:9`!, TXT_ERRCHOOSEFILEcxx . . $ `Descent3/stringtable.h:361:9`!, MSGBOX_OKcxx . . $ `Descent3/newui_core.h:78:9`!);
400 }
401 } else {
402 strcpy(path, file);
403 exit_menu = true;
404 ret = true;
405 ddio_SplitPathcxx . . $ ddio_SplitPath(b05ba7ab99603c07).(path, NewuiFileDlg_lastpathcxx . . $ NewuiFileDlg_lastpath., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
406 }
407 }
408 }
409 }
410 } break;
411 case ID_UPDIRcxx . . $ `Descent3/newui_filedlg.cpp:231:9`!: {
412 char newpath[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!];
413 strcpy(working_file, "");
414 ddio_GetParentPathcxx . . $ ddio_GetParentPath(9efbdc942cde3d3d).(newpath, working_path);
415 strcpy(working_path, newpath);
416
417 UpdateFileListcxx . . $ UpdateFileList(dc9e0ef26fa8a297).(listbox, working_path, wildcards);
418 strncpy(edits[ED_FILENAMEcxx . . $ `Descent3/newui_filedlg.cpp:229:9`!], working_path, _MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`! - 1);
419 edits[ED_FILENAMEcxx . . $ `Descent3/newui_filedlg.cpp:229:9`!][_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`! - 1] = '\0';
420 } break;
421 case ID_WILDCARDcxx . . $ `Descent3/newui_filedlg.cpp:232:9`!: {
422 strcpy(wildcards, edits[ED_WILDCARDcxx . . $ `Descent3/newui_filedlg.cpp:228:9`!]);
423 UpdateFileListcxx . . $ UpdateFileList(dc9e0ef26fa8a297).(listbox, working_path, wildcards);
424 } break;
425 case ID_FILENAMEcxx . . $ `Descent3/newui_filedlg.cpp:233:9`!: {
426 char c[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!];
427 strcpy(c, edits[ED_FILENAMEcxx . . $ `Descent3/newui_filedlg.cpp:229:9`!]);
428
429 if (strlen(c) > 0) {
430 if (!stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::is_directorycxx . . $ std/filesystem/is_directory(c53a6ef3278968b1).(ccxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).)) {
431 // the user wants a file
432 if (flags & PFDF_FILEMUSTEXISTcxx . . $ `Descent3/newui.h:351:9`!) {
433 if (cfexistcxx . . $ cfexist(293b0826c8d9cb54).(ccxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).)) {
434 strcpy(path, c);
435 exit_menu = true;
436 ret = true;
437 ddio_SplitPathcxx . . $ ddio_SplitPath(b05ba7ab99603c07).(path, NewuiFileDlg_lastpathcxx . . $ NewuiFileDlg_lastpath., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
438 } else {
439 // invalid file
440 DoMessageBoxcxx . . $ DoMessageBox(dcc99837539e9edc).(TXT_ERRORcxx . . $ `Descent3/stringtable.h:165:9`!, TXT_ERRFILENOTEXISTcxx . . $ `Descent3/stringtable.h:362:9`!, MSGBOX_OKcxx . . $ `Descent3/newui_core.h:78:9`!);
441 }
442 } else {
443 strcpy(path, c);
444 ddio_SplitPathcxx . . $ ddio_SplitPath(b05ba7ab99603c07).(path, NewuiFileDlg_lastpathcxx . . $ NewuiFileDlg_lastpath., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
445 exit_menu = true;
446 ret = true;
447 }
448 } else {
449 // just change directories
450 strcpy(working_path, c);
451 UpdateFileListcxx . . $ UpdateFileList(dc9e0ef26fa8a297).(listbox, working_path, wildcards);
452 }
453 }
454 } break;
455 }
456 }
457
458 if (ret) {
459 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Selected Filename: %s\n", path);
460 } else {
461 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Cancel!\n");
462 }
463
464 window.Closecxx . . $ UIWindow#Close(49f6e7a06ebc5aa8).();
465 window.Destroycxx . . $ UIWindow#Destroy(49f6e7a06ebc5aa8).();
466
467 working_filenamecxx . . $ working_filename. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
468 working_listpathcxx . . $ working_listpath. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
469 path_editcxx . . $ path_edit. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
470 path_listcxx . . $ path_list. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
471
472 return ret;
473 }
474
475 // returns the number of files in path p, that matches wildcard
476 // it fills in buffer (up to maxcount) with the files found
477 int GetFilesInPathcxx . . $ GetFilesInPath(9c3e5e98b18f8d37).(char **buffer, int maxcount, const char *p, const char *wildcard) {
478 ASSERTcxx . . $ `misc/pserror.h:246:9`!(buffer);
479 ASSERTcxx . . $ `misc/pserror.h:246:9`!(p);
480 ASSERTcxx . . $ `misc/pserror.h:246:9`!(wildcard);
481 if (maxcount <= 0)
482 return 0;
483
484 char old_path[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!], path[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!];
485 ddio_GetWorkingDircxx . . $ ddio_GetWorkingDir(a07d8cccb7673f5a).(old_path, _MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!);
486 if (!ddio_SetWorkingDircxx . . $ ddio_SetWorkingDir(c5f7da30cbc0f4e9).(p)) {
487 // directory doesn't exist
488 ddio_SetWorkingDircxx . . $ ddio_SetWorkingDir(c5f7da30cbc0f4e9).(old_path);
489 return -1;
490 }
491
492 ddio_GetWorkingDircxx . . $ ddio_GetWorkingDir(a07d8cccb7673f5a).(path, _MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!);
493 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(path, p)) {
494 // the working dir is not the same as the passed in path, so try to create a correct path and set it
495 ddio_MakePathcxx . . $ ddio_MakePath(9ad4b0815420a85).(path, p, "", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
496 if (!ddio_SetWorkingDircxx . . $ ddio_SetWorkingDir(c5f7da30cbc0f4e9).(path)) {
497 ddio_SetWorkingDircxx . . $ ddio_SetWorkingDir(c5f7da30cbc0f4e9).(old_path);
498 return -1;
499 }
500 }
501
502 int count = 0;
503 char tempbuffer[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!];
504
505 if (ddio_FindFileStartcxx . . $ ddio_FindFileStart(84e74a5521f49206).(wildcard, tempbuffer)) {
506 if (!stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::is_directorycxx . . $ std/filesystem/is_directory(c53a6ef3278968b1).(tempbuffercxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).)) {
507 buffer[count] = mem_strdupcxx . . $ `mem/mem.h:81:9`!(tempbuffer);
508 count++;
509 }
510
511 bool done = false;
512
513 while (!done) {
514 if (ddio_FindNextFilecxx . . $ ddio_FindNextFile(c6b7e35ff6de5671).(tempbuffer)) {
515 if (!stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::is_directorycxx . . $ std/filesystem/is_directory(c53a6ef3278968b1).(tempbuffercxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).)) {
516 if (count < maxcount)
517 buffer[count] = mem_strdupcxx . . $ `mem/mem.h:81:9`!(tempbuffer);
518 count++;
519 }
520 } else
521 done = true;
522 }
523 }
524 ddio_FindFileClosecxx . . $ ddio_FindFileClose(49f6e7a06ebc5aa8).();
525 ddio_SetWorkingDircxx . . $ ddio_SetWorkingDir(c5f7da30cbc0f4e9).(old_path);
526 return count;
527 }
528
529 // returns the number of directories in path p
530 // it fills in buffer (up to maxcount) with the directories found
531 int GetDirectoriesInPathcxx . . $ GetDirectoriesInPath(ab39428d9351a64a).(char **buffer, int maxcount, const char *p) {
532 ASSERTcxx . . $ `misc/pserror.h:246:9`!(buffer);
533 ASSERTcxx . . $ `misc/pserror.h:246:9`!(p);
534 if (maxcount <= 0)
535 return 0;
536
537 int i;
538 for (i = 0; i < maxcount; i++) {
539 buffer[i] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
540 }
541
542 char old_path[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!], path[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!];
543
544 ddio_GetWorkingDircxx . . $ ddio_GetWorkingDir(a07d8cccb7673f5a).(old_path, _MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!);
545 if (!ddio_SetWorkingDircxx . . $ ddio_SetWorkingDir(c5f7da30cbc0f4e9).(p)) {
546 // directory doesn't exist
547 ddio_SetWorkingDircxx . . $ ddio_SetWorkingDir(c5f7da30cbc0f4e9).(old_path);
548 return -1;
549 }
550
551 ddio_GetWorkingDircxx . . $ ddio_GetWorkingDir(a07d8cccb7673f5a).(path, _MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!);
552 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(path, p)) {
553 // the working dir is not the same as the passed in path, so try to create a correct path and set it
554 ddio_MakePathcxx . . $ ddio_MakePath(9ad4b0815420a85).(path, p, "", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
555 if (!ddio_SetWorkingDircxx . . $ ddio_SetWorkingDir(c5f7da30cbc0f4e9).(path)) {
556 ddio_SetWorkingDircxx . . $ ddio_SetWorkingDir(c5f7da30cbc0f4e9).(old_path);
557 return -1;
558 }
559 }
560
561 int count = 0;
562 char tempbuffer[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!];
563
564 if (ddio_FindFileStartcxx . . $ ddio_FindFileStart(84e74a5521f49206).("*", tempbuffer)) {
565 if (stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::is_directorycxx . . $ std/filesystem/is_directory(c53a6ef3278968b1).(tempbuffercxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).)) {
566 buffer[count] = mem_strdupcxx . . $ `mem/mem.h:81:9`!(tempbuffer);
567 count++;
568 }
569
570 bool done = false;
571
572 while (!done) {
573 if (ddio_FindNextFilecxx . . $ ddio_FindNextFile(c6b7e35ff6de5671).(tempbuffer)) {
574 if (stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::is_directorycxx . . $ std/filesystem/is_directory(c53a6ef3278968b1).(tempbuffercxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).)) {
575 if (count < maxcount)
576 buffer[count] = mem_strdupcxx . . $ `mem/mem.h:81:9`!(tempbuffer);
577 count++;
578 }
579 } else
580 done = true;
581 }
582 }
583 ddio_FindFileClosecxx . . $ ddio_FindFileClose(49f6e7a06ebc5aa8).();
584 ddio_SetWorkingDircxx . . $ ddio_SetWorkingDir(c5f7da30cbc0f4e9).(old_path);
585 return count;
586 }
587
588 // Updates the given listbox with the directories and files that match wildcards (each wildcard seperates by a ;)
589 void UpdateFileListcxx . . $ UpdateFileList(dc9e0ef26fa8a297).(newuiListBoxcxx . . $ newuiListBox# *lb, const char *path, char *wildcards) {
590 FDlg_EnableWaitMessagecxx . . $ FDlg_EnableWaitMessage(b45ddcbc8423892c).(true);
591 lb->RemoveAllcxx . . $ newuiListBox#RemoveAll(49f6e7a06ebc5aa8).();
592
593 // if path is NULL or 0 length string then just list the directories
594 if ((!path) || (*path == '\0')) {
595 char *roots[30];
596 int rootcount = ddio_GetFileSysRootscxx . . $ ddio_GetFileSysRoots(9654734fd31b2328).((char **)&roots, 30);
597 if (!rootcount) {
598 FDlg_EnableWaitMessagecxx . . $ FDlg_EnableWaitMessage(b45ddcbc8423892c).(false);
599 return;
600 }
601 char tempbuffer[5];
602 for (int i = 0; i < rootcount; i++) {
603 if (roots[i]) {
604 snprintf(tempbuffer, sizeof(tempbuffer), " [%s]", roots[i]);
605 lb->AddItemcxx . . $ newuiListBox#AddItem(85c52e162fed56f9).(tempbuffer);
606 mem_freecxx . . $ `mem/mem.h:80:9`!(roots[i]);
607 }
608 }
609 FDlg_EnableWaitMessagecxx . . $ FDlg_EnableWaitMessage(b45ddcbc8423892c).(false);
610 return;
611 }
612
613 char **dirs = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
614 char *tempdir[1];
615 char fullpath[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!];
616 ddio_GetRootFromPathcxx . . $ ddio_GetRootFromPath(611124a97efc52dd).(path, fullpath);
617 if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(path, fullpath)) {
618 // we are are the root of the drive, make a dummy path
619 ddio_MakePathcxx . . $ ddio_MakePath(9ad4b0815420a85).(fullpath, path, "", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
620 } else {
621 // just use this
622 strcpy(fullpath, path);
623 }
624
625 int dircount = GetDirectoriesInPathcxx . . $ GetDirectoriesInPath(ab39428d9351a64a).((char **)&tempdir, 1, fullpath);
626 if (dircount == -1) {
627 // invalid directory/path
628 DoMessageBoxcxx . . $ DoMessageBox(dcc99837539e9edc).(TXT_ERRORcxx . . $ `Descent3/stringtable.h:165:9`!, TXT_ERRPATHNOTVALIDcxx . . $ `Descent3/stringtable.h:363:9`!, MSGBOX_OKcxx . . $ `Descent3/newui_core.h:78:9`!);
629 FDlg_EnableWaitMessagecxx . . $ FDlg_EnableWaitMessage(b45ddcbc8423892c).(false);
630 return;
631 }
632
633 if (tempdir[0])
634 mem_freecxx . . $ `mem/mem.h:80:9`!(tempdir[0]);
635 if (dircount > 0) {
636 dirs = (char **)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(char *) * dircount);
637 if (!dirs) {
638 // out of memory!
639 dircount = 0;
640 } else {
641 GetDirectoriesInPathcxx . . $ GetDirectoriesInPath(ab39428d9351a64a).(dirs, dircount, fullpath);
642 }
643 } else {
644 dircount = 0;
645 dirs = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
646 }
647
648 // figure out how many wildcards we have, and allocate accordingly
649 int wildcard_count = 0;
650 char *wc = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
651 char **wc_strings = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
652 int *wc_count = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
653 char ***filelist = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
654 int total_files = 0;
655 int wildcard_len = 0;
656 char *strptr = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
657
658 // save the wildcards
659 wc = (char *)mem_malloccxx . . $ `mem/mem.h:79:9`!(strlen(wildcards) + 2);
660 if (!wc) {
661 FDlg_EnableWaitMessagecxx . . $ FDlg_EnableWaitMessage(b45ddcbc8423892c).(false);
662 return;
663 }
664
665 // make sure there is a tailing ;
666 strcpy(wc, wildcards);
667 wildcard_len = strlen(wildcards);
668 if (wc[wildcard_len - 1] != ';') {
669 wc[wildcard_len] = ';';
670 wc[wildcard_len + 1] = '\0';
671 }
672
673 // break up wildcard string, counting the number of wildcards as we go
674 strptr = wc;
675 while (*strptr != '\0') {
676 if (*strptr == ';') {
677 *strptr = '\0';
678 wildcard_count++;
679 }
680 strptr++;
681 }
682
683 if (wildcard_count > 0) {
684 wc_strings = (char **)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(char *) * wildcard_count);
685 wc_count = (int *)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(int) * wildcard_count);
686
687 if ((wc_strings) && (wc_count)) {
688 int e;
689
690 // get each individual string of the wildcard strings
691 strptr = wc;
692 for (e = 0; e < wildcard_count; e++) {
693 wc_strings[e] = mem_strdupcxx . . $ `mem/mem.h:81:9`!(strptr);
694 strptr += strlen(strptr) + 1;
695 }
696
697 // malloc memory...an array of (array of char *) for each wildcard
698 filelist = (char ***)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(char **) * wildcard_count);
699 if (!filelist) {
700 // there was an error allocating the memory
701 if (wc) {
702 mem_freecxx . . $ `mem/mem.h:80:9`!(wc);
703 wc = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
704 }
705 for (e = 0; e < wildcard_count; e++) {
706 if (wc_strings[e])
707 mem_freecxx . . $ `mem/mem.h:80:9`!(wc_strings[e]);
708 wc_count[e] = 0;
709 filelist[e] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
710 }
711
712 mem_freecxx . . $ `mem/mem.h:80:9`!(wc_strings);
713 wc_strings = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
714 goto wildcard_err;
715 }
716
717 char *templist[1];
718 int count;
719
720 total_files = 0;
721
722 for (e = 0; e < wildcard_count; e++) {
723 // we just need to get how many of each wildcard there is in the directory
724 templist[0] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
725 count = GetFilesInPathcxx . . $ GetFilesInPath(9c3e5e98b18f8d37).((char **)&templist, 1, path, wc_strings[e]);
726 if (count == -1) {
727 // invalid path
728 wc_count[e] = 0;
729 filelist[e] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
730 } else {
731 total_files += count;
732 if (templist[0]) {
733 mem_freecxx . . $ `mem/mem.h:80:9`!(templist[0]);
734 templist[0] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
735 }
736
737 if (count > 0) {
738 // now we need to get all the files for the wildcard
739 filelist[e] = (char **)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(char *) * count);
740 if (filelist[e]) {
741 GetFilesInPathcxx . . $ GetFilesInPath(9c3e5e98b18f8d37).(filelist[e], count, path, wc_strings[e]);
742 wc_count[e] = count;
743 } else {
744 wc_count[e] = 0;
745 }
746 } else {
747 filelist[e] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
748 wc_count[e] = 0;
749 }
750 } // end if(count==-1)
751
752 // we don't need the wildcard anymore, we can free it up
753 if (wc_strings[e])
754 mem_freecxx . . $ `mem/mem.h:80:9`!(wc_strings[e]);
755 } // end for(e=0;e<wildcard_count;e++)
756
757 // free up allocated memory that we don't need anymore
758 mem_freecxx . . $ `mem/mem.h:80:9`!(wc_strings);
759 if (wc)
760 mem_freecxx . . $ `mem/mem.h:80:9`!(wc);
761
762 wc_strings = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
763 wc = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
764 } else {
765 // we couldn't allocate memory for wildcard strings
766 total_files = 0;
767 filelist = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
768 if (wc_count) {
769 for (int e = 0; e < wildcard_count; e++)
770 wc_count[e] = 0;
771 }
772 }
773 }
774
775 wildcard_err:
776 if ((dircount + total_files) == 0) {
777 FDlg_EnableWaitMessagecxx . . $ FDlg_EnableWaitMessage(b45ddcbc8423892c).(false);
778 return;
779 }
780
781 // lbfilelist = new UITextItem[dircount+total_files];
782 char tempbuffer[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`! + 1];
783 int i;
784
785 for (i = 0; i < dircount; i++) {
786 if (dirs[i]) {
787 snprintf(tempbuffer, sizeof(tempbuffer), " [%s]", dirs[i]);
788 lb->AddItemcxx . . $ newuiListBox#AddItem(85c52e162fed56f9).(tempbuffer);
789 mem_freecxx . . $ `mem/mem.h:80:9`!(dirs[i]);
790 }
791 }
792 i = dircount;
793 if (total_files > 0) {
794 for (int j = 0; j < wildcard_count; j++) {
795 int num_files;
796 char **wc_filelist;
797 num_files = wc_count[j];
798 if (num_files > 0) {
799 wc_filelist = filelist[j];
800 for (int k = 0; k < num_files; k++) {
801 if (wc_filelist[k]) {
802 lb->AddItemcxx . . $ newuiListBox#AddItem(85c52e162fed56f9).(wc_filelist[k]);
803 i++;
804 mem_freecxx . . $ `mem/mem.h:80:9`!(wc_filelist[k]);
805 wc_filelist[k] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
806 }
807 }
808 if (wc_filelist) {
809 mem_freecxx . . $ `mem/mem.h:80:9`!(wc_filelist);
810 wc_filelist = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
811 }
812 }
813 }
814 }
815
816 if (dirs)
817 mem_freecxx . . $ `mem/mem.h:80:9`!(dirs);
818 if (filelist)
819 mem_freecxx . . $ `mem/mem.h:80:9`!(filelist);
820 if (wc_count)
821 mem_freecxx . . $ `mem/mem.h:80:9`!(wc_count);
822 FDlg_EnableWaitMessagecxx . . $ FDlg_EnableWaitMessage(b45ddcbc8423892c).(false);
823 }