Intelligent VFS symlink

Michal Svec rebel at atrey.karlin.mff.cuni.cz
Wed Jul 25 17:13:18 UTC 2001


Hi!

This patch modifies VFS symlink behavior to be a little more intelligent
-- similar to the "ln -s /path/file /newpath/". There would be no need to
enter the file name twice by hand if it is the same.

If I want to symlink /path/file (it is a current file) and /newpath/ is
the other panel, it would be enough to just press Ctrl+X and S and Enter.
Now, the user has to switch to the target field and append the source
filename.

Any comments?

Regards
Michal

--- mc-4.5.54/vfs/vfs.c.orig	Thu May  3 14:28:22 2001
+++ mc-4.5.54/vfs/vfs.c	Thu May  3 15:17:57 2001
@@ -4,6 +4,7 @@
    Written by: 1995 Miguel de Icaza
                1995 Jakub Jelinek
 	       1998 Pavel Machek
+	       2001 Michal Svec
    
    $Id: vfs.c,v 1.68 2001/03/05 06:00:27 andrew Exp $
 
@@ -424,6 +425,27 @@
     return handle;
 }
 
+int
+mc_symlink (char *oldpath, char *newpath)
+{
+    int result;
+    struct stat buf;
+
+    char *path = vfs_canon (newpath);
+    vfs *vfs = vfs_type (path);
+
+    if(vfs->stat && !(*vfs->stat)(vfs, newpath, &buf) && S_ISDIR(buf.st_mode))
+        path = g_strconcat(path, "/", g_basename(oldpath), NULL);
+
+    result = vfs->symlink ? (*vfs->symlink)(vfs, oldpath, path) : -1;
+
+    if (result == -1)
+      (*__errno_location ())  = vfs->symlink ? ferrno (vfs) : 38;
+
+    g_free (path);
+    return result;
+}  
+
 #define vfs_op(handle) vfs_file_table [handle].operations 
 #define vfs_info(handle) vfs_file_table [handle].fs_info
 #define vfs_free_bucket(handle) vfs_info(handle) = 0;
@@ -626,7 +648,6 @@
 MC_NAMEOP (utime, (char *path, struct utimbuf *times), (vfs, vfs_name (path), times))
 MC_NAMEOP (readlink, (char *path, char *buf, int bufsiz), (vfs, vfs_name (path), buf, bufsiz))
 MC_NAMEOP (unlink, (char *path), (vfs, vfs_name (path)))
-MC_NAMEOP (symlink, (char *name1, char *path), (vfs, vfs_name (name1), vfs_name (path)))
 
 #define MC_RENAMEOP(name) \
 int mc_##name (char *name1, char *name2) \





More information about the mc-devel mailing list