Move check_for_default() function from lib/util.c to src/util.c
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
Этот коммит содержится в:
родитель
7dad2df6a8
Коммит
c58365fa64
27
lib/util.c
27
lib/util.c
@ -48,9 +48,6 @@
|
|||||||
#include "lib/strutil.h"
|
#include "lib/strutil.h"
|
||||||
#include "lib/util.h"
|
#include "lib/util.h"
|
||||||
|
|
||||||
#include "src/filemanager/filegui.h"
|
|
||||||
#include "src/filemanager/file.h" /* copy_file_file() */
|
|
||||||
|
|
||||||
/*** global variables ****************************************************************************/
|
/*** global variables ****************************************************************************/
|
||||||
|
|
||||||
/*** file scope macro definitions ****************************************************************/
|
/*** 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 *
|
char *
|
||||||
load_mc_home_file (const char *from, const char *filename, char **allocated_filename)
|
load_mc_home_file (const char *from, const char *filename, char **allocated_filename)
|
||||||
{
|
{
|
||||||
|
@ -122,9 +122,6 @@ void init_uid_gid_cache (void);
|
|||||||
char *get_group (int);
|
char *get_group (int);
|
||||||
char *get_owner (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 */
|
/* Returns a copy of *s until a \n is found and is below top */
|
||||||
const char *extract_line (const char *s, const char *top);
|
const char *extract_line (const char *s, const char *top);
|
||||||
|
|
||||||
|
@ -69,7 +69,8 @@ mc_SOURCES = \
|
|||||||
main.c main.h \
|
main.c main.h \
|
||||||
setup.c setup.h \
|
setup.c setup.h \
|
||||||
subshell.c subshell.h \
|
subshell.c subshell.h \
|
||||||
textconf.c textconf.h
|
textconf.c textconf.h \
|
||||||
|
util.c util.h
|
||||||
|
|
||||||
if CHARSET
|
if CHARSET
|
||||||
mc_SOURCES += selcodepage.c selcodepage.h
|
mc_SOURCES += selcodepage.c selcodepage.h
|
||||||
|
@ -65,6 +65,7 @@
|
|||||||
#include "src/selcodepage.h"
|
#include "src/selcodepage.h"
|
||||||
#include "src/keybind-defaults.h"
|
#include "src/keybind-defaults.h"
|
||||||
#include "src/clipboard.h" /* copy_file_to_ext_clip, paste_to_file_from_ext_clip */
|
#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-impl.h"
|
||||||
#include "edit-widget.h"
|
#include "edit-widget.h"
|
||||||
|
@ -65,6 +65,7 @@
|
|||||||
#include "src/setup.h"
|
#include "src/setup.h"
|
||||||
#include "src/execute.h" /* toggle_panels() */
|
#include "src/execute.h" /* toggle_panels() */
|
||||||
#include "src/history.h"
|
#include "src/history.h"
|
||||||
|
#include "src/util.h" /* check_for_default() */
|
||||||
|
|
||||||
#ifdef USE_INTERNAL_EDIT
|
#ifdef USE_INTERNAL_EDIT
|
||||||
#include "src/editor/edit.h"
|
#include "src/editor/edit.h"
|
||||||
|
72
src/util.c
Обычный файл
72
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 <config.h>
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
20
src/util.h
Обычный файл
20
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 */
|
||||||
|
|
Загрузка…
x
Ссылка в новой задаче
Block a user