]> git.tdb.fi Git - libs/core.git/commitdiff
Add Path::empty()
authorMikko Rasa <tdb@tdb.fi>
Sun, 27 Aug 2006 10:51:38 +0000 (10:51 +0000)
committerMikko Rasa <tdb@tdb.fi>
Sun, 27 Aug 2006 10:51:38 +0000 (10:51 +0000)
begin()==end() for an empty path

source/path.cpp
source/path.h

index 99961379977d65684da8f3209bc65d61570039e4..1a9460ac9c15f4496fd320adacf89d9aed36401a 100644 (file)
@@ -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
index f52362230ebf538468734aa4ddfd1e2cc32e0df9..9e1e3747fed37c0b6687ee48c0925071bbccd6ea 100644 (file)
@@ -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; }