I'm looking for a good C++ copy function that encapsulate inside local copy, UNC copy, and HTTP download copy. something like
bool copy(string path1, string path2) {}
I'm not strong at c++ and have tendency to create memory 开发者_JAVA百科leaks more than are needed. Is there a complete implementation out there?
Thanks!
Basically you are asking someone to implement a generic copy function that is able to take various different URI's?
For example, if you want to do HTTP downloads you will need a library that knows HTTP, such as cURL.
The other two, (local path and UNC) should work on Windows, look at using fstream. There are plenty of examples.
As it stands this question is extremely vague and isn't really requesting help; merely asking us to implement what sounds like homework.
You might want to look into libcurl.
The copying is easy:
destination << source.rdbuf();
Writing the streambuf to handles the different sources and
destinations is less obvious, although if you have a good library which
handles all of the dirty work, it shouldn't be too hard to wrap it in a
streambuf. (Otherwise: a robust implementation of any socket protocol
is not something for someone not strong at C++.)
加载中,请稍侯......
精彩评论