1 <refentry id="gnome-vfs-20-gnome-vfs-xfer">
3 <refentrytitle>File Transfers</refentrytitle>
4 <manvolnum>3</manvolnum>
5 <refmiscinfo>GNOME-VFS-2.0 Library</refmiscinfo>
9 <refname>File Transfers</refname><refpurpose>Conveniently copy/move/delete files en masse</refpurpose>
12 <refsynopsisdiv><title>Synopsis</title>
18 enum <link linkend="GnomeVFSXferOptions">GnomeVFSXferOptions</link>;
19 enum <link linkend="GnomeVFSXferProgressStatus">GnomeVFSXferProgressStatus</link>;
20 enum <link linkend="GnomeVFSXferOverwriteMode">GnomeVFSXferOverwriteMode</link>;
21 enum <link linkend="GnomeVFSXferOverwriteAction">GnomeVFSXferOverwriteAction</link>;
22 enum <link linkend="GnomeVFSXferErrorMode">GnomeVFSXferErrorMode</link>;
23 enum <link linkend="GnomeVFSXferErrorAction">GnomeVFSXferErrorAction</link>;
24 enum <link linkend="GnomeVFSXferPhase">GnomeVFSXferPhase</link>;
25 typedef <link linkend="GnomeVFSXferProgressInfo">GnomeVFSXferProgressInfo</link>;
26 <link linkend="gint">gint</link> (<link linkend="GnomeVFSXferProgressCallback">*GnomeVFSXferProgressCallback</link>) (<link linkend="GnomeVFSXferProgressInfo">GnomeVFSXferProgressInfo</link> *info,
27 <link linkend="gpointer">gpointer</link> data);
28 <link linkend="GnomeVFSResult">GnomeVFSResult</link> <link linkend="gnome-vfs-xfer-uri-list">gnome_vfs_xfer_uri_list</link> (const <link linkend="GList">GList</link> *source_uri_list,
29 const <link linkend="GList">GList</link> *target_uri_list,
30 <link linkend="GnomeVFSXferOptions">GnomeVFSXferOptions</link> xfer_options,
31 <link linkend="GnomeVFSXferErrorMode">GnomeVFSXferErrorMode</link> error_mode,
32 <link linkend="GnomeVFSXferOverwriteMode">GnomeVFSXferOverwriteMode</link> overwrite_mode,
33 <link linkend="GnomeVFSXferProgressCallback">GnomeVFSXferProgressCallback</link> progress_callback,
34 <link linkend="gpointer">gpointer</link> data);
35 <link linkend="GnomeVFSResult">GnomeVFSResult</link> <link linkend="gnome-vfs-xfer-uri">gnome_vfs_xfer_uri</link> (const <link linkend="GnomeVFSURI">GnomeVFSURI</link> *source_uri,
36 const <link linkend="GnomeVFSURI">GnomeVFSURI</link> *target_uri,
37 <link linkend="GnomeVFSXferOptions">GnomeVFSXferOptions</link> xfer_options,
38 <link linkend="GnomeVFSXferErrorMode">GnomeVFSXferErrorMode</link> error_mode,
39 <link linkend="GnomeVFSXferOverwriteMode">GnomeVFSXferOverwriteMode</link> overwrite_mode,
40 <link linkend="GnomeVFSXferProgressCallback">GnomeVFSXferProgressCallback</link> progress_callback,
41 <link linkend="gpointer">gpointer</link> data);
42 <link linkend="GnomeVFSResult">GnomeVFSResult</link> <link linkend="gnome-vfs-xfer-delete-list">gnome_vfs_xfer_delete_list</link> (const <link linkend="GList">GList</link> *source_uri_list,
43 <link linkend="GnomeVFSXferErrorMode">GnomeVFSXferErrorMode</link> error_mode,
44 <link linkend="GnomeVFSXferOptions">GnomeVFSXferOptions</link> xfer_options,
45 <link linkend="GnomeVFSXferProgressCallback">GnomeVFSXferProgressCallback</link> progress_callback,
46 <link linkend="gpointer">gpointer</link> data);
59 <title>Description</title>
66 <title>Details</title>
68 <title><anchor id="GnomeVFSXferOptions"/>enum GnomeVFSXferOptions</title>
69 <indexterm><primary>GnomeVFSXferOptions</primary></indexterm><programlisting>typedef enum {
70 GNOME_VFS_XFER_DEFAULT = 0,
71 GNOME_VFS_XFER_UNUSED_1 = 1 << 0,
72 GNOME_VFS_XFER_FOLLOW_LINKS = 1 << 1,
73 GNOME_VFS_XFER_UNUSED_2 = 1 << 2,
74 GNOME_VFS_XFER_RECURSIVE = 1 << 3,
75 GNOME_VFS_XFER_SAMEFS = 1 << 4,
76 GNOME_VFS_XFER_DELETE_ITEMS = 1 << 5,
77 GNOME_VFS_XFER_EMPTY_DIRECTORIES = 1 << 6,
78 GNOME_VFS_XFER_NEW_UNIQUE_DIRECTORY = 1 << 7,
79 GNOME_VFS_XFER_REMOVESOURCE = 1 << 8,
80 GNOME_VFS_XFER_USE_UNIQUE_NAMES = 1 << 9,
81 GNOME_VFS_XFER_LINK_ITEMS = 1 << 10,
82 GNOME_VFS_XFER_FOLLOW_LINKS_RECURSIVE = 1 << 11
83 } GnomeVFSXferOptions;
89 <title><anchor id="GnomeVFSXferProgressStatus"/>enum GnomeVFSXferProgressStatus</title>
90 <indexterm><primary>GnomeVFSXferProgressStatus</primary></indexterm><programlisting>typedef enum {
91 GNOME_VFS_XFER_PROGRESS_STATUS_OK = 0,
92 GNOME_VFS_XFER_PROGRESS_STATUS_VFSERROR = 1,
93 GNOME_VFS_XFER_PROGRESS_STATUS_OVERWRITE = 2,
94 /* during the duplicate status the progress callback is asked to
95 supply a new unique name */
96 GNOME_VFS_XFER_PROGRESS_STATUS_DUPLICATE = 3
97 } GnomeVFSXferProgressStatus;
103 <title><anchor id="GnomeVFSXferOverwriteMode"/>enum GnomeVFSXferOverwriteMode</title>
104 <indexterm><primary>GnomeVFSXferOverwriteMode</primary></indexterm><programlisting>typedef enum {
105 /* Interrupt transferring with an error (GNOME_VFS_ERROR_FILEEXISTS). */
106 GNOME_VFS_XFER_OVERWRITE_MODE_ABORT = 0,
107 /* Invoke the progress callback with a
108 `GNOME_VFS_XFER_PROGRESS_STATUS_OVERWRITE' status code. */
109 GNOME_VFS_XFER_OVERWRITE_MODE_QUERY = 1,
110 /* Overwrite files silently. */
111 GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE = 2,
112 /* Ignore files silently. */
113 GNOME_VFS_XFER_OVERWRITE_MODE_SKIP = 3
114 } GnomeVFSXferOverwriteMode;
120 <title><anchor id="GnomeVFSXferOverwriteAction"/>enum GnomeVFSXferOverwriteAction</title>
121 <indexterm><primary>GnomeVFSXferOverwriteAction</primary></indexterm><programlisting>typedef enum {
122 GNOME_VFS_XFER_OVERWRITE_ACTION_ABORT = 0,
123 GNOME_VFS_XFER_OVERWRITE_ACTION_REPLACE = 1,
124 GNOME_VFS_XFER_OVERWRITE_ACTION_REPLACE_ALL = 2,
125 GNOME_VFS_XFER_OVERWRITE_ACTION_SKIP = 3,
126 GNOME_VFS_XFER_OVERWRITE_ACTION_SKIP_ALL = 4
127 } GnomeVFSXferOverwriteAction;
130 This defines the actions to perform before a file is being overwritten
131 (i.e., these are the answers that can be given to a replace query).</para>
134 </para><variablelist role="enum">
136 <term><literal>GNOME_VFS_XFER_OVERWRITE_ACTION_ABORT</literal></term>
137 <listitem><simpara> abort the transfer
138 </simpara></listitem>
141 <term><literal>GNOME_VFS_XFER_OVERWRITE_ACTION_REPLACE</literal></term>
142 <listitem><simpara> replace the existing file
143 </simpara></listitem>
146 <term><literal>GNOME_VFS_XFER_OVERWRITE_ACTION_REPLACE_ALL</literal></term>
147 <listitem><simpara> replace the existing file, and all future files
148 without prompting the callback.
149 </simpara></listitem>
152 <term><literal>GNOME_VFS_XFER_OVERWRITE_ACTION_SKIP</literal></term>
153 <listitem><simpara> don't copy over the existing file
154 </simpara></listitem>
157 <term><literal>GNOME_VFS_XFER_OVERWRITE_ACTION_SKIP_ALL</literal></term>
158 <listitem><simpara> don't copy over the existing file, and all future
159 files without prompting the callback.
160 </simpara></listitem>
162 </variablelist></refsect2>
164 <title><anchor id="GnomeVFSXferErrorMode"/>enum GnomeVFSXferErrorMode</title>
165 <indexterm><primary>GnomeVFSXferErrorMode</primary></indexterm><programlisting>typedef enum {
166 /* Interrupt transferring with an error (code returned is code of the
167 operation that has caused the error). */
168 GNOME_VFS_XFER_ERROR_MODE_ABORT = 0,
169 /* Invoke the progress callback with a
170 `GNOME_VFS_XFER_PROGRESS_STATUS_VFSERROR' status code. */
171 GNOME_VFS_XFER_ERROR_MODE_QUERY = 1
172 } GnomeVFSXferErrorMode;
178 <title><anchor id="GnomeVFSXferErrorAction"/>enum GnomeVFSXferErrorAction</title>
179 <indexterm><primary>GnomeVFSXferErrorAction</primary></indexterm><programlisting>typedef enum {
180 /* Interrupt operation and return `GNOME_VFS_ERROR_INTERRUPTED'. */
181 GNOME_VFS_XFER_ERROR_ACTION_ABORT = 0,
182 /* Try the same operation again. */
183 GNOME_VFS_XFER_ERROR_ACTION_RETRY = 1,
184 /* Skip this file and continue normally. */
185 GNOME_VFS_XFER_ERROR_ACTION_SKIP = 2
186 } GnomeVFSXferErrorAction;
192 <title><anchor id="GnomeVFSXferPhase"/>enum GnomeVFSXferPhase</title>
193 <indexterm><primary>GnomeVFSXferPhase</primary></indexterm><programlisting>typedef enum {
195 GNOME_VFS_XFER_PHASE_INITIAL,
196 /* Checking if destination can handle move/copy */
197 GNOME_VFS_XFER_CHECKING_DESTINATION,
198 /* Collecting file list */
199 GNOME_VFS_XFER_PHASE_COLLECTING,
200 /* File list collected (*) */
201 GNOME_VFS_XFER_PHASE_READYTOGO,
202 /* Opening source file for reading */
203 GNOME_VFS_XFER_PHASE_OPENSOURCE,
204 /* Creating target file for copy */
205 GNOME_VFS_XFER_PHASE_OPENTARGET,
206 /* Copying data from source to target (*) */
207 GNOME_VFS_XFER_PHASE_COPYING,
208 /* Moving file from source to target (*) */
209 GNOME_VFS_XFER_PHASE_MOVING,
210 /* Reading data from source file */
211 GNOME_VFS_XFER_PHASE_READSOURCE,
212 /* Writing data to target file */
213 GNOME_VFS_XFER_PHASE_WRITETARGET,
214 /* Closing source file */
215 GNOME_VFS_XFER_PHASE_CLOSESOURCE,
216 /* Closing target file */
217 GNOME_VFS_XFER_PHASE_CLOSETARGET,
218 /* Deleting source file */
219 GNOME_VFS_XFER_PHASE_DELETESOURCE,
220 /* Setting attributes on target file */
221 GNOME_VFS_XFER_PHASE_SETATTRIBUTES,
222 /* Go to the next file (*) */
223 GNOME_VFS_XFER_PHASE_FILECOMPLETED,
224 /* cleaning up after a move (removing source files, etc.) */
225 GNOME_VFS_XFER_PHASE_CLEANUP,
226 /* Operation finished (*) */
227 GNOME_VFS_XFER_PHASE_COMPLETED,
228 GNOME_VFS_XFER_NUM_PHASES
235 <title><anchor id="GnomeVFSXferProgressInfo"/>GnomeVFSXferProgressInfo</title>
236 <indexterm><primary>GnomeVFSXferProgressInfo</primary></indexterm><programlisting>typedef struct {
237 /* Progress status (see above for a description). */
238 GnomeVFSXferProgressStatus status;
240 /* VFS status code. If `status' is
241 `GNOME_VFS_XFER_PROGRESS_STATUS_VFSERROR', you should look at this
242 member to know what has happened. */
243 GnomeVFSResult vfs_status;
245 /* Current phase in the transferring process. */
246 GnomeVFSXferPhase phase;
248 /* Source URI. FIXME bugzilla.eazel.com 1206: change name? */
251 /* Destination URI. FIXME bugzilla.eazel.com 1206: change name? */
254 /* Index of file being copied. */
257 /* Total number of files to be copied. */
260 /* Total number of bytes to be copied. */
261 GnomeVFSFileSize bytes_total;
263 /* Total size of this file (in bytes). */
264 GnomeVFSFileSize file_size;
266 /* Bytes copied for this file so far. */
267 GnomeVFSFileSize bytes_copied;
269 /* Total amount of data copied from the beginning. */
270 GnomeVFSFileSize total_bytes_copied;
272 /* Target unique name used when duplicating, etc. to avoid collisions */
273 gchar *duplicate_name;
275 /* Count used in the unique name e.g. (copy 2), etc. */
278 gboolean top_level_item;
279 /* indicates that the copied/moved/deleted item is an actual item
280 * passed in the uri list rather than one encountered by recursively
281 * traversing directories. Used by metadata copying.
284 /* Reserved for future expansions to GnomeVFSXferProgressInfo
285 * without having to break ABI compatibility */
289 } GnomeVFSXferProgressInfo;
295 <title><anchor id="GnomeVFSXferProgressCallback"/>GnomeVFSXferProgressCallback ()</title>
296 <indexterm><primary>GnomeVFSXferProgressCallback</primary></indexterm><programlisting><link linkend="gint">gint</link> (*GnomeVFSXferProgressCallback) (<link linkend="GnomeVFSXferProgressInfo">GnomeVFSXferProgressInfo</link> *info,
297 <link linkend="gpointer">gpointer</link> data);</programlisting>
300 </para><variablelist role="params">
301 <varlistentry><term><parameter>info</parameter> :</term>
303 </simpara></listitem></varlistentry>
304 <varlistentry><term><parameter>data</parameter> :</term>
306 </simpara></listitem></varlistentry>
307 <varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara>
310 </simpara></listitem></varlistentry>
311 </variablelist></refsect2>
313 <title><anchor id="gnome-vfs-xfer-uri-list"/>gnome_vfs_xfer_uri_list ()</title>
314 <indexterm><primary>gnome_vfs_xfer_uri_list</primary></indexterm><programlisting><link linkend="GnomeVFSResult">GnomeVFSResult</link> gnome_vfs_xfer_uri_list (const <link linkend="GList">GList</link> *source_uri_list,
315 const <link linkend="GList">GList</link> *target_uri_list,
316 <link linkend="GnomeVFSXferOptions">GnomeVFSXferOptions</link> xfer_options,
317 <link linkend="GnomeVFSXferErrorMode">GnomeVFSXferErrorMode</link> error_mode,
318 <link linkend="GnomeVFSXferOverwriteMode">GnomeVFSXferOverwriteMode</link> overwrite_mode,
319 <link linkend="GnomeVFSXferProgressCallback">GnomeVFSXferProgressCallback</link> progress_callback,
320 <link linkend="gpointer">gpointer</link> data);</programlisting>
322 This function will transfer multiple files to a multiple targets. Given a
323 a source uri(s) and a destination uri(s). There are a list of options that
324 your application can use to control how the transfer is done.</para>
327 </para><variablelist role="params">
328 <varlistentry><term><parameter>source_uri_list</parameter> :</term>
329 <listitem><simpara> A Glist of uris (ie file;//)
330 </simpara></listitem></varlistentry>
331 <varlistentry><term><parameter>target_uri_list</parameter> :</term>
332 <listitem><simpara> A GList of uris
333 </simpara></listitem></varlistentry>
334 <varlistentry><term><parameter>xfer_options</parameter> :</term>
335 <listitem><simpara> These are options you wish to set for the transfer. For
336 instance by setting the xfer behavior you can either make a copy or a
338 </simpara></listitem></varlistentry>
339 <varlistentry><term><parameter>error_mode</parameter> :</term>
340 <listitem><simpara> Decide how to behave if the xfer is interrupted. For instance
341 you could set your application to return an error code in case of an
343 </simpara></listitem></varlistentry>
344 <varlistentry><term><parameter>overwrite_mode</parameter> :</term>
345 <listitem><simpara> How to react if a file your copying is being overwritten.
346 </simpara></listitem></varlistentry>
347 <varlistentry><term><parameter>progress_callback</parameter> :</term>
348 <listitem><simpara> This is used to monitor the progress of a transfer.
349 Common use would be to check to see if the transfer is asking for permission
351 </simpara></listitem></varlistentry>
352 <varlistentry><term><parameter>data</parameter> :</term>
353 <listitem><simpara> Data to be want passed back in callbacks from the xfer engine
354 </simpara></listitem></varlistentry>
355 <varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> If all goes well it returns GNOME_VFS_OK. Check GnomeVFSResult for
357 </simpara></listitem></varlistentry>
358 </variablelist></refsect2>
360 <title><anchor id="gnome-vfs-xfer-uri"/>gnome_vfs_xfer_uri ()</title>
361 <indexterm><primary>gnome_vfs_xfer_uri</primary></indexterm><programlisting><link linkend="GnomeVFSResult">GnomeVFSResult</link> gnome_vfs_xfer_uri (const <link linkend="GnomeVFSURI">GnomeVFSURI</link> *source_uri,
362 const <link linkend="GnomeVFSURI">GnomeVFSURI</link> *target_uri,
363 <link linkend="GnomeVFSXferOptions">GnomeVFSXferOptions</link> xfer_options,
364 <link linkend="GnomeVFSXferErrorMode">GnomeVFSXferErrorMode</link> error_mode,
365 <link linkend="GnomeVFSXferOverwriteMode">GnomeVFSXferOverwriteMode</link> overwrite_mode,
366 <link linkend="GnomeVFSXferProgressCallback">GnomeVFSXferProgressCallback</link> progress_callback,
367 <link linkend="gpointer">gpointer</link> data);</programlisting>
369 This function will allow a person to copy data from one location to another.
370 The location is specified using a URIs as the means to describe the location
371 of the data. Like any copy there are several options that can be set.
372 These can be set using the xfer_options. In addition there are callback
373 mechanisms and error codes to provide feedback in the copy
377 </para><variablelist role="params">
378 <varlistentry><term><parameter>source_uri</parameter> :</term>
379 <listitem><simpara> This is the location of where your data resides.
380 </simpara></listitem></varlistentry>
381 <varlistentry><term><parameter>target_uri</parameter> :</term>
382 <listitem><simpara> This is the location of where you want your data to go.
383 </simpara></listitem></varlistentry>
384 <varlistentry><term><parameter>xfer_options</parameter> :</term>
385 <listitem><simpara> Set the kind of transfers you want. These are:
386 GNOME_VFS_XFER_DEFAULT: Default behavior. Which is to do a straight one to
388 GNOME_VFS_XFER_FOLLOW_LINKS: This means follow the value of the symbolic
389 link when copying. (ie treat a symbolic link as a directory)
390 GNOME_VFS_RECURSIVE: Do a recursive copy of the source to the destination.
391 Equivalent to the cp -r option in GNU cp.
392 GNOME_VFS_XFER_SAME_FS: This only allows copying onto the same filesystem.
393 GNOME_VFS_DELETE_ITEM: This is equivalent to a mv. Where you will copy the
394 contents of the source to the destination and then remove data from the
396 GNOME_VFS_XFER_EMPTY_DIRECTORIES: <TBA>
397 GNOME_VFS_XFER_NEW_UNIQUE_DIRECTORY: This will create a directory if it
398 doesn't exist in the destination area. Useful with the
399 GNOME_VFS_XFER_RECURSIVE xfer option.
400 GNOME_VFS_XFER_REMOVESOURCE: This option will remove the source data after
401 whatever xfer option has been taken.
402 GNOME_VFS_USE_UNIQUE_NAMES: This is a check ot make sure that what you copy
403 onto the destination is not overwritten. It will only copy the unique items
404 from the source to the destjnation.
405 GNOME_VFS_XFER_LINK_ITEMS: <TBA>
406 </simpara></listitem></varlistentry>
407 <varlistentry><term><parameter>error_mode</parameter> :</term>
408 <listitem><simpara> When this function returns you need to check the error code
409 for the results of the copy. The results are generally:
410 GNOME_VFS_XFER_ERROR_MODE_ABORT: This means that the operation was aborted
411 by some sort of signal that interrupted the transfer.
412 GNOME_VFS_ERROR_MODE_QUERY: This means that no error has occured and that
413 you should query with the GNOME_VFS_XFER_PROGRESS_STATUS_VFSERROR. See
414 </simpara></listitem></varlistentry>
415 <varlistentry><term><parameter>overwrite_mode</parameter> :</term>
416 <listitem><simpara> This sets the options to deal with data that are duplicate
417 between the source and the destination. Your choices are:
418 GNOME_VFS_XFER_OVERWRITE_MODE_ABORT: This means abort the transfer if you
420 GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE: Replace the files silently. Don't
422 GNOME_VFS_XFER_OVERWRITE_MODE_SKIP: Skip duplicate files silenty.
424 </simpara></listitem></varlistentry>
425 <varlistentry><term><parameter>progress_callback</parameter> :</term>
426 <listitem><simpara> This is an important call back because this is how you
427 communicate with your copy process.
428 </simpara></listitem></varlistentry>
429 <varlistentry><term><parameter>data</parameter> :</term>
430 <listitem><simpara> Data to be want passed back in callbacks from the xfer engine
431 </simpara></listitem></varlistentry>
432 <varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> An integer representing the result of the operation.
434 </simpara></listitem></varlistentry>
435 </variablelist></refsect2>
437 <title><anchor id="gnome-vfs-xfer-delete-list"/>gnome_vfs_xfer_delete_list ()</title>
438 <indexterm><primary>gnome_vfs_xfer_delete_list</primary></indexterm><programlisting><link linkend="GnomeVFSResult">GnomeVFSResult</link> gnome_vfs_xfer_delete_list (const <link linkend="GList">GList</link> *source_uri_list,
439 <link linkend="GnomeVFSXferErrorMode">GnomeVFSXferErrorMode</link> error_mode,
440 <link linkend="GnomeVFSXferOptions">GnomeVFSXferOptions</link> xfer_options,
441 <link linkend="GnomeVFSXferProgressCallback">GnomeVFSXferProgressCallback</link> progress_callback,
442 <link linkend="gpointer">gpointer</link> data);</programlisting>
444 Unlink items in the list <parameter>source_uri_list</parameter> from their filesystems.</para>
447 </para><variablelist role="params">
448 <varlistentry><term><parameter>source_uri_list</parameter> :</term>
449 <listitem><simpara> This is a list containing uris
450 </simpara></listitem></varlistentry>
451 <varlistentry><term><parameter>error_mode</parameter> :</term>
452 <listitem><simpara> Decide how you want to deal with interruptions
453 </simpara></listitem></varlistentry>
454 <varlistentry><term><parameter>xfer_options</parameter> :</term>
455 <listitem><simpara> Set whatever transfer options you need.
456 </simpara></listitem></varlistentry>
457 <varlistentry><term><parameter>progress_callback</parameter> :</term>
458 <listitem><simpara> Callback to check on progress of transfer.
459 </simpara></listitem></varlistentry>
460 <varlistentry><term><parameter>data</parameter> :</term>
461 <listitem><simpara> Data to be want passed back in callbacks from the xfer engine
462 </simpara></listitem></varlistentry>
463 <varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> <literal>GNOME_VFS_OK</literal> if successful, or the appropriate error code otherwise
464 </simpara></listitem></varlistentry>
465 </variablelist></refsect2>