From 1443ba89b2cee518cd1cb7585f15ab65b79ed964 Mon Sep 17 00:00:00 2001 From: eidheim Date: Fri, 31 Jul 2015 13:15:52 +0200 Subject: [PATCH] More appropriate function names in sourcefile.*. --- src/config.cc | 8 ++++---- src/directories.cc | 4 ++-- src/notebook.cc | 2 +- src/source.cc | 2 +- src/sourcefile.cc | 10 +++++----- src/sourcefile.h | 20 ++++++++++---------- src/window.cc | 2 +- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/config.cc b/src/config.cc index 6957af4..fd40399 100644 --- a/src/config.cc +++ b/src/config.cc @@ -20,9 +20,9 @@ void MainConfig::find_or_create_config_files() { for (auto &file : files) { auto path = boost::filesystem::path(Singleton::config_dir() + file); if (!boost::filesystem::is_regular_file(path)) { - if (file == "config.json") juci::filesystem::save(path, configjson); - if (file == "plugins.py") juci::filesystem::save(path, pluginspy); - if (file == "menu.xml") juci::filesystem::save(path, menuxml); + if (file == "config.json") juci::filesystem::write(path, configjson); + if (file == "plugins.py") juci::filesystem::write(path, pluginspy); + if (file == "menu.xml") juci::filesystem::write(path, menuxml); } } } @@ -76,7 +76,7 @@ void MainConfig::GenerateKeybindings() { std::cerr << "menu.xml not found" << std::endl; throw; } - menu.ui = juci::filesystem::open(path); + menu.ui = juci::filesystem::read(path); boost::property_tree::ptree keys_json = cfg.get_child("keybindings"); for (auto &i : keys_json) { auto key=i.second.get_value(); diff --git a/src/directories.cc b/src/directories.cc index 7c6505f..be6df8b 100644 --- a/src/directories.cc +++ b/src/directories.cc @@ -103,7 +103,7 @@ std::string Directories::get_cmakelists_variable(const boost::filesystem::path& boost::filesystem::directory_iterator end_itr; for (boost::filesystem::directory_iterator itr( dir_path );itr != end_itr;++itr ) { if (itr->path().filename().string() == "CMakeLists.txt") { - for (auto &line : juci::filesystem::lines(itr->path())) { + for (auto &line : juci::filesystem::read_lines(itr->path())) { if (line.find(command_name+"(", 0) != std::string::npos || line.find(command_name+" (", 0) != std::string::npos ) { size_t variable_start = line.find("{", 0); @@ -138,7 +138,7 @@ std::string Directories::get_cmakelists_variable(const boost::filesystem::path& } } } - for (auto &line : juci::filesystem::lines(itr->path())) { + for (auto &line : juci::filesystem::read_lines(itr->path())) { if (line.find("set(", 0) != std::string::npos || line.find("set (", 0) != std::string::npos) { if( line.find(project_name_var, 0) != std::string::npos) { diff --git a/src/notebook.cc b/src/notebook.cc index 32c07cf..5f04d2b 100644 --- a/src/notebook.cc +++ b/src/notebook.cc @@ -92,7 +92,7 @@ bool Notebook::save(int page) { return false; auto view=get_view(page); if (view->file_path != "" && view->get_buffer()->get_modified()) { - if(juci::filesystem::save(view->file_path, view->get_buffer())) { + if(juci::filesystem::write(view->file_path, view->get_buffer())) { view->get_buffer()->set_modified(false); Singleton::terminal()->print("File saved to: " +view->file_path+"\n"); return true; diff --git a/src/source.cc b/src/source.cc index ec037ba..c8f05da 100644 --- a/src/source.cc +++ b/src/source.cc @@ -43,7 +43,7 @@ file_path(file_path), project_path(project_path) { set_highlight_current_line(Singleton::Config::source()->highlight_current_line); get_source_buffer()->get_undo_manager()->begin_not_undoable_action(); - juci::filesystem::open(file_path, get_buffer()); + juci::filesystem::read(file_path, get_buffer()); get_source_buffer()->get_undo_manager()->end_not_undoable_action(); get_buffer()->place_cursor(get_buffer()->get_iter_at_offset(0)); diff --git a/src/sourcefile.cc b/src/sourcefile.cc index 6c4b784..7fedbd1 100644 --- a/src/sourcefile.cc +++ b/src/sourcefile.cc @@ -5,7 +5,7 @@ const size_t buffer_size=131072; //Only use on small files -std::string juci::filesystem::open(const std::string &path) { +std::string juci::filesystem::read(const std::string &path) { std::stringstream ss; std::ifstream input(path); if(input) { @@ -15,7 +15,7 @@ std::string juci::filesystem::open(const std::string &path) { return ss.str(); } -bool juci::filesystem::open(const std::string &path, Glib::RefPtr text_buffer) { +bool juci::filesystem::read(const std::string &path, Glib::RefPtr text_buffer) { std::ifstream input(path); if(input) { std::vector buffer(buffer_size); @@ -29,7 +29,7 @@ bool juci::filesystem::open(const std::string &path, Glib::RefPtr juci::filesystem::lines(const std::string &path) { +std::vector juci::filesystem::read_lines(const std::string &path) { std::vector res; std::ifstream input(path); if (input) { @@ -40,7 +40,7 @@ std::vector juci::filesystem::lines(const std::string &path) { } //Only use on small files -bool juci::filesystem::save(const std::string &path, const std::string &new_content) { +bool juci::filesystem::write(const std::string &path, const std::string &new_content) { std::ofstream output(path); if(output) output << new_content; @@ -50,7 +50,7 @@ bool juci::filesystem::save(const std::string &path, const std::string &new_cont return true; } -bool juci::filesystem::save(const std::string &path, Glib::RefPtr buffer) { +bool juci::filesystem::write(const std::string &path, Glib::RefPtr buffer) { std::ofstream output(path); if(output) { auto start_iter=buffer->begin(); diff --git a/src/sourcefile.h b/src/sourcefile.h index 4b9efb1..aabe617 100644 --- a/src/sourcefile.h +++ b/src/sourcefile.h @@ -8,18 +8,18 @@ namespace juci { class filesystem { public: - static std::string open(const std::string &path); - static std::string open(const boost::filesystem::path &path) { return open(path.string()); } - static bool open(const std::string &path, Glib::RefPtr text_buffer); + static std::string read(const std::string &path); + static std::string read(const boost::filesystem::path &path) { return read(path.string()); } + static bool read(const std::string &path, Glib::RefPtr text_buffer); - static std::vector lines(const std::string &path); - static std::vector lines(const boost::filesystem::path &path) { return lines(path.string()); }; + static std::vector read_lines(const std::string &path); + static std::vector read_lines(const boost::filesystem::path &path) { return read_lines(path.string()); }; - static bool save(const std::string &path, const std::string &new_content); - static bool save(const boost::filesystem::path &path, const std::string &new_content) { return save(path.string(), new_content); } - static bool save(const std::string &path) { return save(path, ""); }; - static bool save(const boost::filesystem::path &path) { return save(path, ""); }; - static bool save(const std::string &path, Glib::RefPtr text_buffer); + static bool write(const std::string &path, const std::string &new_content); + static bool write(const boost::filesystem::path &path, const std::string &new_content) { return write(path.string(), new_content); } + static bool write(const std::string &path) { return write(path, ""); }; + static bool write(const boost::filesystem::path &path) { return write(path, ""); }; + static bool write(const std::string &path, Glib::RefPtr text_buffer); }; } // namepace juci #endif // JUCI_SOURCEFILE_H_ diff --git a/src/window.cc b/src/window.cc index 259441f..7462788 100644 --- a/src/window.cc +++ b/src/window.cc @@ -279,7 +279,7 @@ void Window::new_file_entry() { Singleton::terminal()->print("Error: "+p.string()+" already exists.\n"); } else { - if(juci::filesystem::save(p)) { + if(juci::filesystem::write(p)) { notebook.open(boost::filesystem::canonical(p).string()); Singleton::terminal()->print("New file "+p.string()+" created.\n"); if(notebook.project_path!="")