|
a/src/utils/pathut.cpp |
|
b/src/utils/pathut.cpp |
|
... |
|
... |
523 |
// was hardcoded, but the local path was used for doc
|
523 |
// was hardcoded, but the local path was used for doc
|
524 |
// identification.
|
524 |
// identification.
|
525 |
return path_canon(url.substr(colon+1));
|
525 |
return path_canon(url.substr(colon+1));
|
526 |
}
|
526 |
}
|
527 |
|
527 |
|
|
|
528 |
string url_parentfolder(const string& url)
|
|
|
529 |
{
|
|
|
530 |
// In general, the parent is the directory above the full path
|
|
|
531 |
string parenturl = path_getfather(url_gpath(url));
|
|
|
532 |
// But if this is http, make sure to keep the host part. Recoll
|
|
|
533 |
// only has file or http urls for now.
|
|
|
534 |
bool isfileurl = urlisfileurl(url);
|
|
|
535 |
if (!isfileurl && parenturl == "/") {
|
|
|
536 |
parenturl = url_gpath(url);
|
|
|
537 |
}
|
|
|
538 |
return isfileurl ? string("file://") + parenturl :
|
|
|
539 |
string("http://") + parenturl;
|
|
|
540 |
}
|
|
|
541 |
|
528 |
// Convert to file path if url is like file:
|
542 |
// Convert to file path if url is like file:
|
529 |
// Note: this only works with our internal pseudo-urls which are not
|
543 |
// Note: this only works with our internal pseudo-urls which are not
|
530 |
// encoded/escaped
|
544 |
// encoded/escaped
|
531 |
string fileurltolocalpath(string url)
|
545 |
string fileurltolocalpath(string url)
|
532 |
{
|
546 |
{
|
|
... |
|
... |
538 |
if ((pos = url.find_last_of("#")) != string::npos) {
|
552 |
if ((pos = url.find_last_of("#")) != string::npos) {
|
539 |
url.erase(pos);
|
553 |
url.erase(pos);
|
540 |
}
|
554 |
}
|
541 |
return url;
|
555 |
return url;
|
542 |
}
|
556 |
}
|
|
|
557 |
|
543 |
bool urlisfileurl(const string& url)
|
558 |
bool urlisfileurl(const string& url)
|
544 |
{
|
559 |
{
|
545 |
return url.find("file://") == 0;
|
560 |
return url.find("file://") == 0;
|
546 |
}
|
561 |
}
|
547 |
|
562 |
|