File tree 3 files changed +51
-1254
lines changed
3 files changed +51
-1254
lines changed Original file line number Diff line number Diff line change 5
5
//
6
6
7
7
#include " interface_derived.hpp"
8
- #if defined _WIN32
9
- #include " dirent.h"
10
- #else
11
- #include < dirent.h>
12
- #endif
8
+ #include < filesystem>
13
9
#include < wx/msgdlg.h>
14
10
#include < fmt/format.h>
15
11
#include < wx/choicdlg.h>
@@ -173,27 +169,20 @@ void CreateProjectDialogD::loadTemplates(const editor& e){
173
169
174
170
// open the folder
175
171
auto templatesFolder = e.path /e.name / templatesDir;
176
- DIR* dir = opendir (templatesFolder.string ().c_str ());
177
- struct dirent *entry = readdir (dir);
178
- // loop over the contents
179
- while (entry != NULL )
180
- {
181
- // does the file start with the correct prefix?
182
- if (string (entry->d_name ).rfind (templatePrefix,0 )==0 ){
183
- // add it to the UI
184
- wxListItem i;
185
- i.SetId (0 );
186
- string label = entry->d_name ;
187
- i.SetText (label.substr (templatePrefix.length ()+1 ));
188
-
189
- templateCtrl->InsertItem (i);
190
- }
191
- // advance to next item in folder
192
- entry = readdir (dir);
193
- }
194
- // free resources
195
- closedir (dir);
196
- free (entry);
172
+
173
+ for (const auto & entry : std::filesystem::directory_iterator{templatesFolder}){
174
+ // does the file start with the correct prefix?
175
+ auto path = entry.path ();
176
+ if (path.filename ().string ().rfind (templatePrefix,0 )==0 ){
177
+ // add it to the UI
178
+ wxListItem i;
179
+ i.SetId (0 );
180
+ string label = path.filename ();
181
+ i.SetText (label.substr (templatePrefix.length ()+1 ));
182
+
183
+ templateCtrl->InsertItem (i);
184
+ }
185
+ }
197
186
}
198
187
199
188
void CreateProjectDialogD::OnChoiceChanged (wxCommandEvent& event){
You can’t perform that action at this time.
0 commit comments