*** empty log message ***
[midnight-commander.git] / src / fileopctx.c
blob5ee6637965da53a2c1bcca1e371b2f2215196790
1 /* File operation contexts for the Midnight Commander
3 * Copyright (C) 1998 The Free Software Foundation
5 * Authors: Federico Mena <federico@nuclecu.unam.mx>
6 * Miguel de Icaza <miguel@nuclecu.unam.mx>
7 */
9 #include <config.h>
10 #include <unistd.h>
12 #include "global.h"
13 #include "fileopctx.h"
14 #include "../vfs/vfs.h"
17 /**
18 * file_op_context_new:
20 * Creates a new file operation context with the default values. If you later want
21 * to have a user interface for this, call #file_op_context_create_ui().
23 * Return value: The newly-created context, filled with the default file mask values.
24 **/
25 FileOpContext *
26 file_op_context_new (void)
28 FileOpContext *ctx;
30 ctx = g_new0 (FileOpContext, 1);
31 ctx->eta_secs = 0.0;
32 ctx->progress_bytes = 0.0;
33 ctx->op_preserve = TRUE;
34 ctx->do_reget = TRUE;
35 ctx->stat_func = (mc_stat_fn) mc_lstat;
36 ctx->preserve = TRUE;
37 ctx->preserve_uidgid = (geteuid () == 0) ? TRUE : FALSE;
38 ctx->umask_kill = 0777777;
39 ctx->erase_at_end = TRUE;
41 return ctx;
45 /**
46 * file_op_context_destroy:
47 * @ctx: The file operation context to destroy.
49 * Destroys the specified file operation context and its associated UI data, if
50 * it exists.
51 **/
52 void
53 file_op_context_destroy (FileOpContext *ctx)
55 g_return_if_fail (ctx != NULL);
57 if (ctx->ui)
58 file_op_context_destroy_ui (ctx);
60 /* FIXME: do we need to free ctx->dest_mask? */
62 g_free (ctx);