extern const char sys::PathSeparator = ':';
+Path::Path(const std::string& p)
+ : path(p) {}
+
+Path::Path(const char *StrStart, unsigned StrLen)
+ : path(StrStart, StrLen) {}
+
bool
Path::isValid() const {
// Check some obvious things
return path.substr(slash, dot - slash);
}
+std::string
+Path::getSuffix() const {
+ // Find the last slash
+ std::string::size_type slash = path.rfind('/');
+ if (slash == std::string::npos)
+ slash = 0;
+ else
+ slash++;
+
+ std::string::size_type dot = path.rfind('.');
+ if (dot == std::string::npos || dot < slash)
+ return std::string();
+ else
+ return path.substr(dot + 1);
+}
+
bool Path::getMagicNumber(std::string& Magic, unsigned len) const {
assert(len < 1024 && "Request for magic string too long");
char* buf = (char*) alloca(1 + len);
path.copy(pathname,MAXPATHLEN);
// Null-terminate the last component
- int lastchar = path.length() - 1 ;
+ size_t lastchar = path.length() - 1 ;
if (pathname[lastchar] != '/')
++lastchar;
// Otherwise, try to just remove the one directory.
char pathname[MAXPATHLEN];
path.copy(pathname, MAXPATHLEN);
- int lastchar = path.length() - 1 ;
+ size_t lastchar = path.length() - 1;
if (pathname[lastchar] == '/')
pathname[lastchar] = 0;
else