diff options
| author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-04-20 22:37:23 +0100 | 
|---|---|---|
| committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-04-25 21:25:34 +0100 | 
| commit | 2a932ef6df79436d0c2280283a64f6d45d1d342a (patch) | |
| tree | 3be1a68f31d05c36d279f3de3b94b5695adc0960 | |
| parent | Make file event handlers non-static (diff) | |
| download | gentoobrowse-api-2a932ef6df79436d0c2280283a64f6d45d1d342a.tar.bz2 gentoobrowse-api-2a932ef6df79436d0c2280283a64f6d45d1d342a.tar.xz gentoobrowse-api-2a932ef6df79436d0c2280283a64f6d45d1d342a.zip | |
Add operator for extracting nth element of a path
| -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); | 
