From cb2ad816f6080416b775a61252805069343b614f Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Wed, 20 Jul 2011 23:12:02 +0300 Subject: [PATCH] changed interface of function mc_setctl() for handle vfs_path_t object as parameter Signed-off-by: Slava Zanko --- lib/vfs/interface.c | 5 +---- lib/vfs/vfs.h | 2 +- src/args.c | 9 +++++++-- src/filemanager/file.c | 33 ++++++++++++++++++++++++--------- src/filemanager/panel.c | 16 +++++++++------- 5 files changed, 42 insertions(+), 23 deletions(-) diff --git a/lib/vfs/interface.c b/lib/vfs/interface.c index 5a1fdd501..4010f6c2c 100644 --- a/lib/vfs/interface.c +++ b/lib/vfs/interface.c @@ -376,14 +376,12 @@ mc_ctl (int handle, int ctlop, void *arg) /* --------------------------------------------------------------------------------------------- */ int -mc_setctl (const char *path, int ctlop, void *arg) +mc_setctl (const vfs_path_t * vpath, int ctlop, void *arg) { int result = -1; - vfs_path_t *vpath; vfs_path_element_t *path_element; - vpath = vfs_path_from_str (path); if (vpath == NULL) vfs_die ("You don't want to pass NULL to mc_setctl."); @@ -393,7 +391,6 @@ mc_setctl (const char *path, int ctlop, void *arg) path_element->class->setctl != NULL ? path_element->class->setctl (vpath, ctlop, arg) : 0; - vfs_path_free (vpath); return result; } diff --git a/lib/vfs/vfs.h b/lib/vfs/vfs.h index 08a499187..2e6f20f8e 100644 --- a/lib/vfs/vfs.h +++ b/lib/vfs/vfs.h @@ -298,7 +298,7 @@ int mc_chown (const char *path, uid_t owner, gid_t group); int mc_chdir (const vfs_path_t * vpath); int mc_unlink (const char *path); int mc_ctl (int fd, int ctlop, void *arg); -int mc_setctl (const char *path, int ctlop, void *arg); +int mc_setctl (const vfs_path_t * vpath, int ctlop, void *arg); int mc_open (const char *filename, int flags, ...); char *mc_get_current_wd (char *buffer, size_t bufsize); char *mc_getlocalcopy (const char *pathname); diff --git a/src/args.c b/src/args.c index c54dd009b..8e58dcaa1 100644 --- a/src/args.c +++ b/src/args.c @@ -611,11 +611,16 @@ mc_setup_by_args (int argc, char **argv, GError ** error) if (mc_args__netfs_logfile != NULL) { + vfs_path_t *vpath; #ifdef ENABLE_VFS_FTP - mc_setctl ("ftp://", VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile); + vpath = vfs_path_from_str ("ftp://"); + mc_setctl (vpath, VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile); + vfs_path_free (vpath); #endif /* ENABLE_VFS_FTP */ #ifdef ENABLE_VFS_SMB - mc_setctl ("smb://", VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile); + vpath = vfs_path_from_str ("smb://"); + mc_setctl (vpath, VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile); + vfs_path_free (vpath); #endif /* ENABLE_VFS_SMB */ } diff --git a/src/filemanager/file.c b/src/filemanager/file.c index 72c71a5ac..faa05d74a 100644 --- a/src/filemanager/file.c +++ b/src/filemanager/file.c @@ -2578,6 +2578,7 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl #define source_with_path source #endif /* !WITH_FULL_PATHS */ char *dest = NULL; + vfs_path_t *dest_vpath = NULL; char *temp = NULL; char *save_cwd = NULL, *save_dest = NULL; struct stat src_stat; @@ -2586,6 +2587,7 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl FileProgressStatus value; FileOpContext *ctx; FileOpTotalContext *tctx; + vfs_path_t *tmp_vpath; gboolean do_bg = FALSE; /* do background operation? */ @@ -2693,6 +2695,7 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl ret_val = FALSE; goto ret_fast; } + dest_vpath = vfs_path_from_str (dest); } else if (confirm_delete) { @@ -2762,8 +2765,13 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl /* If we are the parent */ if (v == 1) { - mc_setctl (panel->cwd, VFS_SETCTL_FORGET, NULL); - mc_setctl (dest, VFS_SETCTL_FORGET, NULL); + tmp_vpath = vfs_path_from_str (panel->cwd); + mc_setctl (tmp_vpath, VFS_SETCTL_FORGET, NULL); + vfs_path_free (tmp_vpath); + + mc_setctl (dest_vpath, VFS_SETCTL_FORGET, NULL); + vfs_path_free (dest_vpath); + g_free (dest); /* file_op_context_destroy (ctx); */ return FALSE; } @@ -2774,11 +2782,13 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl /* We do not want to trash cache every time file is created/touched. However, this will make our cache contain invalid data. */ - if ((dest != NULL) && (mc_setctl (dest, VFS_SETCTL_STALE_DATA, (void *) 1))) + if ((dest != NULL) && (mc_setctl (dest_vpath, VFS_SETCTL_STALE_DATA, (void *) 1))) save_dest = g_strdup (dest); - if ((panel->cwd[0] != '\0') && (mc_setctl (panel->cwd, VFS_SETCTL_STALE_DATA, (void *) 1))) + tmp_vpath = vfs_path_from_str (panel->cwd); + if ((panel->cwd[0] != '\0') && (mc_setctl (tmp_vpath, VFS_SETCTL_STALE_DATA, (void *) 1))) save_cwd = g_strdup (panel->cwd); + vfs_path_free (tmp_vpath); /* Now, let's do the job */ @@ -2834,7 +2844,9 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl g_free (temp); g_free (repl_dest); g_free (dest); + vfs_path_free (dest_vpath); dest = temp2; + dest_vpath = vfs_path_from_str (dest); switch (operation) { @@ -2880,10 +2892,8 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl { int dst_result; struct stat dst_stat; - vfs_path_t *vpath = vfs_path_from_str (dest); - dst_result = mc_stat (vpath, &dst_stat); - vfs_path_free (vpath); + dst_result = mc_stat (dest_vpath, &dst_stat); if ((dst_result != 0) || S_ISDIR (dst_stat.st_mode)) break; @@ -3002,13 +3012,17 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl /* Clean up */ if (save_cwd != NULL) { - mc_setctl (save_cwd, VFS_SETCTL_STALE_DATA, NULL); + tmp_vpath = vfs_path_from_str (save_cwd); + mc_setctl (tmp_vpath, VFS_SETCTL_STALE_DATA, NULL); + vfs_path_free (tmp_vpath); g_free (save_cwd); } if (save_dest != NULL) { - mc_setctl (save_dest, VFS_SETCTL_STALE_DATA, NULL); + tmp_vpath = vfs_path_from_str (save_dest); + mc_setctl (tmp_vpath, VFS_SETCTL_STALE_DATA, NULL); + vfs_path_free (tmp_vpath); g_free (save_dest); } @@ -3018,6 +3032,7 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl g_free (source_with_path); #endif /* WITH_FULL_PATHS */ g_free (dest); + vfs_path_free (dest_vpath); g_free (ctx->dest_mask); ctx->dest_mask = NULL; diff --git a/src/filemanager/panel.c b/src/filemanager/panel.c index 1191ba2f4..e21769206 100644 --- a/src/filemanager/panel.c +++ b/src/filemanager/panel.c @@ -2357,14 +2357,12 @@ do_enter_on_file_entry (file_entry * fe) if (!vfs_current_is_local ()) { - char *tmp, *tmp_curr_dir; int ret; + vfs_path_t *tmp_vpath; - tmp_curr_dir = vfs_get_current_dir (); - tmp = concat_dir_and_file (tmp_curr_dir, fe->fname); - g_free (tmp_curr_dir); - ret = mc_setctl (tmp, VFS_SETCTL_RUN, NULL); - g_free (tmp); + tmp_vpath = vfs_path_append_new (vfs_get_raw_current_dir (), fe->fname, NULL); + ret = mc_setctl (tmp_vpath, VFS_SETCTL_RUN, NULL); + vfs_path_free (tmp_vpath); /* We took action only if the dialog was shown or the execution * was successful */ return confirm_execute || (ret == 0); @@ -3454,8 +3452,12 @@ update_one_panel_widget (WPanel * panel, panel_update_flags_t flags, const char if ((flags & UP_RELOAD) != 0) { + vfs_path_t *tmp_vpath; + + tmp_vpath = vfs_path_from_str (panel->cwd); panel->is_panelized = FALSE; - mc_setctl (panel->cwd, VFS_SETCTL_FLUSH, 0); + mc_setctl (tmp_vpath, VFS_SETCTL_FLUSH, 0); + vfs_path_free (tmp_vpath); memset (&(panel->dir_stat), 0, sizeof (panel->dir_stat)); }