mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 12:32:40 +03:00
(check_for_default): minor optimization and change return value.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
8ac2c68d3f
commit
a9ff27db05
16
src/util.c
16
src/util.c
@ -48,24 +48,25 @@
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
gboolean
|
||||
check_for_default (const vfs_path_t * default_file_vpath, const vfs_path_t * file_vpath)
|
||||
{
|
||||
char *file, *default_file;
|
||||
char *file;
|
||||
|
||||
file = vfs_path_to_str (file_vpath);
|
||||
default_file = vfs_path_to_str (default_file_vpath);
|
||||
|
||||
if (!exist_file (file))
|
||||
{
|
||||
char *default_file;
|
||||
FileOpContext *ctx;
|
||||
FileOpTotalContext *tctx;
|
||||
|
||||
default_file = vfs_path_to_str (default_file_vpath);
|
||||
if (!exist_file (default_file))
|
||||
{
|
||||
g_free (file);
|
||||
g_free (default_file);
|
||||
return -1;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ctx = file_op_context_new (OP_COPY);
|
||||
@ -74,11 +75,12 @@ check_for_default (const vfs_path_t * default_file_vpath, const vfs_path_t * fil
|
||||
copy_file_file (tctx, ctx, default_file, file);
|
||||
file_op_total_context_destroy (tctx);
|
||||
file_op_context_destroy (ctx);
|
||||
g_free (default_file);
|
||||
}
|
||||
g_free (file);
|
||||
g_free (default_file);
|
||||
|
||||
return 0;
|
||||
g_free (file);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -12,7 +12,7 @@
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
/* Check if the file exists. If not copy the default */
|
||||
int check_for_default (const vfs_path_t * default_file_vpath, const vfs_path_t * file_vpath);
|
||||
gboolean check_for_default (const vfs_path_t * default_file_vpath, const vfs_path_t * file_vpath);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user