Browse Source

changed interface of function mc_setctl() for handle vfs_path_t object as parameter

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
Slava Zanko 13 years ago
parent
commit
031e994cba
5 changed files with 42 additions and 23 deletions
  1. 1 4
      lib/vfs/interface.c
  2. 1 1
      lib/vfs/vfs.h
  3. 7 2
      src/args.c
  4. 24 9
      src/filemanager/file.c
  5. 9 7
      src/filemanager/panel.c

+ 1 - 4
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;
 }
 

+ 1 - 1
lib/vfs/vfs.h

@@ -296,7 +296,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);

+ 7 - 2
src/args.c

@@ -429,11 +429,16 @@ mc_setup_by_args (int argc, char *argv[])
 
     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 */
     }
 

+ 24 - 9
src/filemanager/file.c

@@ -2576,6 +2576,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;
@@ -2584,6 +2585,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? */
 
@@ -2691,6 +2693,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)
     {
@@ -2760,8 +2763,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;
         }
@@ -2772,11 +2780,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 */
 
@@ -2832,7 +2842,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)
                     {
@@ -2878,10 +2890,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;
@@ -3000,13 +3010,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);
     }
 
@@ -3016,6 +3030,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;
 

+ 9 - 7
src/filemanager/panel.c

@@ -2432,14 +2432,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);
@@ -3576,8 +3574,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));
     }