1717#endif
1818
1919#include < fmt/format.h>
20+ #include < filesystem>
2021using namespace std ;
22+ using namespace std ::filesystem;
2123
2224#define LEARN_TAB 2
2325#define WEBVIEW 2000
@@ -73,7 +75,7 @@ MainFrameDerived::MainFrameDerived() : MainFrame(NULL){
7375 int status = mkdir (datapath.c_str (),S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
7476 menuReveal->SetItemLabel (" Reveal In Finder\t Ctrl-F" );
7577 #elif defined _WIN32
76- int status = mkdir (datapath.c_str ());
78+ int status = mkdir (datapath.string (). c_str ());
7779 // on windows also make the main window background white
7880 this ->SetBackgroundColour (*wxWHITE);
7981 // high DPI scaling fixes
@@ -106,8 +108,8 @@ void MainFrameDerived::ReloadData(){
106108 editors.clear ();
107109
108110 // check that projects file exists in folder
109- string p = string ( datapath + dirsep + projectsFile) ;
110- if (file_exists (p)){
111+ path p = datapath / projectsFile;
112+ if (filesystem::exists (p)){
111113 ifstream in;
112114 in.open (p);
113115 string line;
@@ -140,8 +142,8 @@ void MainFrameDerived::ReloadData(){
140142 }
141143
142144 // check that the installs path file exists in the folder
143- p = string ( datapath + dirsep + editorPathsFile) ;
144- if (file_exists (p)){
145+ p = datapath / editorPathsFile;
146+ if (filesystem::exists (p)){
145147 // load the editors
146148 ifstream in; in.open (p); string line;
147149 while (getline (in, line)){
@@ -232,14 +234,14 @@ void MainFrameDerived::OnPageChanging(wxBookCtrlEvent& event){
232234 Loads an editor search path into the app, updating the UI and the vector
233235 @param path the string path to laod
234236 */
235- void MainFrameDerived::LoadEditorPath (const string & path){
237+ void MainFrameDerived::LoadEditorPath (const std::filesystem::path & path){
236238 // add to internal structure and to file
237239 installPaths.push_back (path);
238240 SaveEditorVersions ();
239241
240242 // add to the UI
241243 wxArrayString a;
242- a.Add (path);
244+ a.Add (path. string () );
243245
244246 installsPathsList->Append (a);
245247}
@@ -289,7 +291,7 @@ void MainFrameDerived::OnRevealProject(wxCommandEvent& event){
289291 long selectedIndex = wxListCtrl_get_selected (projectsList);
290292 if (selectedIndex > -1 ){
291293 project& p = projects[selectedIndex];
292- reveal_in_explorer (p.path );
294+ reveal_in_explorer (p.path . string () );
293295 }
294296}
295297
@@ -318,13 +320,13 @@ void MainFrameDerived::OpenProject(const long& index){
318320 // get the project
319321 project p = projects[index];
320322
321- for (string path : installPaths){
322- string editorPath = path + dirsep + p.version + dirsep + executable;
323+ for (auto & path : installPaths){
324+ auto editorPath = path / p.version / executable;
323325
324326 // check that the unity editor exists at that location
325- if (file_exists (editorPath)){
327+ if (filesystem::exists (editorPath)){
326328
327- string cmd = " \" " + editorPath + " \" -projectpath \" " + p.path + " \" " ;
329+ string cmd = " \" " + editorPath. string () + " \" -projectpath \" " + p.path . string () + " \" " ;
328330
329331 // start the process
330332 launch_process (cmd);
@@ -343,7 +345,7 @@ void MainFrameDerived::OpenProject(const long& index){
343345 @param e the editor version to use when opening the project
344346 */
345347void MainFrameDerived::OpenProject (const project& p, const editor& e){
346- string cmd = " \" " + e.path + dirsep + e.name + dirsep + executable + " \" -projectpath \" " + p.path + " \" " ;
348+ string cmd = " \" " + ( e.path / e.name / executable). string () + " \" -projectpath \" " + p.path . string () + " \" " ;
347349 launch_process (cmd);
348350}
349351
@@ -408,18 +410,18 @@ project MainFrameDerived::LoadProject(const string &path){
408410 */
409411void MainFrameDerived::SaveProjects (){
410412 ofstream file;
411- file.open (datapath + dirsep + projectsFile);
413+ file.open (datapath / projectsFile);
412414 for (project& p : projects){
413- file << p.path << endl;
415+ file << p.path . string () << endl;
414416 }
415417 file.close ();
416418}
417419
418420void MainFrameDerived::SaveEditorVersions (){
419421 ofstream file;
420- file.open (datapath + dirsep + editorPathsFile);
421- for (string & p : installPaths){
422- file << p << endl;
422+ file.open (datapath / editorPathsFile);
423+ for (auto & p : installPaths){
424+ file << p. string () << endl;
423425 }
424426 file.close ();
425427 LoadEditorVersions ();
@@ -454,7 +456,7 @@ void MainFrameDerived::AddProject(const project& p){
454456 projectsList->SetItem (i);
455457
456458 i.SetColumn (3 );
457- i.SetText (p.path );
459+ i.SetText (p.path . string () );
458460 projectsList->SetItem (i);
459461
460462 // resize columns
@@ -473,9 +475,9 @@ void MainFrameDerived::LoadEditorVersions(){
473475 editors.clear ();
474476
475477 // iterate over the search paths
476- for (string & path : installPaths){
478+ for (auto & path : installPaths){
477479 // open the folder
478- DIR* dir = opendir (path.c_str ());
480+ DIR* dir = opendir (path.string (). c_str ());
479481 if (dir != nullptr ){
480482 struct dirent *entry = readdir (dir);
481483 // loop over the contents
@@ -485,10 +487,10 @@ void MainFrameDerived::LoadEditorVersions(){
485487 // is this a folder?
486488 if (entry->d_type == DT_DIR){
487489 // does this folder have a valid executable inside?
488- string p = string ( path + dirsep + entry->d_name + dirsep + executable) ;
489- if (file_exists (p)){
490+ auto p = path / entry->d_name / executable;
491+ if (filesystem::exists (p)){
490492 // add it to the list
491- a.Add (string (entry->d_name ) + " - " + path);
493+ a.Add (string (entry->d_name ) + " - " + path. string () );
492494
493495 // add it to the backing datastructure
494496 editor e = {entry->d_name , path};
0 commit comments