summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2016-04-20 22:37:23 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2016-04-25 21:25:34 +0100
commit5d0c5d07f7c20aba902d6cd39a393e0ef7777e60 (patch)
tree3be1a68f31d05c36d279f3de3b94b5695adc0960
parentMake file event handlers non-static (diff)
downloadgentoobrowse-api-5d0c5d07f7c20aba902d6cd39a393e0ef7777e60.tar.bz2
gentoobrowse-api-5d0c5d07f7c20aba902d6cd39a393e0ef7777e60.tar.xz
gentoobrowse-api-5d0c5d07f7c20aba902d6cd39a393e0ef7777e60.zip
Add operator for extracting nth element of a path
-rw-r--r--gentoobrowse-api/service/fileUtils.cpp9
-rw-r--r--gentoobrowse-api/service/fileUtils.h4
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);