Browse Source

Use correct operators for concatination of paths

merge-requests/365/head
Jørgen Lien Sellæg 10 years ago
parent
commit
e56f39aa0c
  1. 12
      src/cmake.cc
  2. 6
      src/dialogs.cc

12
src/cmake.cc

@ -17,9 +17,9 @@ CMake::CMake(const boost::filesystem::path &path) {
return false; return false;
}; };
auto search_path=boost::filesystem::path(path); auto search_path=path;
auto search_cmake_path=search_path; auto search_cmake_path=search_path;
search_cmake_path+="/CMakeLists.txt"; search_cmake_path/="CMakeLists.txt";
if(boost::filesystem::exists(search_cmake_path)) if(boost::filesystem::exists(search_cmake_path))
paths.emplace(paths.begin(), search_cmake_path); paths.emplace(paths.begin(), search_cmake_path);
if(find_cmake_project(search_cmake_path)) if(find_cmake_project(search_cmake_path))
@ -28,7 +28,7 @@ CMake::CMake(const boost::filesystem::path &path) {
do { do {
search_path=search_path.parent_path(); search_path=search_path.parent_path();
search_cmake_path=search_path; search_cmake_path=search_path;
search_cmake_path+="/CMakeLists.txt"; search_cmake_path/="CMakeLists.txt";
if(boost::filesystem::exists(search_cmake_path)) if(boost::filesystem::exists(search_cmake_path))
paths.emplace(paths.begin(), search_cmake_path); paths.emplace(paths.begin(), search_cmake_path);
if(find_cmake_project(search_cmake_path)) { if(find_cmake_project(search_cmake_path)) {
@ -37,8 +37,8 @@ CMake::CMake(const boost::filesystem::path &path) {
} }
} while(search_path!=search_path.root_directory()); } while(search_path!=search_path.root_directory());
} }
if(project_path!="") { if(!project_path.empty()) {
if(boost::filesystem::exists(project_path.string()+"/CMakeLists.txt") && !boost::filesystem::exists(project_path.string()+"/compile_commands.json")) if(boost::filesystem::exists(project_path/"CMakeLists.txt") && !boost::filesystem::exists(project_path/"compile_commands.json"))
create_compile_commands(project_path); create_compile_commands(project_path);
} }
} }
@ -48,7 +48,7 @@ bool CMake::create_compile_commands(const boost::filesystem::path &path) {
if(Singleton::terminal()->execute(Singleton::Config::terminal()->cmake_command+" . -DCMAKE_EXPORT_COMPILE_COMMANDS=ON", path)==EXIT_SUCCESS) { if(Singleton::terminal()->execute(Singleton::Config::terminal()->cmake_command+" . -DCMAKE_EXPORT_COMPILE_COMMANDS=ON", path)==EXIT_SUCCESS) {
#ifdef _WIN32 //Temporary fix to MSYS2's libclang #ifdef _WIN32 //Temporary fix to MSYS2's libclang
auto compile_commands_path=path; auto compile_commands_path=path;
compile_commands_path+="/compile_commands.json"; compile_commands_path/="compile_commands.json";
auto compile_commands_file=filesystem::read(compile_commands_path); auto compile_commands_file=filesystem::read(compile_commands_path);
size_t pos=0; size_t pos=0;
while((pos=compile_commands_file.find("-I/", pos))!=std::string::npos) { while((pos=compile_commands_file.find("-I/", pos))!=std::string::npos) {

6
src/dialogs.cc

@ -8,10 +8,10 @@ std::string open_dialog(const std::string &title,
Gtk::FileChooserAction gtk_options, Gtk::FileChooserAction gtk_options,
const std::string &file_name = "") { const std::string &file_name = "") {
Gtk::FileChooserDialog dialog(title, gtk_options); Gtk::FileChooserDialog dialog(title, gtk_options);
if(Singleton::directories()->current_path!="") if(!Singleton::directories()->current_path.empty())
gtk_file_chooser_set_current_folder((GtkFileChooser*)dialog.gobj(), Singleton::directories()->current_path.string().c_str()); gtk_file_chooser_set_current_folder((GtkFileChooser*)dialog.gobj(), Singleton::directories()->current_path.c_str());
else else
gtk_file_chooser_set_current_folder((GtkFileChooser*)dialog.gobj(), boost::filesystem::current_path().string().c_str()); gtk_file_chooser_set_current_folder((GtkFileChooser*)dialog.gobj(), boost::filesystem::current_path().c_str());
if (!file_name.empty()) if (!file_name.empty())
gtk_file_chooser_set_filename((GtkFileChooser*)dialog.gobj(), file_name.c_str()); gtk_file_chooser_set_filename((GtkFileChooser*)dialog.gobj(), file_name.c_str());
dialog.set_position(Gtk::WindowPosition::WIN_POS_CENTER_ALWAYS); dialog.set_position(Gtk::WindowPosition::WIN_POS_CENTER_ALWAYS);

Loading…
Cancel
Save