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 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.
您可能需要研究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++.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.