1111#include < filesystem>
1212
1313// data file names
14- static const std::string projectsFile = " projects.txt" ;
15- static const std::string editorPathsFile = " editorPaths.txt" ;
16- static const std::string templatePrefix = " com.unity.template" ;
17- static const std::string AppVersion = " v1.5 " ;
14+ static constexpr std::string_view projectsFile = " projects.txt" ;
15+ static constexpr std::string_view editorPathsFile = " editorPaths.txt" ;
16+ static constexpr std::string_view templatePrefix = " com.unity.template" ;
17+ static constexpr std::string_view AppVersion = " v1.51 " ;
1818
1919#if defined __APPLE__
2020 #include < pwd.h>
2121 // the location to store application data
2222 static const std::filesystem::path datapath = std::filesystem::path(getpwuid(getuid())->pw_dir) / " Library/Application Support/UnityHubNative" ;
23- static const char dirsep = ' /' ;
2423
2524 static const std::filesystem::path cachedir = std::filesystem::path(getpwuid(getuid())->pw_dir) / " /Library/Caches/com.ravbug.UnityHubNative/" ;
26- static const std::string installerExt = " dmg" ;
25+ static constexpr std::string_view installerExt = " dmg" ;
2726
2827 // where to find various Unity things on macOS
2928 static const std::filesystem::path executable = " Unity.app/Contents/MacOS/Unity" ;
@@ -33,7 +32,7 @@ static const std::string AppVersion = "v1.5";
3332 static const std::filesystem::path templatesDir = " Unity.app/Contents/Resources/PackageManager/ProjectTemplates/" ;
3433
3534 // for stream redirecting to dev/null
36- static const std::string null_device = " >/dev/null 2>&1" ;
35+ static constexpr std::string_view null_device = " >/dev/null 2>&1" ;
3736
3837#elif defined _WIN32
3938// naming conflicts
@@ -46,7 +45,6 @@ static const std::string AppVersion = "v1.5";
4645 static const std::filesystem::path homedir = homedrive / homepath;
4746
4847 static const std::filesystem::path datapath = homedir / std::filesystem::path(" AppData\\ Roaming\\ UnityHubNative" );
49- static const char dirsep = ' \\ ' ;
5048
5149 static const std::filesystem::path cachedir = std::filesystem::temp_directory_path();
5250 static const std::string installerExt = " exe" ;
@@ -117,7 +115,6 @@ static const std::string AppVersion = "v1.5";
117115 #include < pwd.h>
118116 static const std::filesystem::path datapath = std::filesystem::path(getpwuid(getuid())->pw_dir) / " UnityHubNative" ;
119117 static const std::string null_device = " >/dev/null 2>&1" ;
120- static const char dirsep = ' /' ;
121118
122119 static const std::filesystem::path executable = " Editor/Unity" ;
123120 static const std::vector<std::filesystem::path> defaultInstall = {std::filesystem::path (getpwuid (getuid ())->pw_dir ) / " Unity/Hub/Editor" };
@@ -136,6 +133,9 @@ struct project{
136133 std::string version;
137134 std::string modifiedDate;
138135 std::filesystem::path path;
136+ bool operator ==(const project& other) const {
137+ return this ->path == other.path ;
138+ }
139139};
140140
141141/* *
@@ -144,18 +144,7 @@ struct project{
144144 @param command the shell command to run on the system
145145 @note The command passed to this function must be correct for the system it is running on. If it is not correct, the function will appear to do nothing.
146146 */
147- inline void launch_process (const std::string& command, int flags = 0 ) {
148- #if defined __APPLE__ || defined __linux__
149- // the '&' runs the command nonblocking, and >/dev/null 2>&1 destroys output
150- FILE* stream = popen (std::string (command + null_device + " &" ).c_str (), " r" );
151- pclose (stream);
152-
153- #elif _WIN32
154- // call wxExecute with the Async flag
155- wxExecute (wxString (command),flags);
156-
157- #endif
158- }
147+ void launch_process (const std::string& command, int flags = 0 );
159148
160149inline void reveal_in_explorer (const std::string& path){
161150#if defined __APPLE__
@@ -205,4 +194,8 @@ struct editor {
205194 decltype (path) executablePath() const {
206195 return path / name / executable;
207196 }
197+
198+ bool operator ==(const editor& other){
199+ return this ->name == other.name ; // many editors can share a root path
200+ }
208201};
0 commit comments