|
|
Comments and Discussions
|
|
 |

|
Thank you Otom
Danke!
No. there is only one CFTPClient running. here is my code, very sample:
#include "stdafx.h"
#include "cstring"
typedef struct node_s {
std::wstring name;
std::wstring path;
int state;
} node_t;
bool itr_url(nsFTP::CFTPClient& client, const node_t& node)
{
if (node.name.empty()) {
return false;
}
nsFTP::TSpFTPFileStatusVector list;
if (!client.List(node.path, list)) {
return false;
}
printf("scanning %ls \n", node.name.c_str());
for(nsFTP::TSpFTPFileStatusVector::iterator it = list.begin();
it != list.end(); ++it) {
if ((*it)->IsCwdPossible()) { //this is a folder
node_t n;
n.name = (*it)->Name().c_str();
n.path = node.path + _T("/") + n.name;
n.state = 0;
if (!itr_url(client, n)) return false;
}
}
return true;
}
bool itr_url(nsFTP::CFTPClient& client, const std::wstring path)
{
nsFTP::TSpFTPFileStatusVector list;
if (!client.List(path, list)) return false;
printf("scanning %ls \n", path.c_str());
for(nsFTP::TSpFTPFileStatusVector::iterator it = list.begin();
it != list.end(); ++it) {
if ((*it)->IsCwdPossible()) { //this is a folder
node_t n;
n.name = (*it)->Name().c_str();
n.path = path + _T("/") + n.name;
n.state = 0;
if (!itr_url(client, n)) { return false; }
}
}
if (client.IsConnected()) client.Logout();
return true;
}
int _tmain(int argc, _TCHAR* argv[])
{
int port_number = 21;
nsFTP::CFTPClient ftpClient;
nsFTP::CLogonInfo logonInfo(_T("214.25.77.227"), 21,
_T("test"), _T("Q+683bjM"));
// Initialize use of Winsock DLL by a process
WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD(2, 2);
err = WSAStartup(wVersionRequested, &wsaData);
if (err != 0) {
printf("WSAStartup failed with error: %d\n", err);
return 1;
}
if (LOBYTE(wsaData.wVersion) != 2 ||
HIBYTE(wsaData.wVersion) != 2) {
printf("Could not find a usable version of Winsock.dll\n");
WSACleanup();
return 1;
} else printf("The Winsock 2.2 dll was found okay\n");
ftpClient.Login(logonInfo);
itr_url(ftpClient, _T("./content"));
ftpClient.Logout();
WSACleanup();
return 0;
}
if you have many subfolders/files under ./content, you can see that it not work.
and you can also see that the processing of List() becomes very slow before it blocked...
could you help me?
Aurora
modified 23 Dec '11 - 13:02.
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
A non-MFC class to encapsulate the FTP protocol.
| Type | Article |
| Licence | CPOL |
| First Posted | 27 Oct 2004 |
| Views | 268,243 |
| Downloads | 22,617 |
| Bookmarked | 181 times |
|
|