diff --git a/include/TessesFramework/Filesystem/VFS.hpp b/include/TessesFramework/Filesystem/VFS.hpp index 36eb76d..7daf82f 100644 --- a/include/TessesFramework/Filesystem/VFS.hpp +++ b/include/TessesFramework/Filesystem/VFS.hpp @@ -14,11 +14,22 @@ namespace Tesses::Framework::Filesystem VFSPath(std::string path); VFSPath(VFSPath p, std::string subent); VFSPath(VFSPath p, VFSPath p2); + + + VFSPath GetParent(); VFSPath CollapseRelativeParents(); std::string GetFileName(); std::string ToString(); }; + VFSPath operator/(VFSPath p, VFSPath p2); + VFSPath operator/(VFSPath p, std::string p2); + VFSPath operator/(std::string p, VFSPath p2); + VFSPath operator+(VFSPath p, VFSPath p2); + VFSPath operator+(VFSPath p, std::string p2); + VFSPath operator+(std::string p, VFSPath p2); + + class VFS { public: diff --git a/src/Filesystem/VFS.cpp b/src/Filesystem/VFS.cpp index 7ac5f10..d1a90f8 100644 --- a/src/Filesystem/VFS.cpp +++ b/src/Filesystem/VFS.cpp @@ -2,6 +2,53 @@ #include "TessesFramework/Http/HttpUtils.hpp" namespace Tesses::Framework::Filesystem { + VFSPath operator/(VFSPath p, VFSPath p2) + { + return VFSPath(p,p2); + } + VFSPath operator/(VFSPath p, std::string p2) + { + return VFSPath(p,p2); + } + VFSPath operator/(std::string p, VFSPath p2) + { + return VFSPath(p,p2); + } + VFSPath operator+(VFSPath p, VFSPath p2) + { + VFSPath pout; + pout.relative = p.relative; + if(p.path.size()>1) + { + pout.path.insert(pout.path.end(),p.path.begin(),p.path.end()-1); + } + std::string mid={}; + if(!p.path.empty()) + { + mid.append(p.path.back()); + } + + if(!p2.path.empty()) + { + mid.append(p2.path.front()); + } + pout.path.push_back(mid); + + if(p2.path.size()>1) + { + pout.path.insert(pout.path.end(),p2.path.begin()+1,p2.path.end()); + } + + return pout; + } + VFSPath operator+(VFSPath p, std::string p2) + { + return p + VFSPath(p2); + } + VFSPath operator+(std::string p, VFSPath p2) + { + return VFSPath(p) + p2; + } VFSPath VFS::ReadLink(VFSPath path) { return VFSPath("/");