forked from apex-hughin/CrimsonEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FtpClnt.h
89 lines (60 loc) · 2.41 KB
/
FtpClnt.h
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
#ifndef __FTP_CLNT_H_
#define __FTP_CLNT_H_
#include <afxsock.h>
// READ/WRITE BUFFER SIZE
#define FTP_TRANSFER_BUFFER_SIZE 512
class CFtpClient
{
public:
CFtpClient();
virtual ~CFtpClient();
BOOL Open(LPCTSTR lpszServer, INT nPortNum = 21);
BOOL Close();
BOOL LogOn(LPCTSTR lpszUser, LPCTSTR lpszPassword);
BOOL LogOff();
BOOL GetCurrentDirectory(CString & szDirName);
BOOL SetCurrentDirectory(LPCTSTR lpszDirName);
BOOL SendCommand(LPCTSTR lpszCommand);
BOOL SetFileTransferType(BOOL bBinary);
BOOL RenameFile(LPCTSTR lpszExisting, LPCTSTR lpszNewName);
BOOL ListDirectory(CStringArray & arrList, LPCTSTR lpszFilter, BOOL bPassive);
BOOL GetFile(LPCTSTR lpszRemoteFile, LPCTSTR lpszLocalFile, BOOL bBinary, BOOL bPassive);
BOOL PutFile(LPCTSTR lpszLocalFile, LPCTSTR lpszRemoteFile, BOOL bBinary, BOOL bPassive);
BOOL OpenFile(BOOL bGet, LPCTSTR lpszRemoteFile, BOOL bBinary, BOOL bPassive);
BOOL CloseFile();
UINT ReadFile(VOID * lpBuf, UINT nMax);
BOOL WriteFile(VOID * lpBuf, UINT nMax);
INT GetResponseCode() { return m_nResponseCode; }
LPCTSTR GetResponseMessage() { return m_szResponseMessage; }
private:
CSocket * m_pControlSocket;
CSocketFile * m_pControlSocketFile;
CArchive * m_pControlReadArchive, * m_pControlWriteArchive;
CSocket * m_pServerSocket, * m_pDataSocket;
CSocketFile * m_pDataSocketFile;
CArchive * m_pDataReadArchive, * m_pDataWriteArchive;
BOOL m_bIsDataChannelEstablished, m_bPassiveModeDataChannel;
BOOL m_bIsRemoteFileOpen, m_bOpenRemoteFileToGet;
INT m_nResponseCode;
CString m_szResponseMessage;
private:
BOOL SetSocketErrorMessage(INT nErrorCode, LPCTSTR lpszDefaultErrorMessage);
BOOL EstablishDataChannel(BOOL bPassive, LPCTSTR lpszCommand);
BOOL DestroyDataChannel();
private:
BOOL StringFromAddress(CString & rString, LPCTSTR lpszAddress, INT nPortNum);
BOOL AddressFromString(CString & rAddress, INT & rPortNum, LPCTSTR lpszString);
BOOL WriteToControlChannel(LPCTSTR lpszString);
BOOL ReadFromControlChannel();
BOOL ReadFromDataChannel(CString & rString);
UINT ReadFromDataChannel(VOID * lpBuf, UINT nMax);
BOOL WriteToDataChannel(VOID * lpBuf, UINT nMax);
BOOL OpenControlChannel(LPCTSTR lpszServer, INT nPortNum);
BOOL CloseControlChannel();
BOOL ListenServer(CString & rAddress, INT & rPortNum);
BOOL CloseServer();
BOOL AcceptDataChannel();
BOOL ConnectDataChannel(LPCTSTR lpszServer, INT nPortNum);
BOOL CloseDataChannel();
};
#endif // __FTP_CLNT_H_