mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-15 19:33:07 +01:00
improvement of URIStreamOpener::open() implementation
This commit is contained in:
parent
e87a3a6e45
commit
a73eef0487
@ -65,22 +65,15 @@ std::istream* URIStreamOpener::open(const std::string& pathOrURI) const
|
||||
{
|
||||
return openURI(scheme, uri);
|
||||
}
|
||||
else
|
||||
else if (scheme.length() <= 1) // could be Windows path
|
||||
{
|
||||
Path path;
|
||||
if (path.tryParse(pathOrURI, Path::PATH_GUESS))
|
||||
{
|
||||
return openFile(path);
|
||||
else
|
||||
throw UnknownURISchemeException(pathOrURI);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (UnknownURISchemeException&)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (TooManyURIRedirectsException&)
|
||||
{
|
||||
throw;
|
||||
throw UnknownURISchemeException(pathOrURI);
|
||||
}
|
||||
catch (URISyntaxException&)
|
||||
{
|
||||
@ -105,24 +98,32 @@ std::istream* URIStreamOpener::open(const std::string& basePathOrURI, const std:
|
||||
if (it != _map.end())
|
||||
{
|
||||
uri.resolve(pathOrURI);
|
||||
scheme = uri.getScheme();
|
||||
return openURI(scheme, uri);
|
||||
}
|
||||
else if (scheme.length() <= 1) // could be Windows path
|
||||
{
|
||||
Path base;
|
||||
Path path;
|
||||
if (base.tryParse(basePathOrURI, Path::PATH_GUESS) && path.tryParse(pathOrURI, Path::PATH_GUESS))
|
||||
{
|
||||
base.resolve(path);
|
||||
return openFile(base);
|
||||
}
|
||||
}
|
||||
throw UnknownURISchemeException(basePathOrURI);
|
||||
}
|
||||
catch (UnknownURISchemeException&)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (TooManyURIRedirectsException&)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception&)
|
||||
catch (URISyntaxException&)
|
||||
{
|
||||
Path base;
|
||||
Path path;
|
||||
if (base.tryParse(basePathOrURI, Path::PATH_GUESS) && path.tryParse(pathOrURI, Path::PATH_GUESS))
|
||||
{
|
||||
base.resolve(path);
|
||||
return openFile(base);
|
||||
}
|
||||
else throw;
|
||||
}
|
||||
Path base(basePathOrURI, Path::PATH_GUESS);
|
||||
Path path(pathOrURI, Path::PATH_GUESS);
|
||||
base.resolve(path);
|
||||
return openFile(base);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user