diff --git a/src/rcldb/rcldb.cpp b/src/rcldb/rcldb.cpp index a5457672..51077278 100644 --- a/src/rcldb/rcldb.cpp +++ b/src/rcldb/rcldb.cpp @@ -1307,7 +1307,7 @@ bool Db::addOrUpdate(const string &udi, const string &parent_udi, Doc &doc) // Split and index the path from the url for path-based filtering { - string path = url_gpath(doc.url); + string path = url_gpathS(doc.url); vector vpath; stringToTokens(path, vpath, "/"); // If vpath is not /, the last elt is the file/dir name, not a diff --git a/src/utils/pathut.cpp b/src/utils/pathut.cpp index a132a8e0..8ba9899e 100644 --- a/src/utils/pathut.cpp +++ b/src/utils/pathut.cpp @@ -805,6 +805,29 @@ string url_gpath(const string& url) return path_canon(url.substr(colon+1)); } +string url_gpathS(const string& url) +{ +#ifdef _WIN32 + string u = url_gpath(url); + string nu; + if (path_hasdrive(u)) { + nu.append(1, '/'); + nu.append(1, u[0]); + if (path_isdriveabs(u)) { + nu.append(u.substr(2)); + } else { + // This should be an error really + nu.append(1, '/'); + nu.append(u.substr(2)); + } + } + return nu; +#else + return url_gpath(url); +#endif +} + + string url_parentfolder(const string& url) { // In general, the parent is the directory above the full path diff --git a/src/utils/pathut.h b/src/utils/pathut.h index 8c825cd6..4e4ad1ab 100644 --- a/src/utils/pathut.h +++ b/src/utils/pathut.h @@ -67,6 +67,12 @@ extern std::string url_parentfolder(const std::string& url); /// routine, it does the right thing only in the recoll context extern std::string url_gpath(const std::string& url); +/// Same but, in the case of a Windows local path, also turn "c:/" into +/// "/c/" This should be used only for splitting the path in rcldb, it +/// would better be local in there, but I prefer to keep all the +/// system-specific path stuff in pathut +extern std::string url_gpathS(const std::string& url); + /// Stat parameter and check if it's a directory extern bool path_isdir(const std::string& path);