summaryrefslogtreecommitdiffstats
path: root/include/ingen
diff options
context:
space:
mode:
Diffstat (limited to 'include/ingen')
-rw-r--r--include/ingen/FilePath.hpp108
-rw-r--r--include/ingen/Node.hpp8
-rw-r--r--include/ingen/URI.hpp6
-rw-r--r--include/ingen/filesystem.hpp84
4 files changed, 11 insertions, 195 deletions
diff --git a/include/ingen/FilePath.hpp b/include/ingen/FilePath.hpp
index 6f0266a7..ce157d90 100644
--- a/include/ingen/FilePath.hpp
+++ b/include/ingen/FilePath.hpp
@@ -1,6 +1,6 @@
/*
This file is part of Ingen.
- Copyright 2018 David Robillard <http://drobilla.net/>
+ Copyright 2018-2020 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
@@ -17,113 +17,11 @@
#ifndef INGEN_FILEPATH_HPP
#define INGEN_FILEPATH_HPP
-#include "ingen/ingen.h"
-
-#include <boost/utility/string_view.hpp> // IWYU pragma: export
-
-#include <cstddef>
-#include <ostream>
-#include <string>
-#include <utility>
-
-#ifndef USE_WINDOWS_FILE_PATHS
-# if defined(_WIN32) && !defined(__CYGWIN__)
-# define USE_WINDOWS_FILE_PATHS 1
-# else
-# define USE_WINDOWS_FILE_PATHS 0
-# endif
-#endif
+#include <filesystem>
namespace ingen {
-/** A path to a file.
- *
- * This is a minimal subset of the std::filesystem::path interface in C++17.
- * Support for Windows paths is only partial and there is no support for
- * character encoding conversion at all.
- */
-class INGEN_API FilePath
-{
-public:
-#if USE_WINDOWS_FILE_PATHS
- using value_type = wchar_t;
- static constexpr value_type preferred_separator = L'\\';
-#else
- using value_type = char;
- static constexpr value_type preferred_separator = '/';
-#endif
-
- using string_type = std::basic_string<value_type>;
-
- FilePath() = default;
- FilePath(const FilePath&) = default;
- FilePath(FilePath&&) = default;
-
- FilePath(string_type str) : _str(std::move(str)) {}
- FilePath(const value_type* str) : _str(str) {}
- FilePath(const boost::basic_string_view<value_type>& sv)
- : _str(sv.data(), sv.length())
- {}
-
- ~FilePath() = default;
-
- FilePath& operator=(const FilePath& path) = default;
- FilePath& operator=(FilePath&& path) noexcept;
- FilePath& operator=(string_type&& str);
-
- FilePath& operator/=(const FilePath& path);
-
- FilePath& operator+=(const FilePath& path);
- FilePath& operator+=(const string_type& str);
- FilePath& operator+=(const value_type* str);
- FilePath& operator+=(value_type chr);
- FilePath& operator+=(boost::basic_string_view<value_type> sv);
-
- void clear() noexcept { _str.clear(); }
-
- const string_type& native() const noexcept { return _str; }
- const string_type& string() const noexcept { return _str; }
- const value_type* c_str() const noexcept { return _str.c_str(); }
-
- operator string_type() const { return _str; }
-
- static FilePath root_name();
-
- FilePath root_directory() const;
- FilePath root_path() const;
- FilePath relative_path() const;
- FilePath parent_path() const;
- FilePath filename() const;
- FilePath stem() const;
- FilePath extension() const;
-
- bool empty() const noexcept { return _str.empty(); }
-
- bool is_absolute() const;
- bool is_relative() const { return !is_absolute(); }
-
-private:
- std::size_t find_first_sep() const;
- std::size_t find_last_sep() const;
-
- string_type _str;
-};
-
-INGEN_API bool operator==(const FilePath& lhs, const FilePath& rhs) noexcept;
-INGEN_API bool operator!=(const FilePath& lhs, const FilePath& rhs) noexcept;
-INGEN_API bool operator<(const FilePath& lhs, const FilePath& rhs) noexcept;
-INGEN_API bool operator<=(const FilePath& lhs, const FilePath& rhs) noexcept;
-INGEN_API bool operator>(const FilePath& lhs, const FilePath& rhs) noexcept;
-INGEN_API bool operator>=(const FilePath& lhs, const FilePath& rhs) noexcept;
-
-INGEN_API FilePath operator/(const FilePath& lhs, const FilePath& rhs);
-
-template <typename Char, typename Traits>
-std::basic_ostream<Char, Traits>&
-operator<<(std::basic_ostream<Char, Traits>& os, const FilePath& path)
-{
- return os << path.string();
-}
+using FilePath = std::filesystem::path;
} // namespace ingen
diff --git a/include/ingen/Node.hpp b/include/ingen/Node.hpp
index c8006a8e..3e07df2f 100644
--- a/include/ingen/Node.hpp
+++ b/include/ingen/Node.hpp
@@ -24,6 +24,7 @@
#include "lilv/lilv.h"
#include <cstdint>
+#include <filesystem>
#include <map>
#include <memory>
#include <string>
@@ -37,7 +38,6 @@ class Symbol;
namespace ingen {
class Arc;
-class FilePath;
class URIs;
/** A node in the audio graph.
@@ -75,7 +75,11 @@ public:
// Plugin blocks only
virtual LilvInstance* instance() { return nullptr; }
- virtual bool save_state(const FilePath& dir) const { return false; }
+
+ virtual bool save_state(const std::filesystem::path& dir) const
+ {
+ return false;
+ }
// All objects
virtual GraphType graph_type() const = 0;
diff --git a/include/ingen/URI.hpp b/include/ingen/URI.hpp
index 0c8d23ef..c344e7c2 100644
--- a/include/ingen/URI.hpp
+++ b/include/ingen/URI.hpp
@@ -22,20 +22,18 @@
#include "serd/serd.h"
#include "sord/sordmm.hpp"
-#include <boost/utility/string_view.hpp> // IWYU pragma: export
-#include <boost/utility/string_view_fwd.hpp> // IWYU pragma: export
-
#include <cstddef>
#include <cstdint>
#include <ostream>
#include <string>
+#include <string_view>
namespace ingen {
class INGEN_API URI
{
public:
- using Chunk = boost::string_view;
+ using Chunk = std::string_view;
URI();
explicit URI(const std::string& str);
diff --git a/include/ingen/filesystem.hpp b/include/ingen/filesystem.hpp
deleted file mode 100644
index 5a90e7b7..00000000
--- a/include/ingen/filesystem.hpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- This file is part of Ingen.
- Copyright 2007-2017 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/>.
-*/
-
-#ifndef INGEN_FILESYSTEM_HPP
-#define INGEN_FILESYSTEM_HPP
-
-#include "ingen/FilePath.hpp"
-
-#ifdef _WIN32
-# include <windows.h>
-# include <io.h>
-# define F_OK 0
-# define mkdir(path, flags) _mkdir(path)
-#else
-# include <unistd.h>
-#endif
-
-#include <sys/stat.h>
-
-#include <algorithm>
-#include <cerrno>
-#include <cstdlib>
-#include <memory>
-#include <vector>
-
-/* A minimal subset of the std::filesystem API from C++17. */
-
-namespace ingen {
-namespace filesystem {
-
-inline bool exists(const FilePath& path)
-{
- return !access(path.c_str(), F_OK);
-}
-
-inline bool is_directory(const FilePath& path)
-{
- struct stat info{};
- stat(path.c_str(), &info);
- return S_ISDIR(info.st_mode);
-}
-
-inline bool create_directories(const FilePath& path)
-{
- std::vector<FilePath> paths;
- for (FilePath p = path; p != path.root_directory(); p = p.parent_path()) {
- paths.emplace_back(p);
- }
-
- for (auto p = paths.rbegin(); p != paths.rend(); ++p) {
- if (mkdir(p->c_str(), 0755) && errno != EEXIST) {
- return false;
- }
- }
-
- return true;
-}
-
-inline FilePath current_path()
-{
- struct Freer { void operator()(char* const ptr) { free(ptr); } };
-
- std::unique_ptr<char, Freer> cpath(realpath(".", nullptr));
-
- return {cpath.get()};
-}
-
-} // namespace filesystem
-} // namespace ingen
-
-#endif // INGEN_FILESYSTEM_HPP