diff options
author | Ryo Nakamura <upa@haeena.net> | 2024-01-11 12:53:34 +0900 |
---|---|---|
committer | Ryo Nakamura <upa@haeena.net> | 2024-01-18 12:59:49 +0900 |
commit | 5cbf3ad6480adb6615a9a80b59d4a9d1ade62431 (patch) | |
tree | 7df444fe7e96dbe11041fe4adf40a615fac6bbed /src/path.c | |
parent | 4b34118a88be403e8028806ba09be41212d289b1 (diff) |
fix wrong dst path for source path under '/'
When a source file path is /FILE, its dest path would be dst/ILE.
This commit fixes this issue (#8).
Diffstat (limited to 'src/path.c')
-rw-r--r-- | src/path.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -106,10 +106,18 @@ static int resolve_dst_path(const char *src_file_path, char *dst_file_path, mscp_set_error("dirname: %s", strerrno()); return -1; } - if (strlen(prefix) == 1 && prefix[0] == '.') - offset = 0; - else - offset = strlen(prefix) + 1; + + offset = strlen(prefix) + 1; + if (strlen(prefix) == 1) { /* corner cases */ + switch (prefix[0]) { + case '.': + offset = 0; + break; + case '/': + offset = 1; + break; + } + } if (!a->src_path_is_dir && !a->dst_path_is_dir) { /* src path is file. dst path is (1) file, or (2) does not exist. |