diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Configuration.cpp | 7 | ||||
-rw-r--r-- | src/FilePath.cpp | 247 | ||||
-rw-r--r-- | src/Parser.cpp | 8 | ||||
-rw-r--r-- | src/Serialiser.cpp | 10 | ||||
-rw-r--r-- | src/World.cpp | 3 | ||||
-rw-r--r-- | src/gui/ThreadedLoader.cpp | 4 | ||||
-rw-r--r-- | src/meson.build | 1 | ||||
-rw-r--r-- | src/runtime_paths.cpp | 5 | ||||
-rw-r--r-- | src/server/LV2Block.hpp | 6 | ||||
-rw-r--r-- | src/server/events/Copy.cpp | 1 | ||||
-rw-r--r-- | src/server/events/Delete.cpp | 1 | ||||
-rw-r--r-- | src/server/events/Delta.cpp | 1 |
12 files changed, 27 insertions, 267 deletions
diff --git a/src/Configuration.cpp b/src/Configuration.cpp index 5af9fea1..705594c9 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -17,7 +17,6 @@ #include "ingen/Configuration.hpp" #include "ingen/Forge.hpp" #include "ingen/URIMap.hpp" -#include "ingen/filesystem.hpp" #include "ingen/fmt.hpp" #include "ingen/ingen.h" #include "ingen/runtime_paths.hpp" @@ -33,7 +32,9 @@ #include <cstdint> #include <cstdlib> #include <cstring> +#include <filesystem> #include <memory> +#include <sstream> #include <thread> #include <utility> #include <vector> @@ -232,7 +233,7 @@ Configuration::parse(int argc, char** argv) bool Configuration::load(const FilePath& path) { - if (!filesystem::exists(path)) { + if (!std::filesystem::exists(path)) { return false; } @@ -280,7 +281,7 @@ Configuration::save(URIMap& uri_map, // Create parent directories if necessary const FilePath dir = path.parent_path(); - if (!filesystem::create_directories(dir)) { + if (!std::filesystem::create_directories(dir)) { throw FileError(fmt("Error creating directory %1% (%2%)", dir, strerror(errno))); } diff --git a/src/FilePath.cpp b/src/FilePath.cpp deleted file mode 100644 index 8cbd3a9e..00000000 --- a/src/FilePath.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/* - This file is part of Ingen. - Copyright 2018 David Robillard <http://drobilla.net/> - - Ingen is free software: you can redistribute it and/or modify it under the - terms of the GNU Affero General Public License as published by the Free - Software Foundation, either version 3 of the License, or any later version. - - Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU Affero General Public License for details. - - You should have received a copy of the GNU Affero General Public License - along with Ingen. If not, see <http://www.gnu.org/licenses/>. -*/ - -#include "ingen/FilePath.hpp" - -#include <algorithm> -#include <string> -#include <utility> - -namespace ingen { - -template <typename Char> -static bool -is_sep(const Char chr) -{ -#if USE_WINDOWS_FILE_PATHS - return chr == L'/' || chr == preferred_separator; -#else - return chr == '/'; -#endif -} - -FilePath& -FilePath::operator=(FilePath&& path) noexcept -{ - _str = std::move(path._str); - path.clear(); - return *this; -} - -FilePath& -FilePath::operator=(string_type&& str) -{ - _str = std::move(str); - return *this; -} - -FilePath& -FilePath::operator/=(const FilePath& path) -{ - const FilePath::string_type& str = path.string(); - if (!_str.empty() && !is_sep(_str.back()) && !str.empty() && - !is_sep(str.front())) { - _str += preferred_separator; - } - - _str += str; - return *this; -} - -FilePath& -FilePath::operator+=(const FilePath& path) -{ - return operator+=(path.native()); -} - -FilePath& -FilePath::operator+=(const string_type& str) -{ - _str += str; - return *this; -} - -FilePath& -FilePath::operator+=(const value_type* str) -{ - _str += str; - return *this; -} - -FilePath& -FilePath::operator+=(value_type chr) -{ - _str += chr; - return *this; -} - -FilePath& -FilePath::operator+=(boost::basic_string_view<value_type> sv) -{ - _str.append(sv.data(), sv.size()); - return *this; -} - -FilePath -FilePath::root_name() -{ -#if USE_WINDOWS_FILE_PATHS - if (_str.length() >= 2 && _str[0] >= 'A' && _str[0] <= 'Z' && - _str[1] == ':') { - return FilePath(_str.substr(0, 2)); - } -#endif - - return {}; -} - -FilePath -FilePath::root_directory() const -{ -#if USE_WINDOWS_FILE_PATHS - const auto name = root_name().string(); - return name.empty() ? Path() : Path(name + preferred_separator); -#endif - - return _str[0] == '/' ? FilePath("/") : FilePath(); -} - -FilePath -FilePath::root_path() const -{ -#if USE_WINDOWS_FILE_PATHS - const auto name = root_name(); - return name.empty() ? FilePath() : name / root_directory(); -#endif - return root_directory(); -} - -FilePath -FilePath::relative_path() const -{ - const auto root = root_path(); - return root.empty() ? FilePath() - : FilePath(_str.substr(root.string().length())); -} - -FilePath -FilePath::parent_path() const -{ - if (empty() || *this == root_path()) { - return *this; - } - - const auto first_sep = find_first_sep(); - const auto last_sep = find_last_sep(); - return ((last_sep == std::string::npos || last_sep == first_sep) - ? root_path() - : FilePath(_str.substr(0, last_sep))); -} - -FilePath -FilePath::filename() const -{ - return ((empty() || *this == root_path()) - ? FilePath() - : FilePath(_str.substr(find_last_sep() + 1))); -} - -FilePath -FilePath::stem() const -{ - const auto name = filename(); - const auto dot = name.string().find('.'); - return ((dot == std::string::npos) ? name - : FilePath(name.string().substr(0, dot))); -} - -FilePath -FilePath::extension() const -{ - const auto name = filename().string(); - const auto dot = name.find('.'); - return ((dot == std::string::npos) ? FilePath() - : FilePath(name.substr(dot, dot))); -} - -bool -FilePath::is_absolute() const -{ -#if USE_WINDOWS_FILE_PATHS - return !root_name().empty(); -#else - return !root_directory().empty(); -#endif -} - -std::size_t -FilePath::find_first_sep() const -{ - const auto i = std::find_if(_str.begin(), _str.end(), is_sep<value_type>); - return i == _str.end() ? std::string::npos : (i - _str.begin()); -} - -std::size_t -FilePath::find_last_sep() const -{ - const auto i = std::find_if(_str.rbegin(), _str.rend(), is_sep<value_type>); - return (i == _str.rend() ? std::string::npos - : (_str.length() - 1 - (i - _str.rbegin()))); -} - -bool -operator==(const FilePath& lhs, const FilePath& rhs) noexcept -{ - return lhs.string() == rhs.string(); -} - -bool -operator!=(const FilePath& lhs, const FilePath& rhs) noexcept -{ - return !(lhs == rhs); -} - -bool -operator<(const FilePath& lhs, const FilePath& rhs) noexcept -{ - return lhs.string().compare(rhs.string()) < 0; -} - -bool -operator<=(const FilePath& lhs, const FilePath& rhs) noexcept -{ - return !(rhs < lhs); -} - -bool -operator>(const FilePath& lhs, const FilePath& rhs) noexcept -{ - return rhs < lhs; -} - -bool -operator>=(const FilePath& lhs, const FilePath& rhs) noexcept -{ - return !(lhs < rhs); -} - -FilePath -operator/(const FilePath& lhs, const FilePath& rhs) -{ - return FilePath(lhs) /= rhs; -} - -} // namespace ingen diff --git a/src/Parser.cpp b/src/Parser.cpp index 7b25031c..a27dc2b3 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -27,7 +27,6 @@ #include "ingen/URIMap.hpp" #include "ingen/URIs.hpp" #include "ingen/World.hpp" -#include "ingen/filesystem.hpp" #include "ingen/paths.hpp" #include "lv2/atom/atom.h" #include "lv2/core/lv2.h" @@ -40,9 +39,12 @@ #include <cassert> #include <cstdint> #include <cstring> +#include <filesystem> #include <map> #include <set> +#include <sstream> #include <string> +#include <string_view> #include <utility> #define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#" @@ -591,11 +593,11 @@ Parser::parse_file(ingen::World& world, // Get absolute file path FilePath file_path = path; if (!file_path.is_absolute()) { - file_path = filesystem::current_path() / file_path; + file_path = std::filesystem::current_path() / file_path; } // Find file to use as manifest - const bool is_bundle = filesystem::is_directory(file_path); + const bool is_bundle = std::filesystem::is_directory(file_path); const FilePath manifest_path = (is_bundle ? file_path / "manifest.ttl" : file_path); diff --git a/src/Serialiser.cpp b/src/Serialiser.cpp index 21d8286f..7bfa4211 100644 --- a/src/Serialiser.cpp +++ b/src/Serialiser.cpp @@ -28,7 +28,6 @@ #include "ingen/URIMap.hpp" #include "ingen/URIs.hpp" #include "ingen/World.hpp" -#include "ingen/filesystem.hpp" #include "ingen/runtime_paths.hpp" #include "lv2/core/lv2.h" #include "lv2/state/state.h" @@ -44,11 +43,14 @@ #include <cassert> #include <cstdint> #include <cstring> +#include <filesystem> #include <map> #include <memory> #include <set> +#include <sstream> #include <stdexcept> #include <string> +#include <string_view> #include <utility> namespace ingen { @@ -190,12 +192,12 @@ Serialiser::Impl::write_bundle(const std::shared_ptr<const Node>& graph, const URI& uri) { FilePath path(uri.path()); - if (filesystem::exists(path) && !filesystem::is_directory(path)) { + if (std::filesystem::exists(path) && !std::filesystem::is_directory(path)) { path = path.parent_path(); } _world.log().info("Writing bundle %1%\n", path); - filesystem::create_directories(path); + std::filesystem::create_directories(path); const FilePath main_file = path / "main.ttl"; const raul::Path old_root_path = _root_path; @@ -454,7 +456,7 @@ Serialiser::Impl::serialise_block(const std::shared_ptr<const Node>& block, if (_base_uri.scheme() == "file") { const FilePath base_path = _base_uri.file_path(); const FilePath graph_dir = base_path.parent_path(); - const FilePath state_dir = graph_dir / block->symbol(); + const FilePath state_dir = graph_dir / std::string(block->symbol()); const FilePath state_file = state_dir / "state.ttl"; if (block->save_state(state_dir)) { _model->add_statement(block_id, diff --git a/src/World.cpp b/src/World.cpp index e2db1a57..c03641f5 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -20,7 +20,6 @@ #include "ingen/Configuration.hpp" #include "ingen/DataAccess.hpp" #include "ingen/EngineBase.hpp" -#include "ingen/FilePath.hpp" #include "ingen/Forge.hpp" #include "ingen/InstanceAccess.hpp" #include "ingen/LV2Features.hpp" @@ -40,9 +39,11 @@ #include "sord/sordmm.hpp" #include <cstdint> +#include <filesystem> #include <list> #include <map> #include <memory> +#include <sstream> #include <string> #include <utility> diff --git a/src/gui/ThreadedLoader.cpp b/src/gui/ThreadedLoader.cpp index 7c5fdd99..d3672bda 100644 --- a/src/gui/ThreadedLoader.cpp +++ b/src/gui/ThreadedLoader.cpp @@ -20,13 +20,11 @@ #include "ingen/Log.hpp" #include "ingen/Parser.hpp" -#include "ingen/Properties.hpp" #include "ingen/Serialiser.hpp" #include "ingen/URI.hpp" #include "ingen/World.hpp" #include "ingen/client/GraphModel.hpp" #include "raul/Path.hpp" -#include "raul/Symbol.hpp" #include <boost/optional/optional.hpp> #include <glibmm/ustring.h> @@ -35,8 +33,10 @@ #include <sigc++/functors/mem_fun.h> #include <cassert> +#include <filesystem> #include <memory> #include <string> +#include <string_view> #include <utility> using boost::optional; diff --git a/src/meson.build b/src/meson.build index 6c83ae95..833a9db2 100644 --- a/src/meson.build +++ b/src/meson.build @@ -7,7 +7,6 @@ sources = files( 'ClashAvoider.cpp', 'ColorContext.cpp', 'Configuration.cpp', - 'FilePath.cpp', 'Forge.cpp', 'LV2Features.cpp', 'Library.cpp', diff --git a/src/runtime_paths.cpp b/src/runtime_paths.cpp index 86315be8..b876ebd4 100644 --- a/src/runtime_paths.cpp +++ b/src/runtime_paths.cpp @@ -17,12 +17,11 @@ #include "ingen/runtime_paths.hpp" #include "ingen/FilePath.hpp" -#include "ingen/filesystem.hpp" #include "ingen_config.h" -#include <algorithm> #include <cstdlib> #include <dlfcn.h> +#include <filesystem> #include <sstream> #include <string> @@ -92,7 +91,7 @@ find_in_search_path(const std::string& name, { for (const auto& dir : search_path) { FilePath path = dir / name; - if (filesystem::exists(path)) { + if (std::filesystem::exists(path)) { return path; } } diff --git a/src/server/LV2Block.hpp b/src/server/LV2Block.hpp index 9e907ffa..fa3979cd 100644 --- a/src/server/LV2Block.hpp +++ b/src/server/LV2Block.hpp @@ -38,6 +38,7 @@ #include <cstdint> #include <cstdlib> #include <cstring> +#include <filesystem> #include <memory> #include <mutex> @@ -59,7 +60,6 @@ struct constant_time_size; namespace ingen { -class FilePath; class Resource; class URIs; class World; @@ -91,7 +91,7 @@ public: bool instantiate(BufferFactory& bufs, const LilvState* state); LilvInstance* instance() override { return instance(0); } - bool save_state(const FilePath& dir) const override; + bool save_state(const std::filesystem::path& dir) const override; BlockImpl* duplicate(Engine& engine, const raul::Symbol& symbol, @@ -121,7 +121,7 @@ public: const BufferRef& buf, SampleCount offset) override; - static StatePtr load_state(World& world, const FilePath& path); + static StatePtr load_state(World& world, const std::filesystem::path& path); protected: struct Instance : public raul::Noncopyable { diff --git a/src/server/events/Copy.cpp b/src/server/events/Copy.cpp index beb5224c..06a71fdc 100644 --- a/src/server/events/Copy.cpp +++ b/src/server/events/Copy.cpp @@ -40,6 +40,7 @@ #include <memory> #include <mutex> #include <string> +#include <string_view> #include <utility> namespace ingen { diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp index aba49adb..ec1af085 100644 --- a/src/server/events/Delete.cpp +++ b/src/server/events/Delete.cpp @@ -48,6 +48,7 @@ #include <memory> #include <mutex> #include <string> +#include <string_view> namespace ingen { namespace server { diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp index 71d4b48f..af3d5b59 100644 --- a/src/server/events/Delta.cpp +++ b/src/server/events/Delta.cpp @@ -53,6 +53,7 @@ #include <mutex> #include <set> #include <string> +#include <string_view> #include <utility> #include <vector> |