Path::Iterator::Iterator(const Path &p):
- path(p),
+ path(&p),
start(0)
{
- if(path.path.empty())
+ if(path->path.empty())
start = end = string::npos;
- else if(path.path[0]==DIRSEP)
+ else if(path->path[0]==DIRSEP)
end = 1;
#ifdef WIN32
- else if(path.path.size()>2 && path.path[2]==DIRSEP && is_windows_drive(path.path.substr(0, 2)))
+ else if(path->path.size()>2 && path->path[2]==DIRSEP && is_windows_drive(path->path.substr(0, 2)))
end = 2;
#endif
else
- end = path.path.find(DIRSEP);
+ end = path->path.find(DIRSEP);
}
Path::Iterator &Path::Iterator::operator++()
{
start = end;
- if(start>=path.path.size())
+ if(start>=path->path.size())
return *this;
- if(path.path[start]==DIRSEP)
+ if(path->path[start]==DIRSEP)
++start;
- end = path.path.find(DIRSEP, start);
+ end = path->path.find(DIRSEP, start);
return *this;
}
return *this;
end = start;
- if(end>1 && end<path.path.size() && path.path[end]!=DIRSEP)
+ if(end>1 && end<path->path.size() && path->path[end]!=DIRSEP)
--end;
- start = path.path.rfind(DIRSEP, end-1);
+ start = path->path.rfind(DIRSEP, end-1);
if(start==string::npos)
start = 0;
else if(start<end-1)
string Path::Iterator::operator*() const
{
- if(start>=path.path.size())
+ if(start>=path->path.size())
return string();
if(start==end)
return string();
- return path.path.substr(start, end-start);
+ return path->path.substr(start, end-start);
}
} // namespace FS