diff options
-rw-r--r-- | gentoobrowse-api/service/fileUtils.cpp | 9 | ||||
-rw-r--r-- | gentoobrowse-api/service/fileUtils.h | 4 |
2 files changed, 13 insertions, 0 deletions
diff --git a/gentoobrowse-api/service/fileUtils.cpp b/gentoobrowse-api/service/fileUtils.cpp index cfa02bc..05f797f 100644 --- a/gentoobrowse-api/service/fileUtils.cpp +++ b/gentoobrowse-api/service/fileUtils.cpp @@ -5,6 +5,15 @@ namespace Gentoo { namespace Utils { + namespace File { + boost::filesystem::path operator/(const boost::filesystem::path & p, unsigned int n) + { + auto pp = p.begin(); + while (n--) ++pp; + return *pp; + } + } + FileHandle::FileHandle(const std::string & path) : fh(open(path.c_str(), O_RDONLY)) { diff --git a/gentoobrowse-api/service/fileUtils.h b/gentoobrowse-api/service/fileUtils.h index 58d235f..c9a2ec4 100644 --- a/gentoobrowse-api/service/fileUtils.h +++ b/gentoobrowse-api/service/fileUtils.h @@ -6,6 +6,10 @@ namespace Gentoo { namespace Utils { + namespace File { + boost::filesystem::path operator/(const boost::filesystem::path & p, unsigned int n); + } + class FileHandle { public: FileHandle(const std::string & path); |