
Alexander Nasonov wrote:
Peter Dimov wrote:
std::ifstream is( "http://www.example.com/file.zip" ); std::ofstream os( "file.zip" ); os << is.rdbuf();
No proposal required, in principle.
Are you aware of (a) ambiguity and (b) potential security hole?
Yes, I am aware of both. It's a tradeoff.
(a)
mkdir http: mkdir http:/www.example.com touch http:/www.example.com/file.zip file http://www.example.com/file.zip http://www.example.com/file.zip: empty
(b) If you replace the first line with something more generic, for example with: std::ifstream is( argv[1] );
it becomes unclear that the code might send requests to the net.
The code can already send requests to the net; an example is \\www.example.com\share\file under Windows. In most cases, allowing existing code to seamlessly read from remote files over HTTP or FTP is a feature. PHP, for example, does that in its fopen, and most graphical shells also maintain this illusion. Anyway, I just wanted to illustrate the fact that standard library implementors already have the ability to add HTTP/FTP functionality; unfortunately, none have done so. C++ is a somewhat conservative language. :-) The obvious alternative is, of course, std::tr2::iurlstream is( "http://www.example.com/file.zip" ); which does require a proposal, albeit a relatively simple one. ASIO need not be involved in any way, and the implementation under Windows can use WinInet, for example.