root/src/filemanager/fileopctx.c

/* [previous][next][first][last][top][bottom][index][help]  */

DEFINITIONS

This source file includes following definitions.
  1. file_op_context_new
  2. file_op_context_destroy
  3. file_op_total_context_new
  4. file_op_total_context_destroy

   1 /*
   2    File operation contexts for the Midnight Commander
   3 
   4    Copyright (C) 1999-2024
   5    Free Software Foundation, Inc.
   6 
   7    Written by:
   8    Federico Mena <federico@nuclecu.unam.mx>
   9    Miguel de Icaza <miguel@nuclecu.unam.mx>
  10 
  11    This file is part of the Midnight Commander.
  12 
  13    The Midnight Commander is free software: you can redistribute it
  14    and/or modify it under the terms of the GNU General Public License as
  15    published by the Free Software Foundation, either version 3 of the License,
  16    or (at your option) any later version.
  17 
  18    The Midnight Commander is distributed in the hope that it will be useful,
  19    but WITHOUT ANY WARRANTY; without even the implied warranty of
  20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21    GNU General Public License for more details.
  22 
  23    You should have received a copy of the GNU General Public License
  24    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  25  */
  26 
  27 /** \file fileopctx.c
  28  *  \brief Source: file operation contexts
  29  *  \date 1998-2007
  30  *  \author Federico Mena <federico@nuclecu.unam.mx>
  31  *  \author Miguel de Icaza <miguel@nuclecu.unam.mx>
  32  */
  33 
  34 #include <config.h>
  35 
  36 #include <unistd.h>
  37 
  38 #include "lib/global.h"
  39 #include "fileopctx.h"
  40 #include "filegui.h"
  41 #include "lib/search.h"
  42 #include "lib/vfs/vfs.h"
  43 
  44 /*** global variables ****************************************************************************/
  45 
  46 /*** file scope macro definitions ****************************************************************/
  47 
  48 /*** file scope type declarations ****************************************************************/
  49 
  50 /*** file scope variables ************************************************************************/
  51 
  52 /*** file scope functions ************************************************************************/
  53 /* --------------------------------------------------------------------------------------------- */
  54 
  55 /* --------------------------------------------------------------------------------------------- */
  56 /*** public functions ****************************************************************************/
  57 /* --------------------------------------------------------------------------------------------- */
  58 
  59 /**
  60  * \fn file_op_context_t * file_op_context_new (FileOperation op)
  61  * \param op file operation struct
  62  * \return The newly-created context, filled with the default file mask values.
  63  *
  64  * Creates a new file operation context with the default values.  If you later want
  65  * to have a user interface for this, call file_op_context_create_ui().
  66  */
  67 
  68 file_op_context_t *
  69 file_op_context_new (FileOperation op)
     /* [previous][next][first][last][top][bottom][index][help]  */
  70 {
  71     file_op_context_t *ctx;
  72 
  73     ctx = g_new0 (file_op_context_t, 1);
  74     ctx->operation = op;
  75     ctx->eta_secs = 0.0;
  76     ctx->progress_bytes = 0;
  77     ctx->do_reget = -1;
  78     ctx->stat_func = mc_lstat;
  79     ctx->preserve = TRUE;
  80     ctx->preserve_uidgid = (geteuid () == 0);
  81     ctx->umask_kill = (mode_t) (~0);
  82     ctx->erase_at_end = TRUE;
  83     ctx->ignore_all = FALSE;
  84 
  85     return ctx;
  86 }
  87 
  88 /* --------------------------------------------------------------------------------------------- */
  89 /**
  90  * \fn void file_op_context_destroy (file_op_context_t *ctx)
  91  * \param ctx The file operation context to destroy.
  92  *
  93  * Destroys the specified file operation context and its associated UI data, if
  94  * it exists.
  95  */
  96 
  97 void
  98 file_op_context_destroy (file_op_context_t *ctx)
     /* [previous][next][first][last][top][bottom][index][help]  */
  99 {
 100     if (ctx != NULL)
 101     {
 102         file_op_context_destroy_ui (ctx);
 103         mc_search_free (ctx->search_handle);
 104         g_free (ctx);
 105     }
 106 }
 107 
 108 /* --------------------------------------------------------------------------------------------- */
 109 
 110 file_op_total_context_t *
 111 file_op_total_context_new (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 112 {
 113     file_op_total_context_t *tctx;
 114     tctx = g_new0 (file_op_total_context_t, 1);
 115     tctx->ask_overwrite = TRUE;
 116     return tctx;
 117 }
 118 
 119 /* --------------------------------------------------------------------------------------------- */
 120 
 121 void
 122 file_op_total_context_destroy (file_op_total_context_t *tctx)
     /* [previous][next][first][last][top][bottom][index][help]  */
 123 {
 124     g_free (tctx);
 125 }
 126 
 127 /* --------------------------------------------------------------------------------------------- */

/* [previous][next][first][last][top][bottom][index][help]  */