Ticket #2776: file selection reset after exit from the archive in the root.
[midnight-commander.git] / src / util.c
blobb500418b108816104cc8cbae1d5ca20bd640afd3
1 /*
2 Various non-library utilities
4 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2011
5 The Free Software Foundation, Inc.
7 Written by:
8 Adam Byrtek, 2003
10 This file is part of the Midnight Commander.
12 The Midnight Commander is free software: you can redistribute it
13 and/or modify it under the terms of the GNU General Public License as
14 published by the Free Software Foundation, either version 3 of the License,
15 or (at your option) any later version.
17 The Midnight Commander is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #include <config.h>
28 #include "lib/global.h"
29 #include "lib/util.h"
31 #include "src/filemanager/file.h"
32 #include "src/filemanager/filegui.h"
34 #include "util.h"
36 /*** global variables ****************************************************************************/
38 /*** file scope macro definitions ****************************************************************/
40 /*** file scope type declarations ****************************************************************/
42 /*** file scope variables ************************************************************************/
44 /*** file scope functions ************************************************************************/
45 /* --------------------------------------------------------------------------------------------- */
47 /* --------------------------------------------------------------------------------------------- */
48 /*** public functions ****************************************************************************/
49 /* --------------------------------------------------------------------------------------------- */
51 int
52 check_for_default (const vfs_path_t * default_file_vpath, const vfs_path_t * file_vpath)
54 char *file, *default_file;
56 file = vfs_path_to_str (file_vpath);
57 default_file = vfs_path_to_str (default_file_vpath);
59 if (!exist_file (file))
61 FileOpContext *ctx;
62 FileOpTotalContext *tctx;
64 if (!exist_file (default_file))
66 g_free (file);
67 g_free (default_file);
68 return -1;
71 ctx = file_op_context_new (OP_COPY);
72 tctx = file_op_total_context_new ();
73 file_op_context_create_ui (ctx, 0, FALSE);
74 copy_file_file (tctx, ctx, default_file, file);
75 file_op_total_context_destroy (tctx);
76 file_op_context_destroy (ctx);
78 g_free (file);
79 g_free (default_file);
81 return 0;
84 /* --------------------------------------------------------------------------------------------- */