From 12af8e5db060b2c0f47c5515b8134e05d009cf77 Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Wed, 29 Jun 2011 13:12:19 +0300 Subject: [PATCH] fixed relative symlink operations. Symlink now stay relative Signed-off-by: Slava Zanko --- lib/vfs/interface.c | 2 +- lib/vfs/path.c | 26 +++++++++++++++++++++++--- lib/vfs/path.h | 7 +++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/lib/vfs/interface.c b/lib/vfs/interface.c index 31b5702d7..76fb4f216 100644 --- a/lib/vfs/interface.c +++ b/lib/vfs/interface.c @@ -265,7 +265,7 @@ mc_symlink (const char *name1, const char *path) if (vpath1 == NULL) return -1; - vpath2 = vfs_path_from_str (name1); + vpath2 = vfs_path_from_str_flags (name1, VPF_NO_CANON); if (vpath2 != NULL) { diff --git a/lib/vfs/path.c b/lib/vfs/path.c index 9406ebf32..ea4e01c88 100644 --- a/lib/vfs/path.c +++ b/lib/vfs/path.c @@ -607,15 +607,16 @@ vfs_path_to_str (const vfs_path_t * vpath) /* --------------------------------------------------------------------------------------------- */ /** - * Split path string to path elements. + * Split path string to path elements with flags for change parce process. * * @param path_str VFS-path + * @param flags flags for parser * * @return pointer to newly created vfs_path_t object with filled path elements array. */ vfs_path_t * -vfs_path_from_str (const char *path_str) +vfs_path_from_str_flags (const char *path_str, vfs_path_flag_t flags) { vfs_path_t *vpath; char *path; @@ -623,7 +624,11 @@ vfs_path_from_str (const char *path_str) if (path_str == NULL) return NULL; - path = vfs_canon (path_str); + if ((flags & VPF_NO_CANON) == 0) + path = vfs_canon (path_str); + else + path = g_strdup (path_str); + if (path == NULL) return NULL; @@ -637,6 +642,21 @@ vfs_path_from_str (const char *path_str) return vpath; } +/* --------------------------------------------------------------------------------------------- */ +/** + * Split path string to path elements. + * + * @param path_str VFS-path + * + * @return pointer to newly created vfs_path_t object with filled path elements array. + */ + +vfs_path_t * +vfs_path_from_str (const char *path_str) +{ + return vfs_path_from_str_flags (path_str, VPF_NONE); +} + /* --------------------------------------------------------------------------------------------- */ /* * Create new vfs_path_t object. diff --git a/lib/vfs/path.h b/lib/vfs/path.h index 980ab9869..16420d9de 100644 --- a/lib/vfs/path.h +++ b/lib/vfs/path.h @@ -7,6 +7,12 @@ /*** enums ***************************************************************************************/ +typedef enum +{ + VPF_NONE = 0, + VPF_NO_CANON = 1 +} vfs_path_flag_t; + /*** structures declarations (and typedefs of structures)*****************************************/ struct vfs_class; @@ -48,6 +54,7 @@ int vfs_path_elements_count (const vfs_path_t * path); char *vfs_path_to_str (const vfs_path_t * path); char *vfs_path_to_str_elements_count (const vfs_path_t * path, int elements_count); vfs_path_t *vfs_path_from_str (const char *path_str); +vfs_path_t *vfs_path_from_str_flags (const char *path_str, vfs_path_flag_t flags); vfs_path_element_t *vfs_path_get_by_index (const vfs_path_t * path, int element_index); vfs_path_element_t *vfs_path_element_clone (const vfs_path_element_t * element);