From ffccd5b2b05243e7976db80f90f453dccfae9886 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 22:22:03 +0200 Subject: Adding upstream version 3:4.8.30. Signed-off-by: Daniel Baumann --- src/filemanager/fileopctx.c | 128 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 src/filemanager/fileopctx.c (limited to 'src/filemanager/fileopctx.c') diff --git a/src/filemanager/fileopctx.c b/src/filemanager/fileopctx.c new file mode 100644 index 0000000..a118749 --- /dev/null +++ b/src/filemanager/fileopctx.c @@ -0,0 +1,128 @@ +/* + File operation contexts for the Midnight Commander + + Copyright (C) 1999-2023 + Free Software Foundation, Inc. + + Written by: + Federico Mena + Miguel de Icaza + + This file is part of the Midnight Commander. + + The Midnight Commander is free software: you can redistribute it + and/or modify it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + The Midnight Commander is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +/** \file fileopctx.c + * \brief Source: file operation contexts + * \date 1998-2007 + * \author Federico Mena + * \author Miguel de Icaza + */ + +#include + +#include + +#include "lib/global.h" +#include "fileopctx.h" +#include "filegui.h" +#include "lib/search.h" +#include "lib/vfs/vfs.h" + +/*** global variables ****************************************************************************/ + +/*** file scope macro definitions ****************************************************************/ + +/*** file scope type declarations ****************************************************************/ + +/*** file scope variables ************************************************************************/ + +/*** file scope functions ************************************************************************/ +/* --------------------------------------------------------------------------------------------- */ + +/* --------------------------------------------------------------------------------------------- */ +/*** public functions ****************************************************************************/ +/* --------------------------------------------------------------------------------------------- */ + +/** + * \fn file_op_context_t * file_op_context_new (FileOperation op) + * \param op file operation struct + * \return The newly-created context, filled with the default file mask values. + * + * Creates a new file operation context with the default values. If you later want + * to have a user interface for this, call file_op_context_create_ui(). + */ + +file_op_context_t * +file_op_context_new (FileOperation op) +{ + file_op_context_t *ctx; + + ctx = g_new0 (file_op_context_t, 1); + ctx->operation = op; + ctx->eta_secs = 0.0; + ctx->progress_bytes = 0; + ctx->op_preserve = TRUE; + ctx->do_reget = 1; + ctx->stat_func = mc_lstat; + ctx->preserve = TRUE; + ctx->preserve_uidgid = (geteuid () == 0); + ctx->umask_kill = 0777777; + ctx->erase_at_end = TRUE; + ctx->skip_all = FALSE; + + return ctx; +} + +/* --------------------------------------------------------------------------------------------- */ +/** + * \fn void file_op_context_destroy (file_op_context_t *ctx) + * \param ctx The file operation context to destroy. + * + * Destroys the specified file operation context and its associated UI data, if + * it exists. + */ + +void +file_op_context_destroy (file_op_context_t * ctx) +{ + if (ctx != NULL) + { + file_op_context_destroy_ui (ctx); + mc_search_free (ctx->search_handle); + g_free (ctx); + } +} + +/* --------------------------------------------------------------------------------------------- */ + +file_op_total_context_t * +file_op_total_context_new (void) +{ + file_op_total_context_t *tctx; + tctx = g_new0 (file_op_total_context_t, 1); + tctx->ask_overwrite = TRUE; + return tctx; +} + +/* --------------------------------------------------------------------------------------------- */ + +void +file_op_total_context_destroy (file_op_total_context_t * tctx) +{ + g_free (tctx); +} + +/* --------------------------------------------------------------------------------------------- */ -- cgit v1.2.3