-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTestFtpStack2.cpp
More file actions
105 lines (87 loc) · 1.99 KB
/
TestFtpStack2.cpp
File metadata and controls
105 lines (87 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "TestFtpStack2.h"
void PrintUsage( const char * pszProgram )
{
printf( "[Usage] %s {ftp IP} {user id} {password}\n", pszProgram );
}
int main( int argc, char * argv[] )
{
#ifdef WIN32
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF );
#endif
if( argc < 4 )
{
PrintUsage( argv[0] );
return 0;
}
const char * pszServerIp = argv[1];
const char * pszUserId = argv[2];
const char * pszPassWord = argv[3];
CFtpClient clsFtp;
InitNetwork();
CLog::SetLevel( LOG_DEBUG | LOG_NETWORK );
// FTP ¼¹ö ¿¬°á ¹× ·Î±×ÀÎ
if( clsFtp.Connect( pszServerIp, 21, false ) == false )
{
printf( "clsFtp.Connect(%s) error\n", pszServerIp );
return 0;
}
if( clsFtp.Login( pszUserId, pszPassWord ) == false )
{
printf( "login error\n" );
return 0;
}
FTP_FILE_LIST clsList;
FTP_FILE_LIST::iterator itFL;
if( clsFtp.List( clsList ) == false )
{
printf( "clsFtp.List()\n" );
return 0;
}
for( itFL = clsList.begin(); itFL != clsList.end(); ++itFL )
{
if( itFL->m_bFolder )
{
printf( "folder[%s]\n", itFL->m_strFileName.c_str() );
}
else
{
printf( "file[%s]\n", itFL->m_strFileName.c_str() );
}
}
if( clsFtp.Upload( "c:\\temp\\ÇѱÛ.txt" ) == false )
{
printf( "upload error\n" );
}
/*
for( int i = 0; i < 100; ++i )
{
FTP_FILE_LIST clsList;
FTP_FILE_LIST::iterator itFL;
if( clsFtp.List( clsList ) == false )
{
printf( "clsFtp.List()\n" );
return 0;
}
for( itFL = clsList.begin(); itFL != clsList.end(); ++itFL )
{
if( itFL->m_bFolder )
{
printf( "folder[%s]\n", itFL->m_strFileName.c_str() );
}
else
{
printf( "file[%s]\n", itFL->m_strFileName.c_str() );
}
}
if( clsFtp.ChangeFolder( "temp" ) == false )
{
printf( "clsFtp.ChangeFolder error\n" );
}
else if( clsFtp.ChangeFolder( ".." ) == false )
{
printf( "clsFtp.ChangeFolder error\n" );
}
}
*/
return 0;
}