Skip to content

Commit 6fa9938

Browse files
committed
Fix another path bug
1 parent e4a9d6b commit 6fa9938

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

source/create_dialog_derived.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ void CreateProjectDialogD::OnCreate(wxCommandEvent& event){
8888
#elif defined _WIN32
8989
auto fullProj = std::filesystem::path("\"") / projPath / projName / "\"";
9090
auto fullTemplate = std::filesystem::path("\"") / executableTemplatesPath / (templatePrefix + "." + templateName + "\"");
91-
string command = "\"" + executablePath.string() + "\" -createproject " + fullProj.string() + " -cloneFromTemplate " + fullTemplate.string();
91+
string command = "\"" + executablePath.string() + "\" -createproject " + fullProj.string() + " -cloneFromTemplate \"" + fullTemplate.string();
9292
#elif defined __linux__
9393
string command = "\"" + executablePath + "\" -createproject \"" + projPath + dirsep + projName + "\" -cloneFromTemplate \"" + executableTemplatesPath + templatePrefix + "." + templateName + "\"";
9494
#endif
9595
//TODO: return this command to what summoned this dialog
96-
project p = {projName,e.name,"",projPath + dirsep + projName};
96+
project p = {projName,e.name,"",filesystem::path(projPath) / filesystem::path(projName)};
9797
this->callback(command,p);
9898

9999
//close and dispose self

source/globals.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,6 @@ struct project{
141141
std::filesystem::path path;
142142
};
143143

144-
/**
145-
Determines if a file exists at a path using stat()
146-
@param name the path to the file
147-
@return true if the file exists, false if it does not
148-
*/
149-
inline bool file_exists(const std::string& name){
150-
struct stat buffer;
151-
return (stat (name.c_str(), &buffer) == 0);
152-
}
153-
154-
155144
/**
156145
Launches a shell command as a separate, non-connected process. The output of this
157146
command is not captured (sent to the system's null device)

source/interface_derived.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,17 +373,18 @@ string MainFrameDerived::GetPathFromDialog(const string& message)
373373
@note Surround this function in a try/catch, because it throws if it cannot succeed.
374374
*/
375375
project MainFrameDerived::LoadProject(const string &path){
376+
std::filesystem::path p_as_fs(path);
376377
//error if the file does not exist
377-
if (!file_exists(path)){
378+
if (!filesystem::exists(p_as_fs)){
378379
throw runtime_error(path + " does not exist.");
379380
}
380381

381382
//the name is the final part of the path
382383
string name = path.substr(path.find_last_of(dirsep)+1);
383384

384385
//Load ProjectSettings/ProjectVersion.txt to get the editor version, if it exists
385-
string projSettings = string(path + dirsep + "ProjectSettings" + dirsep + "ProjectVersion.txt");
386-
if (!file_exists(projSettings)){
386+
std::filesystem::path projSettings = std::filesystem::path(path) / "ProjectSettings" / "ProjectVersion.txt";
387+
if (!filesystem::exists(projSettings)){
387388
throw runtime_error("No ProjectVersion.txt found at " + path + "\n\nEnsure the folder you selected is the root folder of a complete Unity project.");
388389
}
389390

0 commit comments

Comments
 (0)