(size_trunc_len): fixed potential integer overflow if SI is used.
[midnight-commander.git] / src / util.c
blob14658a138b1f116298be8ca226964800e66e4dca
1 /* Various non-library utilities
3 Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
5 Authors: 2003 Adam Byrtek
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 02110-1301, USA.
25 #include <config.h>
27 #include "lib/global.h"
28 #include "lib/util.h"
30 #include "src/filemanager/file.h"
31 #include "src/filemanager/filegui.h"
33 #include "util.h"
35 /*** global variables ****************************************************************************/
37 /*** file scope macro definitions ****************************************************************/
39 /*** file scope type declarations ****************************************************************/
41 /*** file scope variables ************************************************************************/
43 /*** file scope functions ************************************************************************/
44 /* --------------------------------------------------------------------------------------------- */
46 /* --------------------------------------------------------------------------------------------- */
47 /*** public functions ****************************************************************************/
48 /* --------------------------------------------------------------------------------------------- */
50 int
51 check_for_default (const char *default_file, const char *file)
53 if (!exist_file (file))
55 FileOpContext *ctx;
56 FileOpTotalContext *tctx;
58 if (!exist_file (default_file))
59 return -1;
61 ctx = file_op_context_new (OP_COPY);
62 tctx = file_op_total_context_new ();
63 file_op_context_create_ui (ctx, 0, FALSE);
64 copy_file_file (tctx, ctx, default_file, file);
65 file_op_total_context_destroy (tctx);
66 file_op_context_destroy (ctx);
69 return 0;
72 /* --------------------------------------------------------------------------------------------- */