|
@@ -47,18 +47,19 @@ static thread_local uint64_t uSpeed;
|
|
|
*/
|
|
|
static size_t writeStringCallback(void *contents, size_t size, size_t nmemb, std::string *userStr)
|
|
|
{
|
|
|
- size_t newLength = size * nmemb;
|
|
|
- size_t oldLength = userStr->size();
|
|
|
- try
|
|
|
- {
|
|
|
- userStr->resize(oldLength + newLength);
|
|
|
- }
|
|
|
- catch(std::bad_alloc &e)
|
|
|
- {
|
|
|
-
|
|
|
- return 0;
|
|
|
- }
|
|
|
- std::copy_n((char*)contents, newLength, userStr->begin() + oldLength);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ userStr->append((char*)contents, size * nmemb);
|
|
|
return size * nmemb;
|
|
|
}
|
|
|
|
|
@@ -573,6 +574,7 @@ bool CurlFtp::isDirExist(const std::string& dir)
|
|
|
curl_easy_setopt(m_curl, CURLOPT_PASSWORD, m_password.c_str());
|
|
|
|
|
|
curl_easy_setopt(m_curl, CURLOPT_NOBODY, 1L);
|
|
|
+ curl_easy_setopt(m_curl, CURLOPT_HEADER, 1L);
|
|
|
|
|
|
|
|
|
setSftp(m_curl);
|
|
@@ -587,16 +589,27 @@ bool CurlFtp::isDirExist(const std::string& dir)
|
|
|
|
|
|
CURLcode res = curl_easy_perform(m_curl);
|
|
|
bool result = true;
|
|
|
- if(res != CURLE_OK)
|
|
|
+ if(res == CURLE_REMOTE_FILE_NOT_FOUND)
|
|
|
{
|
|
|
-
|
|
|
result = false;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ else if(res != CURLE_OK)
|
|
|
+ {
|
|
|
+
|
|
|
+ result = false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
return result;
|
|
|
}
|