path.cc - manipulation of paths and filenames.
*/
+#include "config.h"
#include <stdio.h>
+#include <errno.h>
+#if HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
-#include "config.h"
#include "file-path.hh"
#include "flower-debug.hh"
path += nm;
DEBUG_OUT << path << "? ";
+
+#if 0
+ /*
+ Check if directory. TODO: encapsulate for autoconf
+ */
+ struct stat sbuf;
+ if (stat (path.ch_C(), &sbuf) == ENOENT)
+ continue;
+
+ if (!(sbuf.st_mode & __S_IFREG))
+ continue;
+#endif
+#if !STAT_MACROS_BROKEN
+ struct stat sbuf;
+ if (stat (path.ch_C (), &sbuf) == ENOENT)
+ continue;
+
+ if (S_ISDIR (sbuf.st_mode))
+ continue;
+#endif
+
FILE *f = fopen (path.ch_C(), "r"); // ugh!
if (f)
{
return "";
}
+/**
+ Add a directory, return false if failed
+ */
+bool
+File_path::try_add (String s)
+{
+ if (s == "")
+ s = ".";
+ FILE * f = fopen (s.ch_C(), "r");
+ if (!f)
+ return false;
+ fclose (f);
+
+ push (s);
+ return true;
+}
+
void
File_path::add (String s)
{
- push (s);
+ push (s);
}
String