mirror of
https://github.com/glest/glest-source.git
synced 2025-08-29 19:00:07 +02:00
- more ftp bugfixes
This commit is contained in:
@@ -36,15 +36,20 @@ struct FtpFile {
|
|||||||
FILE *stream;
|
FILE *stream;
|
||||||
};
|
};
|
||||||
|
|
||||||
static size_t my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream)
|
static size_t my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream) {
|
||||||
{
|
|
||||||
struct FtpFile *out=(struct FtpFile *)stream;
|
struct FtpFile *out=(struct FtpFile *)stream;
|
||||||
if(out && !out->stream) {
|
if(out && out->stream == NULL) {
|
||||||
|
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Client thread opening file for writing [%s]\n",out->filename);
|
||||||
|
|
||||||
/* open file for writing */
|
/* open file for writing */
|
||||||
out->stream=fopen(out->filename, "wb");
|
out->stream=fopen(out->filename, "wb");
|
||||||
if(!out->stream)
|
if(out->stream == NULL) {
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Client thread FAILED to open file for writing [%s]\n",out->filename);
|
||||||
|
|
||||||
return -1; /* failure, can't open file to write */
|
return -1; /* failure, can't open file to write */
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return fwrite(buffer, size, nmemb, out->stream);
|
return fwrite(buffer, size, nmemb, out->stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,6 +83,8 @@ void FTPClientThread::getMapFromServer(string mapFileName) {
|
|||||||
destFile += destFileExt;
|
destFile += destFileExt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Client thread about to try to RETR into [%s]\n",destFile.c_str());
|
||||||
|
|
||||||
struct FtpFile ftpfile = {
|
struct FtpFile ftpfile = {
|
||||||
destFile.c_str(), /* name to store the file as if succesful */
|
destFile.c_str(), /* name to store the file as if succesful */
|
||||||
NULL
|
NULL
|
||||||
@@ -91,6 +98,8 @@ void FTPClientThread::getMapFromServer(string mapFileName) {
|
|||||||
* You better replace the URL with one that works!
|
* You better replace the URL with one that works!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
ftpfile.stream = NULL;
|
||||||
|
|
||||||
char szBuf[1024]="";
|
char szBuf[1024]="";
|
||||||
sprintf(szBuf,"ftp://maps:mg_ftp_server@%s/%s%s",serverUrl.c_str(),mapFileName.c_str(),destFileExt.c_str());
|
sprintf(szBuf,"ftp://maps:mg_ftp_server@%s/%s%s",serverUrl.c_str(),mapFileName.c_str(),destFileExt.c_str());
|
||||||
|
|
||||||
@@ -112,6 +121,8 @@ void FTPClientThread::getMapFromServer(string mapFileName) {
|
|||||||
/* we failed */
|
/* we failed */
|
||||||
fprintf(stderr, "curl told us %d\n", res);
|
fprintf(stderr, "curl told us %d\n", res);
|
||||||
|
|
||||||
|
ftpfile.stream = NULL;
|
||||||
|
|
||||||
sprintf(szBuf,"ftp://maps_custom:mg_ftp_server@%s/%s%s",serverUrl.c_str(),mapFileName.c_str(),destFileExt.c_str());
|
sprintf(szBuf,"ftp://maps_custom:mg_ftp_server@%s/%s%s",serverUrl.c_str(),mapFileName.c_str(),destFileExt.c_str());
|
||||||
|
|
||||||
curl_easy_setopt(curl, CURLOPT_URL,szBuf);
|
curl_easy_setopt(curl, CURLOPT_URL,szBuf);
|
||||||
@@ -145,19 +156,19 @@ void FTPClientThread::getMapFromServer(string mapFileName) {
|
|||||||
|
|
||||||
if(ftpfile.stream) {
|
if(ftpfile.stream) {
|
||||||
fclose(ftpfile.stream); /* close the local file */
|
fclose(ftpfile.stream); /* close the local file */
|
||||||
|
ftpfile.stream = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(result != ftp_crt_SUCCESS && EndsWith(destFile,".mgm")) {
|
if(result != ftp_crt_SUCCESS && EndsWith(destFile,".mgm")) {
|
||||||
destFile = mapFileName + ".gbm";
|
destFile = mapFileName + ".gbm";
|
||||||
getMapFromServer(destFile);
|
getMapFromServer(destFile);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
//curl_global_cleanup();
|
|
||||||
|
|
||||||
if(this->pCBObject != NULL) {
|
if(this->pCBObject != NULL) {
|
||||||
this->pCBObject->FTPClient_CallbackEvent(mapFileName,result);
|
this->pCBObject->FTPClient_CallbackEvent(mapFileName,result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FTPClientThread::addMapToRequests(string mapFilename) {
|
void FTPClientThread::addMapToRequests(string mapFilename) {
|
||||||
MutexSafeWrapper safeMutex(&mutexMapFileList);
|
MutexSafeWrapper safeMutex(&mutexMapFileList);
|
||||||
|
Reference in New Issue
Block a user