(check_for_default): minor optimization and change return value.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2012-04-03 16:32:23 +04:00 committed by Slava Zanko
parent 8ac2c68d3f
commit a9ff27db05
2 changed files with 10 additions and 8 deletions

View File

@ -48,24 +48,25 @@
/*** public functions ****************************************************************************/ /*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
int gboolean
check_for_default (const vfs_path_t * default_file_vpath, const vfs_path_t * file_vpath) 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); file = vfs_path_to_str (file_vpath);
default_file = vfs_path_to_str (default_file_vpath);
if (!exist_file (file)) if (!exist_file (file))
{ {
char *default_file;
FileOpContext *ctx; FileOpContext *ctx;
FileOpTotalContext *tctx; FileOpTotalContext *tctx;
default_file = vfs_path_to_str (default_file_vpath);
if (!exist_file (default_file)) if (!exist_file (default_file))
{ {
g_free (file); g_free (file);
g_free (default_file); g_free (default_file);
return -1; return FALSE;
} }
ctx = file_op_context_new (OP_COPY); 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); copy_file_file (tctx, ctx, default_file, file);
file_op_total_context_destroy (tctx); file_op_total_context_destroy (tctx);
file_op_context_destroy (ctx); file_op_context_destroy (ctx);
g_free (default_file);
} }
g_free (file);
g_free (default_file);
return 0; g_free (file);
return TRUE;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */

View File

@ -12,7 +12,7 @@
/*** declarations of public functions ************************************************************/ /*** declarations of public functions ************************************************************/
/* Check if the file exists. If not copy the default */ /* 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 ****************************************************************************/ /*** inline functions ****************************************************************************/