commit cdb15758dbd4cfeb30e9568b8bbc1ad8471e2fa2
parent 7166d5124f93a16ad7109c39f6d61f9983114ed1
Author: deurzen <m.vandeurzen@student.ru.nl>
Date:   Fri,  5 Apr 2019 09:35:55 +0200
moves from boost to std
Diffstat:
5 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/Makefile b/Makefile
@@ -2,7 +2,7 @@ PROJECT = bulkrename
 
 CC = g++
 CXXFLAGS ?= -std=c++17
-CXXFLAGS += -lboost_system -lboost_filesystem
+LDFLAGS  += -lstdc++fs
 
 OBJDIR = obj
 SRCDIR = src
@@ -33,7 +33,7 @@ notify-link:
 	@echo linking
 
 build: notify-build bin obj ${OBJ_FILES} notify-link
-	${CC} ${CXXFLAGS} ${OBJ_FILES} -o ${TARGET}
+	${CC} ${CXXFLAGS} ${OBJ_FILES} ${LDFLAGS} -o ${TARGET}
 
 -include $(DEPS)
 
diff --git a/src/bulkrename.hh b/src/bulkrename.hh
@@ -5,7 +5,7 @@
 #include "file.hh"
 
 #include <filesystem>
-#include <boost/filesystem.hpp>
+#include <filesystem>
 #include <memory>
 
 
@@ -22,7 +22,7 @@ public:
     static ::std::unique_ptr<bulkrename_t> init(const ::std::string&);
 
 private:
-    ::boost::filesystem::directory_iterator dir_it;
+    ::std::filesystem::directory_iterator dir_it;
     nodetree_t tree;
     filehandler_t filehandler;
 
diff --git a/src/file.cc b/src/file.cc
@@ -30,10 +30,10 @@ filehandler_t::read_in(const nodetree_t& tree)
         ::std::getline(in, name);
 
         if (!in)
-            throw ::std::runtime_error("amount of names does not match amount of files");
+            throw ::std::runtime_error("amount of names must match amount of files");
 
         if (name.empty())
-            throw ::std::runtime_error("file name must be non-empty");
+            throw ::std::runtime_error("file names must be non-empty");
 
         auto dirname  = file->get_path().parent_path().string();
         auto filename = file->get_path().filename().string();
@@ -54,7 +54,7 @@ filehandler_t::read_in(const nodetree_t& tree)
     in.close();
 
     if (conflict_found)
-        throw ::std::runtime_error("multiple files within a directory are given the same name");
+        throw ::std::runtime_error("files within the same directory must have different names");
 }
 
 void
diff --git a/src/node.cc b/src/node.cc
@@ -1,14 +1,14 @@
 #include "node.hh"
 
 void
-dir_t::populate(::boost::filesystem::directory_iterator dir_it)
+dir_t::populate(::std::filesystem::directory_iterator dir_it)
 {
     for (auto& entry : dir_it) {
-        if (::boost::filesystem::is_directory(entry)) {
+        if (::std::filesystem::is_directory(entry)) {
             dir_ptr_t dir = new dir_t(entry.path(), parent);
             children.push_back(dir);
-            dir->populate(::boost::filesystem::directory_iterator(entry));
-        } else if (::boost::filesystem::is_regular_file(entry)) {
+            dir->populate(::std::filesystem::directory_iterator(entry));
+        } else if (::std::filesystem::is_regular_file(entry)) {
             file_ptr_t file = new file_t(entry.path(), parent);
             children.push_back(file);
         }
@@ -17,7 +17,7 @@ dir_t::populate(::boost::filesystem::directory_iterator dir_it)
 
 
 void
-nodetree_t::populate(::boost::filesystem::directory_iterator dir_it)
+nodetree_t::populate(::std::filesystem::directory_iterator dir_it)
 {
     root->populate(dir_it);
 }
@@ -59,7 +59,7 @@ void
 file_t::rename() const
 {
     if (name != new_name)
-        ::boost::filesystem::rename(path, path.parent_path().string() + "/" + new_name);
+        ::std::filesystem::rename(path, path.parent_path().string() + "/" + new_name);
 }
 
 ::std::vector<file_ptr_t>
diff --git a/src/node.hh b/src/node.hh
@@ -1,7 +1,7 @@
 #ifndef __BULKRENAME_NODE_GUARD__
 #define __BULKRENAME_NODE_GUARD__
 
-#include <boost/filesystem.hpp>
+#include <filesystem>
 #include <fstream>
 #include <iostream>
 
@@ -19,7 +19,7 @@ typedef class node_t
 {
 public:
     /* node_t(nodetype_t _type, node_ptr_t _parent, const ::std::string& _name) */
-    node_t(nodetype_t _type, node_ptr_t _parent, const ::boost::filesystem::path& _path)
+    node_t(nodetype_t _type, node_ptr_t _parent, const ::std::filesystem::path& _path)
         : type(_type), parent(_parent), path(_path)
     {}
 
@@ -27,12 +27,12 @@ public:
     virtual void print(::std::ostream& out) const = 0;
 
     const nodetype_t get_type() const { return type; }
-    const ::boost::filesystem::path get_path() const { return path; }
+    const ::std::filesystem::path get_path() const { return path; }
 
 protected:
     nodetype_t type;
     node_ptr_t parent;
-    ::boost::filesystem::path path;
+    ::std::filesystem::path path;
     ::std::string name;
 
 }* node_ptr_t;
@@ -43,7 +43,7 @@ protected:
 typedef class file_t : public node_t
 {
 public:
-    explicit file_t(const ::boost::filesystem::path& path, node_ptr_t parent)
+    explicit file_t(const ::std::filesystem::path& path, node_ptr_t parent)
         : node_t(nodetype_t::file, parent, path), new_name(path.string())
     {}
 
@@ -65,11 +65,11 @@ private:
 typedef class dir_t : public node_t
 {
 public:
-    explicit dir_t(const ::boost::filesystem::path& path, node_ptr_t parent)
+    explicit dir_t(const ::std::filesystem::path& path, node_ptr_t parent)
         : node_t(nodetype_t::dir, parent, path)
     {}
 
-    void populate(::boost::filesystem::directory_iterator);
+    void populate(::std::filesystem::directory_iterator);
     bool has_next() const override { return !children.empty(); }
     void print(::std::ostream& out) const override;
 
@@ -93,7 +93,7 @@ public:
     nodetree_t& operator=(const nodetree_t&) = delete;
     nodetree_t(const nodetree_t&) = delete;
 
-    void populate(::boost::filesystem::directory_iterator);
+    void populate(::std::filesystem::directory_iterator);
     void print(::std::ostream& out) const;
 
     ::std::vector<file_ptr_t> get_files() const;