From cac04476fbf56b8b99ea857ffde147e682f06ab8 Mon Sep 17 00:00:00 2001 From: Yohei Endo Date: Wed, 5 Oct 2016 12:33:42 +0900 Subject: [PATCH] Fix warning message on extracting symlink. When a symbolic link which is in the top directory in archive is extracted, warning message "LHa: invalid path name" is printed. Add symlink_with_make_path(), fix to call make_parent_path() only when the first symlink() is failed. --- src/lhext.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/lhext.c b/src/lhext.c index 5c2a53a..ad6ec1b 100644 --- a/src/lhext.c +++ b/src/lhext.c @@ -198,6 +198,23 @@ open_with_make_path(name) } /* ------------------------------------------------------------------------ */ +static int +symlink_with_make_path(realname, name) + const char *realname; + const char *name; +{ + int l_code; + + l_code = symlink(realname, name); + if (l_code < 0) { + make_parent_path(name); + l_code = symlink(realname, name); + } + + return l_code; +} + +/* ------------------------------------------------------------------------ */ static void adjust_info(name, hdr) char *name; @@ -509,8 +526,7 @@ extract_one(afp, hdr) } unlink(name); - make_parent_path(name); - l_code = symlink(hdr->realname, name); + l_code = symlink_with_make_path(hdr->realname, name); if (l_code < 0) { if (quiet != TRUE) warning("Can't make Symbolic Link \"%s\" -> \"%s\"", -- 2.11.0