/*
- path.hh -- declare File_path
+ file-path.hh -- declare Path and File_path
source file of the Flower Library
- (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-#ifndef PATH_HH
-#define PATH_HH
+#ifndef FILE_PATH_HH
+#define FILE_PATH_HH
+
#include "string.hh"
#include "array.hh"
Search a number of dirs for a file.
TODO: add a unix style PATH interface
- Should use kpathsea?
-
*/
+class Path
+{
+public:
+ String root;
+ String dir;
+ String base;
+ String ext;
+
+ String to_string () const;
+};
+
class File_path : private Array<String>
{
public:
String find (String nm) const;
Array<String>::push;
- String str ()const;
- void add (String str);
+ void prepend (String str) { Array<String>::insert (str, 0); }
+ String to_string ()const;
+ bool try_add (String str);
+ void add (String);
void parse_path (String);
};
-/** split a path into its components.
-
- @params path
-
- @return
- String &drive, String &dirs, String &filebase, String &extension
- */
-void split_path (String path, String &drive, String &dirs, String &filebase, String &extension);
+Path split_path (String path);
-#endif
+#endif /* FILE_PATH */