diff --git a/lib/util.c b/lib/util.c index f72d35832..c70e7e201 100644 --- a/lib/util.c +++ b/lib/util.c @@ -48,9 +48,6 @@ #include "lib/strutil.h" #include "lib/util.h" -#include "src/filemanager/filegui.h" -#include "src/filemanager/file.h" /* copy_file_file() */ - /*** global variables ****************************************************************************/ /*** file scope macro definitions ****************************************************************/ @@ -610,30 +607,6 @@ extension (const char *filename) /* --------------------------------------------------------------------------------------------- */ -int -check_for_default (const char *default_file, const char *file) -{ - if (!exist_file (file)) - { - FileOpContext *ctx; - FileOpTotalContext *tctx; - - if (!exist_file (default_file)) - return -1; - - ctx = file_op_context_new (OP_COPY); - tctx = file_op_total_context_new (); - file_op_context_create_ui (ctx, 0, FALSE); - copy_file_file (tctx, ctx, default_file, file); - file_op_total_context_destroy (tctx); - file_op_context_destroy (ctx); - } - - return 0; -} - -/* --------------------------------------------------------------------------------------------- */ - char * load_mc_home_file (const char *from, const char *filename, char **allocated_filename) { diff --git a/lib/util.h b/lib/util.h index a6aa3a444..ea9dadec5 100644 --- a/lib/util.h +++ b/lib/util.h @@ -122,9 +122,6 @@ void init_uid_gid_cache (void); char *get_group (int); char *get_owner (int); -/* Check if the file exists. If not copy the default */ -int check_for_default (const char *default_file, const char *file); - /* Returns a copy of *s until a \n is found and is below top */ const char *extract_line (const char *s, const char *top); diff --git a/src/Makefile.am b/src/Makefile.am index bf36f7d14..0e10e004e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -69,7 +69,8 @@ mc_SOURCES = \ main.c main.h \ setup.c setup.h \ subshell.c subshell.h \ - textconf.c textconf.h + textconf.c textconf.h \ + util.c util.h if CHARSET mc_SOURCES += selcodepage.c selcodepage.h diff --git a/src/editor/editcmd.c b/src/editor/editcmd.c index 5b05e0b58..8fed62155 100644 --- a/src/editor/editcmd.c +++ b/src/editor/editcmd.c @@ -65,6 +65,7 @@ #include "src/selcodepage.h" #include "src/keybind-defaults.h" #include "src/clipboard.h" /* copy_file_to_ext_clip, paste_to_file_from_ext_clip */ +#include "src/util.h" /* check_for_default() */ #include "edit-impl.h" #include "edit-widget.h" diff --git a/src/filemanager/cmd.c b/src/filemanager/cmd.c index a58ea5f16..27df89ac6 100644 --- a/src/filemanager/cmd.c +++ b/src/filemanager/cmd.c @@ -65,6 +65,7 @@ #include "src/setup.h" #include "src/execute.h" /* toggle_panels() */ #include "src/history.h" +#include "src/util.h" /* check_for_default() */ #ifdef USE_INTERNAL_EDIT #include "src/editor/edit.h" diff --git a/src/util.c b/src/util.c new file mode 100644 index 000000000..14658a138 --- /dev/null +++ b/src/util.c @@ -0,0 +1,72 @@ +/* Various non-library utilities + + Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. + + Authors: 2003 Adam Byrtek + + This program 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 2 of the License, or + (at your option) any later version. + + This program 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, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + */ + + +#include + +#include "lib/global.h" +#include "lib/util.h" + +#include "src/filemanager/file.h" +#include "src/filemanager/filegui.h" + +#include "util.h" + +/*** global variables ****************************************************************************/ + +/*** file scope macro definitions ****************************************************************/ + +/*** file scope type declarations ****************************************************************/ + +/*** file scope variables ************************************************************************/ + +/*** file scope functions ************************************************************************/ +/* --------------------------------------------------------------------------------------------- */ + +/* --------------------------------------------------------------------------------------------- */ +/*** public functions ****************************************************************************/ +/* --------------------------------------------------------------------------------------------- */ + +int +check_for_default (const char *default_file, const char *file) +{ + if (!exist_file (file)) + { + FileOpContext *ctx; + FileOpTotalContext *tctx; + + if (!exist_file (default_file)) + return -1; + + ctx = file_op_context_new (OP_COPY); + tctx = file_op_total_context_new (); + file_op_context_create_ui (ctx, 0, FALSE); + copy_file_file (tctx, ctx, default_file, file); + file_op_total_context_destroy (tctx); + file_op_context_destroy (ctx); + } + + return 0; +} + +/* --------------------------------------------------------------------------------------------- */ diff --git a/src/util.h b/src/util.h new file mode 100644 index 000000000..a94916196 --- /dev/null +++ b/src/util.h @@ -0,0 +1,20 @@ +#ifndef MC_SRC_UTIL_H +#define MC_SRC_UTIL_H + +/*** typedefs(not structures) and defined constants **********************************************/ + +/*** enums ***************************************************************************************/ + +/*** structures declarations (and typedefs of structures)*****************************************/ + +/*** global variables defined in .c file *********************************************************/ + +/*** declarations of public functions ************************************************************/ + +/* Check if the file exists. If not copy the default */ +int check_for_default (const char *default_file, const char *file); + +/*** inline functions ****************************************************************************/ + +#endif /* MC_SRC_UTIL_H */ +