Move doc for PBD::sys::path_is_within to header
[ardour.git] / libs / pbd / pathscanner.cc
index 9b41de9544c0a3f085fc911d416340c2268f4c9a..8f57726c7f65206b42ea3bbd65507a59a0496c04 100644 (file)
 #include <sys/types.h>
 #include <sys/stat.h>
 
+#include <glibmm/miscutils.h>
+
 #include "pbd/error.h"
 #include "pbd/pathscanner.h"
 #include "pbd/stl_delete.h"
 
+using namespace std;
 using namespace PBD;
 
 vector<string *> *
@@ -89,7 +92,7 @@ PathScanner::run_scan_internal (vector<string *> *result,
        struct dirent *finfo;
        char *pathcopy = strdup (dirpath.c_str());
        char *thisdir;
-       char fullpath[PATH_MAX+1];
+       string fullpath;
        string search_str;
        string *newstr;
        long nfound = 0;
@@ -116,12 +119,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;
                        }
 
@@ -146,7 +148,7 @@ PathScanner::run_scan_internal (vector<string *> *result,
                                                continue;
                                        }
                                }
-                               
+
                                if (return_fullpath) {
                                        newstr = new string (fullpath);
                                } else {
@@ -209,7 +211,7 @@ PathScanner::find_first (const string &dirpath,
 string *
 PathScanner::find_first (const string &dirpath,
                         bool (*filter)(const string &, void *),
-                        void *arg,
+                        void * /*arg*/,
                         bool match_fullpath,
                         bool return_fullpath)
 {