moved util. func. out of qtgui file

This commit is contained in:
Jean-Francois Dockes 2011-05-09 06:58:54 +02:00
parent f1c651deeb
commit 4287eb008a
2 changed files with 16 additions and 0 deletions

View File

@ -443,6 +443,20 @@ string url_gpath(const string& url)
return path_canon(url.substr(colon+1));
}
// Convert to file path if url is like file://
string fileurltolocalpath(string url)
{
if (url.find("file://") == 0)
url = url.substr(7, string::npos);
else
return string();
string::size_type pos;
if ((pos = url.find_last_of("#")) != string::npos) {
url.erase(pos);
}
return url;
}
// Printable url: this is used to transcode from the system charset
// into either utf-8 if transcoding succeeds, or url-encoded
bool printableUrl(const string &fcharset, const string &in, string &out)

View File

@ -55,6 +55,8 @@ extern string url_encode(const string& url,
/// Transcode to utf-8 if possible or url encoding, for display.
extern bool printableUrl(const string &fcharset,
const string &in, string &out);
// Convert to file path if url is like file://
extern string fileurltolocalpath(string url);
/// Return the host+path part of an url. This is not a general
/// routine, it does the right thing only in the recoll context