fix();
}
+// create a path based on "path" and a "subpath"
+SGPath::SGPath( const SGPath& p, const std::string& r )
+ : path(p.path),
+ _cached(false)
+{
+ append(r);
+ fix();
+}
+
SGPath::SGPath(const SGPath& p) :
path(p.path),
_cached(p._cached),
_exists = false;
} else {
_exists = true;
- _isFile = ((S_IFREG & buf.st_mode ) !=0)
- _isDir = ((S_IFDIR & buf.st_mode ) !=0)
+ _isFile = ((S_IFREG & buf.st_mode ) !=0);
+ _isDir = ((S_IFDIR & buf.st_mode ) !=0);
}
#else
return result;
}
+
+bool SGPath::isAbsolute() const
+{
+ if (path.empty()) {
+ return false;
+ }
+
+#ifdef _WIN32
+ // detect '[A-Za-z]:/'
+ if (path.size() > 2) {
+ if (isalpha(path[0]) && (path[1] == ':') && (path[2] == sgDirPathSep)) {
+ return true;
+ }
+ }
+#endif
+
+ return (path[0] == sgDirPathSep);
+}
+
+bool SGPath::isNull() const
+{
+ return path.empty() || (path == "");
+}