Add resume option to acsmdownloader
This commit is contained in:
@@ -99,10 +99,11 @@ namespace gourou
|
||||
* @param contentType Optional content type of POST Data
|
||||
* @param responseHeaders Optional Response headers of HTTP request
|
||||
* @param fd Optional file descriptor to write request result
|
||||
* @param resume false if target file should be truncated, true to try resume download (works only in combination with a valid fd)
|
||||
*
|
||||
* @return data of HTTP response
|
||||
*/
|
||||
virtual std::string sendHTTPRequest(const std::string& URL, const std::string& POSTData=std::string(""), const std::string& contentType=std::string(""), std::map<std::string, std::string>* responseHeaders=0, int fd=0) = 0;
|
||||
virtual std::string sendHTTPRequest(const std::string& URL, const std::string& POSTData=std::string(""), const std::string& contentType=std::string(""), std::map<std::string, std::string>* responseHeaders=0, int fd=0, bool resume=false) = 0;
|
||||
};
|
||||
|
||||
class RSAInterface
|
||||
|
@@ -81,10 +81,11 @@ namespace gourou
|
||||
*
|
||||
* @param item Item from fulfill() method
|
||||
* @param path Output file path
|
||||
* @param resume false if target file should be truncated, true to try resume download
|
||||
*
|
||||
* @return Type of downloaded item
|
||||
*/
|
||||
ITEM_TYPE download(FulfillmentItem* item, std::string path);
|
||||
ITEM_TYPE download(FulfillmentItem* item, std::string path, bool resume=false);
|
||||
|
||||
/**
|
||||
* @brief SignIn into ACS Server (required to activate device)
|
||||
@@ -135,10 +136,11 @@ namespace gourou
|
||||
* @param contentType Optional content type of POST Data
|
||||
* @param responseHeaders Optional Response headers of HTTP request
|
||||
* @param fd Optional File descriptor to write received data
|
||||
* @param resume false if target file should be truncated, true to try resume download (works only in combination of a valid fd)
|
||||
*
|
||||
* @return data of HTTP response
|
||||
*/
|
||||
ByteArray sendRequest(const std::string& URL, const std::string& POSTData=std::string(), const char* contentType=0, std::map<std::string, std::string>* responseHeaders=0, int fd=0);
|
||||
ByteArray sendRequest(const std::string& URL, const std::string& POSTData=std::string(), const char* contentType=0, std::map<std::string, std::string>* responseHeaders=0, int fd=0, bool resume=false);
|
||||
|
||||
/**
|
||||
* @brief Send HTTP POST request to URL with document as POSTData
|
||||
|
@@ -287,13 +287,19 @@ namespace gourou
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Open a file descriptor on path. If it already exists, it's truncated
|
||||
* @brief Open a file descriptor on path. If it already exists and truncate == true, it's truncated
|
||||
*
|
||||
* @return Created fd, must be closed
|
||||
*/
|
||||
static inline int createNewFile(std::string path)
|
||||
static inline int createNewFile(std::string path, bool truncate=true)
|
||||
{
|
||||
int fd = open(path.c_str(), O_CREAT|O_WRONLY|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);
|
||||
int options = O_CREAT|O_WRONLY;
|
||||
if (truncate)
|
||||
options |= O_TRUNC;
|
||||
else
|
||||
options |= O_APPEND;
|
||||
|
||||
int fd = open(path.c_str(), options, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);
|
||||
|
||||
if (fd <= 0)
|
||||
EXCEPTION(GOUROU_FILE_ERROR, "Unable to create " << path);
|
||||
|
Reference in New Issue
Block a user