Patch level : 10.0

Files correlati     : xvaga.dll
Ricompilazione Demo : [ ]
Commento            :
Aggiunto parametro in campo.ini
[Server]
ftp=Active

Per permettere accesso a server ftp in modalità Active invece della solita Passive di default.


git-svn-id: svn://10.65.10.50/branches/R_10_00@22368 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2011-07-04 14:03:13 +00:00
parent cac3c0166b
commit 03cf81559c

View File

@ -1813,6 +1813,18 @@ long xvt_fsys_get_file_attr(const FILE_SPEC* fs, long attr)
// File system // File system
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
static bool xvt_sys_ftp_passive_mode(const char* server)
{
static char pasv = ' ';
if (pasv <= ' ')
{
char str[16] = "";
xvt_sys_get_profile_string(xvt_fsys_get_campo_ini(), "Server", "ftp", "Passive", str, sizeof(str));
pasv = toupper(str[0]);
}
return pasv != 'A';
}
SLIST xvt_fsys_list_files(const char *type, const char *pat, BOOLEAN dirs) SLIST xvt_fsys_list_files(const char *type, const char *pat, BOOLEAN dirs)
{ {
SLIST list = xvt_slist_create(); SLIST list = xvt_slist_create();
@ -1844,6 +1856,8 @@ SLIST xvt_fsys_list_files(const char *type, const char *pat, BOOLEAN dirs)
ftp.SetUser(strUser); ftp.SetUser(strUser);
ftp.SetPassword(strPwd); ftp.SetPassword(strPwd);
} }
ftp.SetPassive(xvt_sys_ftp_passive_mode(strHost));
const bool bConnected = ftp.Connect(strHost); const bool bConnected = ftp.Connect(strHost);
if (bConnected && ftp.ChDir(fnDir)) if (bConnected && ftp.ChDir(fnDir))
{ {
@ -1852,6 +1866,7 @@ SLIST xvt_fsys_list_files(const char *type, const char *pat, BOOLEAN dirs)
wxArrayString files; wxArrayString files;
ftp.GetList(files, fnName, true); ftp.GetList(files, fnName, true);
for (size_t i = 0; i < files.GetCount(); i++) for (size_t i = 0; i < files.GetCount(); i++)
{ {
const int type = files[i][0] == 'd' ? 2 : 1; const int type = files[i][0] == 'd' ? 2 : 1;
@ -1905,16 +1920,12 @@ BOOLEAN xvt_fsys_set_dir(const DIRECTORY *dirp)
BOOLEAN xvt_fsys_fcopy(const char* orig, const char* dest) BOOLEAN xvt_fsys_fcopy(const char* orig, const char* dest)
{ {
wxURL orig_url(orig); wxURL orig_url(orig);
wxInputStream * input = orig_url.GetInputStream(); if (orig_url.GetScheme() == "ftp")
if (input == NULL && orig_url.GetScheme() == "ftp")
{ {
wxFTP& ftp = (wxFTP&)orig_url.GetProtocol(); wxFTP& ftp = (wxFTP&)orig_url.GetProtocol();
ftp.SetPassive(false); ftp.SetPassive(xvt_sys_ftp_passive_mode(orig_url.GetServer()));
input = orig_url.GetInputStream();
if (input == NULL)
return FALSE;
} }
wxInputStream * input = orig_url.GetInputStream();
wxURL dest_url(dest); wxURL dest_url(dest);
wxOutputStream* output = NULL; wxOutputStream* output = NULL;
@ -1937,6 +1948,7 @@ BOOLEAN xvt_fsys_fcopy(const char* orig, const char* dest)
ftp.SetUser(strUser); ftp.SetUser(strUser);
ftp.SetPassword(strPwd); ftp.SetPassword(strPwd);
} }
ftp.SetPassive(xvt_sys_ftp_passive_mode(strHost));
if (ftp.Connect(strHost)) if (ftp.Connect(strHost))
if (ftp.SetBinary()) if (ftp.SetBinary())
@ -3777,6 +3789,7 @@ int xvt_fsys_access(const char *pathname, int mode)
ftp.SetUser(strUser); ftp.SetUser(strUser);
ftp.SetPassword(strPwd); ftp.SetPassword(strPwd);
} }
ftp.SetPassive(xvt_sys_ftp_passive_mode(strHost));
return ftp.Connect(strHost) && ftp.ChDir(fnDir) ? 0 : EACCES; return ftp.Connect(strHost) && ftp.ChDir(fnDir) ? 0 : EACCES;
} }
} }
@ -3827,6 +3840,7 @@ BOOLEAN xvt_fsys_remove_file(const char *pathname)
ftp.SetUser(strUser); ftp.SetUser(strUser);
ftp.SetPassword(strPwd); ftp.SetPassword(strPwd);
} }
ftp.SetPassive(xvt_sys_ftp_passive_mode(strHost));
if (ftp.Connect(strHost)) if (ftp.Connect(strHost))
if (ftp.ChDir(fnDir)) if (ftp.ChDir(fnDir))