Use PBD::ffs for portability
[ardour.git] / libs / pbd / pathscanner.cc
index 35182042d32aa53e01ee0f31de420c41b5ec1f66..fac2dcfd965258debf26a13a3d65cd4839e76548 100644 (file)
 #include <sys/types.h>
 #include <sys/stat.h>
 
+#include <glibmm/miscutils.h>
+
 #include "pbd/error.h"
+#include "pbd/pathexpand.h"
 #include "pbd/pathscanner.h"
 #include "pbd/stl_delete.h"
 
@@ -88,9 +91,9 @@ PathScanner::run_scan_internal (vector<string *> *result,
 {
        DIR *dir;
        struct dirent *finfo;
-       char *pathcopy = strdup (dirpath.c_str());
+       char *pathcopy = strdup (search_path_expand (dirpath).c_str());
        char *thisdir;
-       char fullpath[PATH_MAX+1];
+       string fullpath;
        string search_str;
        string *newstr;
        long nfound = 0;
@@ -117,12 +120,11 @@ PathScanner::run_scan_internal (vector<string *> *result,
                            (finfo->d_name[0] == '.' && finfo->d_name[1] == '.' && finfo->d_name[2] == '\0')) {
                                continue;
                        }
-
-                       snprintf (fullpath, sizeof(fullpath), "%s/%s",
-                                 thisdir, finfo->d_name);
+                        
+                        fullpath = Glib::build_filename (thisdir, finfo->d_name);
 
                        struct stat statbuf;
-                       if (stat (fullpath, &statbuf) < 0) {
+                       if (stat (fullpath.c_str(), &statbuf) < 0) {
                                continue;
                        }
 
@@ -147,7 +149,7 @@ PathScanner::run_scan_internal (vector<string *> *result,
                                                continue;
                                        }
                                }
-                               
+
                                if (return_fullpath) {
                                        newstr = new string (fullpath);
                                } else {