From 4cc2d6ced17e8cbe1ae3251069131d22a292b857 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 27 Aug 2006 10:51:38 +0000 Subject: [PATCH 1/1] Add Path::empty() begin()==end() for an empty path --- source/path.cpp | 6 ++++-- source/path.h | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/source/path.cpp b/source/path.cpp index 9996137..1a9460a 100644 --- a/source/path.cpp +++ b/source/path.cpp @@ -141,10 +141,12 @@ Path::iterator::iterator(const Path &p): path(p), start(0) { - if(path.path[0]==DIRCHAR) + if(path.path.empty()) + start=end=string::npos; + else if(path.path[0]==DIRCHAR) end=1; #ifdef WIN32 - else if(path.path[2]==DIRCHAR && is_windows_drive(path.path.substr(0,2))) + else if(path.path.size()>2 && path.path[2]==DIRCHAR && is_windows_drive(path.path.substr(0,2))) end=2; #endif else diff --git a/source/path.h b/source/path.h index f523622..9e1e374 100644 --- a/source/path.h +++ b/source/path.h @@ -45,7 +45,8 @@ public: Path(const std::string &p) { init(p); } Path(const char *p) { init(p); } const std::string &str() const { return path; } - unsigned size() const; + unsigned size() const; + bool empty() const { return path.empty(); } bool is_absolute() const; Path subpath(unsigned, unsigned =(unsigned)-1) const; Path operator/(const Path &p) const { Path a=*this; a/=p; return a; } -- 2.43.0