]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/ftp.tex
more samples are being built and samples/Makefiles uses SAMPLES_SUBDIRS
[wxWidgets.git] / docs / latex / wx / ftp.tex
1 \section{\class{wxFTP}}\label{wxftp}
2
3 \wxheading{Derived from}
4
5 \helpref{wxProtocol}{wxprotocol}
6
7 \wxheading{Include files}
8
9 <wx/protocol/ftp.h>
10
11 \wxheading{See also}
12
13 \helpref{wxSocketBase}{wxsocketbase}
14
15 % ----------------------------------------------------------------------------
16 % Members
17 % ----------------------------------------------------------------------------
18
19 \latexignore{\rtfignore{\wxheading{Members}}}
20
21 \membersection{wxFTP::SendCommand}
22
23 \func{bool}{SendCommand}{\param{const wxString\&}{ command}, \param{char }{ret}}
24
25 Send the specified \it{command} to the FTP server. \it{ret} specifies
26 the expected result.
27
28 \wxheading{Return value}
29
30 TRUE, if the command has been sent successfully, else FALSE.
31
32 % ----------------------------------------------------------------------------
33
34 \membersection{wxFTP::GetLastResult}
35
36 \func{const wxString\&}{GetLastResult}{\void}
37
38 Returns the last command result.
39
40 % ----------------------------------------------------------------------------
41
42 \membersection{wxFTP::ChDir}
43
44 \func{bool}{ChDir}{\param{const wxString\&}{ dir}}
45
46 Change the current FTP working directory.
47 Returns TRUE if successful.
48
49 \membersection{wxFTP::MkDir}
50
51 \func{bool}{MkDir}{\param{const wxString\&}{ dir}}
52
53 Create the specified directory in the current FTP working directory.
54 Returns TRUE if successful.
55
56 \membersection{wxFTP::RmDir}
57
58 \func{bool}{RmDir}{\param{const wxString\&}{ dir}}
59
60 Remove the specified directory from the current FTP working directory.
61 Returns TRUE if successful.
62
63 \membersection{wxFTP::Pwd}
64
65 \func{wxString}{Pwd}{\void}
66
67 Returns the current FTP working directory.
68
69 % ----------------------------------------------------------------------------
70
71 \membersection{wxFTP::Rename}
72
73 \func{bool}{Rename}{\param{const wxString\&}{ src}, \param{const wxString\&}{ dst}}
74
75 Rename the specified \it{src} element to \it{dst}. Returns TRUE if successful.
76
77 % ----------------------------------------------------------------------------
78
79 \membersection{wxFTP::RmFile}
80
81 \func{bool}{RmFile}{\param{const wxString\&}{ path}}
82
83 Delete the file specified by \it{path}. Returns TRUE if successful.
84
85 % ----------------------------------------------------------------------------
86
87 \membersection{wxFTP::SetUser}
88
89 \func{void}{SetUser}{\param{const wxString\&}{ user}}
90
91 Sets the user name to be sent to the FTP server to be allowed to log in.
92
93 \wxheading{Default value}
94
95 The default value of the user name is "anonymous".
96
97 \wxheading{Remark}
98
99 This parameter can be included in a URL if you want to use the URL manager.
100 For example, you can use: "ftp://a\_user:a\_password@a.host:service/a\_directory/a\_file"
101 to specify a user and a password.
102
103 \membersection{wxFTP::SetPassword}
104
105 \func{void}{SetPassword}{\param{const wxString\&}{ passwd}}
106
107 Sets the password to be sent to the FTP server to be allowed to log in.
108
109 \wxheading{Default value}
110
111 The default value of the user name is your email address. For example, it could
112 be "username@userhost.domain". This password is built by getting the current
113 user name and the host name of the local machine from the system.
114
115 \wxheading{Remark}
116
117 This parameter can be included in a URL if you want to use the URL manager.
118 For example, you can use: "ftp://a\_user:a\_password@a.host:service/a\_directory/a\_file"
119 to specify a user and a password.
120
121 % ----------------------------------------------------------------------------
122 \membersection{wxFTP::GetList}
123
124 \func{wxList *}{GetList}{\param{const wxString\&}{ wildcard}}
125
126 The GetList function is quite low-level. It returns the list of the files in
127 the current directory. The list can be filtered using the \it{wildcard} string.
128 If \it{wildcard} is a NULL string, it will return all files in directory.
129
130 The form of the list can change from one peer system to another. For example,
131 for a UNIX peer system, it will look like this:
132
133 \begin{verbatim}
134 -r--r--r-- 1 guilhem lavaux 12738 Jan 16 20:17 cmndata.cpp
135 -r--r--r-- 1 guilhem lavaux 10866 Jan 24 16:41 config.cpp
136 -rw-rw-rw- 1 guilhem lavaux 29967 Dec 21 19:17 cwlex_yy.c
137 -rw-rw-rw- 1 guilhem lavaux 14342 Jan 22 19:51 cwy_tab.c
138 -r--r--r-- 1 guilhem lavaux 13890 Jan 29 19:18 date.cpp
139 -r--r--r-- 1 guilhem lavaux 3989 Feb 8 19:18 datstrm.cpp
140 \end{verbatim}
141
142 But on Windows system, it will look like this:
143
144 \begin{verbatim}
145 winamp~1 exe 520196 02-25-1999 19:28 winamp204.exe
146 1 file(s) 520 196 bytes
147 \end{verbatim}
148
149 The list is a string list and one node corresponds to a line sent by the peer.
150
151 % ----------------------------------------------------------------------------
152
153 \membersection{wxFTP::GetOutputStream}
154
155 \func{wxOutputStream *}{GetOutputStream}{\param{const wxString\&}{ file}}
156
157 Initializes an output stream to the specified \it{file}. The returned
158 stream has all but the seek functionality of wxStreams. When the user finishes
159 writing data, he has to delete the stream to close it.
160
161 \wxheading{Return value}
162
163 An initialized write-only stream.
164
165 \wxheading{See also}
166
167 \helpref{wxOutputStream}{wxoutputstream}
168
169 % ----------------------------------------------------------------------------
170
171 \membersection{wxFTP::GetInputStream}\label{wxftpgetinput}
172
173 \func{wxInputStream *}{GetInputStream}{\param{const wxString\&}{ path}}
174
175 Creates a new input stream on the the specified path. You can use all but seek
176 functionnality of wxStream. Seek isn't available on all stream. For example,
177 http or ftp streams doesn't deal with it. Other functions like Tell
178 aren't available for the moment for this sort of stream.
179 You will be notified when the EOF is reached by an error.
180
181 \wxheading{Return value}
182
183 Returns NULL if an error occured (it could be a network failure or the fact
184 that the file doesn't exist).
185
186 Returns the initialized stream. You will have to delete it yourself once you
187 don't use it anymore. The destructor close the DATA stream connection but
188 will leave the COMMAND stream connection opened. It means that you still
189 can send new commands without reconnecting.
190
191 \wxheading{Example of a standalone connection (without wxURL)}
192
193 \begin{verbatim}
194 wxFTP ftp;
195 wxInputStream *in\_stream;
196 char *data;
197
198 ftp.Connect("a.host.domain");
199 ftp.ChDir("a\_directory");
200 in\_stream = ftp.GetInputStream("a\_file\_to\_get");
201
202 data = new char[in\_stream->StreamSize()];
203
204 in\_stream->Read(data, in\_stream->StreamSize());
205 if (in\_stream->LastError() != wxStream\_NOERROR) {
206 // Do something.
207 }
208
209 delete in\_stream; /* Close the DATA connection */
210
211 ftp.Close(); /* Close the COMMAND connection */
212 \end{verbatim}
213
214 \wxheading{See also}
215
216 \helpref{wxInputStream}{wxinputstream}
217