-
Notifications
You must be signed in to change notification settings - Fork 66
/
FileClient.h
67 lines (57 loc) · 1014 Bytes
/
FileClient.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
#ifndef _ZJY_FILECLIENT_H_
#define _ZJY_FILECLIENT_H_
#include <string>
#include "UploadInterface.h"
#include "SimpleSocket.h"
using std::string;
struct FileInfo
{
string short_name;
DWORD file_size;
unsigned int writed;
FILE *fp;
int type;
FileInfo():file_size(0),writed(0),fp(0),type(0)
{
}
~FileInfo()
{
if(fp)fclose(fp);
}
bool Finish()
{
return writed == file_size;
}
bool Valued()
{
return fp!=0;
}
const char *read(int &nsize);
};
class CFileClient:public ISendFileInterface
{
public:
CFileClient():m_stop(true)
{
}
virtual ~CFileClient()
{
}
virtual const char *GetError()
{
return m_error.c_str();
}
virtual unsigned int ChoseFile(const char *name,int type);
virtual bool Connect(const char *host,unsigned short port);
virtual int SendFile(PTransInfo info);
virtual void Stop()
{
m_stop=true;
}
private:
FileInfo m_file;
string m_error;
CSimpleSocket m_sock;
bool m_stop;
};
#endif