(copy_file_file): reduce variable scope, change order of progress update.
[midnight-commander.git] / src / util.c
blob056273c7fe9d740cbdf719b323f1f56ddf7b6ad2
1 /*
2 Various non-library utilities
4 Copyright (C) 2003-2024
5 Free Software Foundation, Inc.
7 Written by:
8 Adam Byrtek, 2003
9 Slava Zanko <slavazanko@gmail.com>, 2013
11 This file is part of the Midnight Commander.
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.
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.
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/>.
27 #include <config.h>
29 #include "lib/global.h"
30 #include "lib/util.h"
32 #include "src/filemanager/file.h"
33 #include "src/filemanager/filegui.h"
35 #include "util.h"
37 /*** global variables ****************************************************************************/
39 /*** file scope macro definitions ****************************************************************/
41 /*** file scope type declarations ****************************************************************/
43 /*** file scope variables ************************************************************************/
45 /*** file scope functions ************************************************************************/
46 /* --------------------------------------------------------------------------------------------- */
48 /* --------------------------------------------------------------------------------------------- */
49 /*** public functions ****************************************************************************/
50 /* --------------------------------------------------------------------------------------------- */
52 gboolean
53 check_for_default (const vfs_path_t *default_file_vpath, const vfs_path_t *file_vpath)
55 if (!exist_file (vfs_path_as_str (file_vpath)))
57 file_op_context_t *ctx;
59 if (!exist_file (vfs_path_as_str (default_file_vpath)))
60 return FALSE;
62 ctx = file_op_context_new (OP_COPY);
63 file_progress_ui_create (ctx, 0, FALSE);
64 copy_file_file (ctx, vfs_path_as_str (default_file_vpath),
65 vfs_path_as_str (file_vpath));
66 file_op_context_destroy (ctx);
69 return TRUE;
72 /* --------------------------------------------------------------------------------------------- */