-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathftp.cpp
More file actions
executable file
·149 lines (110 loc) · 2.96 KB
/
ftp.cpp
File metadata and controls
executable file
·149 lines (110 loc) · 2.96 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#include "ftp.h"
#include "ftpparse.h"
#include "stringutil.h"
#include "utility.h"
// ftp result parse
// http://cr.yp.to/ftpparse/ftpparse.c
Ftp* Ftp::instance = NULL;
Ftp::Ftp()
{
}
Ftp::~Ftp()
{
}
bool Ftp::Open(String address, String id, String pw)
{
ftp.SetUser(id.c_str());
ftp.SetPassword(pw.c_str());
ftp.SetPassive(false);
if ( !ftp.Connect(address.c_str()) )
{
wxLogError("Couldn't connect");
return false;
}
wxArrayString files;
bool ret = ftp.GetDirList(files);
for(int i=0; i<files.Count(); i++)
{
String s;
s = files[i];
char info[4096];
unicode::convstr_s(info, 4096, s.c_str());
struct ftpparse ftpinfo;
int r = ftpparse(&ftpinfo, info, strlen(info));
}
/*
wxArrayString files2;
ret = ftp.GetFilesList(files2);
for(int i=0; i<files2.Count(); i++)
{
String s;
s = files[i];
}
*/
return true;
}
void Ftp::Close()
{
ftp.Close();
}
void Ftp::ScanFtpFileinfo(std::vector<FILEINFO> &directoryinfolist, std::vector<FILEINFO> &fileinfolist)
{
wxArrayString files;
bool ret = ftp.GetDirList(files);
for(int i=0; i<files.Count(); i++)
{
String s;
s = files[i];
char info[4096];
unicode::convstr_s(info, 4096, s.c_str());
struct ftpparse ftpinfo;
int r = ftpparse(&ftpinfo, info, strlen(info));
wchar temp[4096];
if (ftpinfo.flagtrycwd == 1)
{
FILEINFO info;
info.m_type = TYPE_DIRECTORY;
unicode::convstr_s(temp, 4096, ftpinfo.name);
info.m_name = temp;
info.m_ext = _T("[폴더]");
info.m_attribute = 0;
info.m_attribute |= 0;
info.m_attribute |= 0;
info.m_attribute |= 0;
/*
int len = unicode::strlen(path);
if(path[len-1] == '\\')
info.m_fullpath = String(path) + wfd.cFileName;
else
info.m_fullpath = String(path) + String(_T("\\")) + wfd.cFileName;*/
utility::TimetToFileTime(ftpinfo.mtime, &info.m_creationtime);
utility::TimetToFileTime(ftpinfo.mtime, &info.m_LastAccessTime);
utility::TimetToFileTime(ftpinfo.mtime, &info.m_LastWriteTime);
directoryinfolist.push_back(info);
}
else
{
String name, ext;
FILEINFO info;
info.m_type = TYPE_FILE;
info.m_attribute = 0;
info.m_attribute |= 0;
info.m_attribute |= 0;
info.m_attribute |= 0;
unicode::convstr_s(temp, 4096, ftpinfo.name);
info.m_name = temp;
name = utility::GetName(temp);
ext = utility::GetExtention(temp);
ext.erase(ext.begin());
// info.m_fullpath = String(path) + String(_T("\\")) + info.m_name;
// info.m_excutepath = String(path) + String(_T("\\")) + wfd.cFileName;
info.m_name = name;
info.m_ext = ext;
utility::TimetToFileTime(ftpinfo.mtime, &info.m_creationtime);
utility::TimetToFileTime(ftpinfo.mtime, &info.m_LastAccessTime);
utility::TimetToFileTime(ftpinfo.mtime, &info.m_LastWriteTime);
info.m_filesize = ftpinfo.size;
fileinfolist.push_back(info);
}
}
}