Windows: fix path splitting for the XP field

This commit is contained in:
Jean-Francois Dockes
2015-10-14 10:53:15 +02:00
parent 4b91fec6c7
commit d013ecb1bc
3 changed files with 30 additions and 1 deletions
+23
View File
@@ -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
+6
View File
@@ -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);