2 path.cc - manipulation of paths and filenames.
6 #include "flower-debug.hh"
13 @param path the original full filename
14 @return 4 components of the path. They can be empty
17 split_path(String path,
18 String &drive, String &dirs, String &filebase, String &extension)
20 // peel off components, one by one.
21 int di = path.index_i(':');
24 drive = path.left_str(di + 1);
25 path = path.right_str(path.len() - di -1);
30 di = path.index_last_i(PATHSEP);
33 dirs = path.left_str(di + 1);
34 path = path.right_str(path.len()-di -1);
39 di = path.index_last_i('.');
42 filebase = path.left_str(di);
43 extension =path.right_str(path.len()-di);
53 It will search in the current dir, in the construction-arg, and
54 in any other added path, in this order.
57 File_path::find(String nm)const
60 fdebug << "looking for " << nm << ": ";
61 if ( !nm.length_i() || ( nm == "-" ) )
63 for (int i=0; i < size(); i++) {
65 String path = (*this)[i];
66 path+= String(path.length_i()? "/":"")+nm;
68 fdebug << path << "? ";
69 FILE *f = fopen(path.ch_C(), "r"); // ugh!