From 20106be949263a06261b6a4cbda02da1f353247a Mon Sep 17 00:00:00 2001 From: eidheim Date: Sun, 16 Aug 2015 13:10:12 +0200 Subject: [PATCH] Spaces in paths should now work. --- src/terminal.cc | 4 ++-- src/window.cc | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/terminal.cc b/src/terminal.cc index bb0663c..d47b9be 100644 --- a/src/terminal.cc +++ b/src/terminal.cc @@ -140,7 +140,7 @@ int Terminal::execute(const std::string &command, const boost::filesystem::path std::string cd_path_and_command; if(path!="") { //TODO: Windows... - cd_path_and_command="cd "+path.string()+" && "+command; + cd_path_and_command="cd \""+path.string()+"\" && "+command; } else cd_path_and_command=command; @@ -193,7 +193,7 @@ void Terminal::async_execute(const std::string &command, const boost::filesystem if(path!="") { //TODO: Windows... - cd_path_and_command="cd "+path.string()+" && "+command; + cd_path_and_command="cd \""+path.string()+"\" && "+command; } else cd_path_and_command=command; diff --git a/src/window.cc b/src/window.cc index 2985a12..11e4722 100644 --- a/src/window.cc +++ b/src/window.cc @@ -235,7 +235,16 @@ void Window::create_menu() { if(exit_code==EXIT_SUCCESS) { compile_success(); //TODO: Windows... - Singleton::terminal()->async_execute(executable_path.string(), project_path, [this, executable_path](int exit_code){ + auto executable_path_spaces_fixed=executable_path.string(); + char last_char=0; + for(size_t c=0;casync_execute(executable_path_spaces_fixed, project_path, [this, executable_path](int exit_code){ Singleton::terminal()->async_print(executable_path.string()+" returned: "+boost::lexical_cast(exit_code)+'\n'); }); } @@ -389,10 +398,13 @@ void Window::new_cpp_project_dialog() { dialog.add_button("Select", Gtk::RESPONSE_OK); int result = dialog.run(); - if(result==Gtk::RESPONSE_OK) { boost::filesystem::path project_path=dialog.get_filename(); auto project_name=project_path.filename().string(); + for(size_t c=0;cprint("Error: "+cpp_main_path.string()+" already exists.\n"); return; } - std::string cmakelists="cmake_minimum_required(VERSION 2.8)\n\nproject("+project_name+")\n\nset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -std=c++1y\")\n\nadd_executable("+project_name+" main.cpp)\n"; + std::string cmakelists="cmake_minimum_required(VERSION 2.8)\n\nproject("+project_name+")\n\nset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -std=c++1y -Wall\")\n\nadd_executable("+project_name+" main.cpp)\n"; std::string cpp_main="#include \n\nusing namespace std;\n\nint main() {\n cout << \"Hello World!\" << endl;\n\n return 0;\n}\n"; if(juci::filesystem::write(cmakelists_path, cmakelists) && juci::filesystem::write(cpp_main_path, cpp_main)) { directories.open_folder(project_path);