move m_curDir to the parser class

Change-Id: Ib3cf15dfbb7af861a3c2fa8e746a0b0baaaa512e
diff --git a/src/CParser.cpp b/src/CParser.cpp
index c6a42a6..357970f 100644
--- a/src/CParser.cpp
+++ b/src/CParser.cpp
@@ -12,16 +12,27 @@
 
 InvalidCommandException::~InvalidCommandException() = default;
 
+struct nodeToString : public boost::static_visitor<std::string> {
+    std::string operator()(const nodeup_&) const
+    {
+        return "..";
+    }
+    template <class T>
+    std::string operator()(const T& node) const
+    {
+        return node.m_name;
+    }
+};
+
 CParser::CParser(const CTree& tree)
     : m_tree(tree)
 {
 }
 
-
 cd_ CParser::parseCommand(const std::string& line, std::ostream& errorStream)
 {
     cd_ parsedCommand;
-    ParserContext ctx(m_tree);
+    ParserContext ctx(m_tree, m_curDir);
     auto it = line.begin();
 
     boost::spirit::x3::error_handler<std::string::const_iterator> errorHandler(it, line.end(), errorStream);
@@ -38,3 +49,25 @@
 
     return parsedCommand;
 }
+
+void CParser::changeNode(const path_& name)
+{
+    if (name.m_nodes.empty()) {
+        m_curDir = "";
+        return;
+    }
+    for (const auto& it : name.m_nodes) {
+        const std::string node = boost::apply_visitor(nodeToString(), it);
+        if (node == "..") {
+            m_curDir = stripLastNodeFromPath(m_curDir);
+        } else {
+            m_curDir = joinPaths(m_curDir, boost::apply_visitor(nodeToString(), it));
+        }
+
+    }
+}
+std::string CParser::currentNode() const
+{
+    return m_curDir;
+}
+