moving along
[vrfileman] / src / fspath.h
diff --git a/src/fspath.h b/src/fspath.h
new file mode 100644 (file)
index 0000000..0bc0b70
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef FSPATH_H_
+#define FSPATH_H_
+
+char *make_abs_path(const char *s);
+
+class FSPath {
+private:
+       char *abs_path;
+       char *name, *suffix;
+       char *parent;
+
+       void sanitize();
+
+public:
+       FSPath();
+       FSPath(const char *s);
+       ~FSPath();
+
+       FSPath(const FSPath &p);
+       FSPath &operator =(const FSPath &p);
+
+       FSPath(FSPath &&p);
+       FSPath &operator =(FSPath &&p);
+
+       bool set_path(const char *s);
+       const char *get_path() const;
+
+       const char *get_name() const;
+       const char *get_suffix() const;
+       const char *get_parent() const;
+
+       bool append_path(const char *s);
+
+       // does this path actually exist in the filesystem?
+       bool exists() const;
+       // true if this path exists and is a regular file
+       bool is_file() const;
+       // true if this path exists and is a directory
+       bool is_dir() const;
+       // true of this path exists and is a device file
+       bool is_dev() const;
+
+       operator const char* () const;
+};
+
+
+#endif // FSPATH_H_