- /* Get rid of trailing "/" and "/.". */
- while (len) {
- if (fn[len - 1] == '/') {
- is_dot_dir = 1;
- if (!--len && !dir) {
- len++;
- break;
- }
- }
- else if (len >= 2 && fn[len - 1] == '.'
- && fn[len - 2] == '/') {
- is_dot_dir = 1;
- if (!(len -= 2) && !dir) {
- len++;
- break;
- }
- } else
- break;
+ /* A leading ./ can be used in relative mode to affect
+ * the dest dir without its name being in the path. */
+ if (*fn == '.' && fn[1] == '/' && !implied_dot_dir) {
+ send_file_name(f, flist, ".", NULL,
+ (flags | FLAG_IMPLIED_DIR) & ~FLAG_CONTENT_DIR,
+ ALL_FILTERS);
+ implied_dot_dir = 1;
+ }
+ len = clean_fname(fn, CFN_KEEP_TRAILING_SLASH
+ | CFN_DROP_TRAILING_DOT_DIR);
+ if (len == 1) {
+ if (fn[0] == '/') {
+ fn = "/.";
+ len = 2;
+ name_type = DOT_NAME;
+ } else if (fn[0] == '.')
+ name_type = DOT_NAME;
+ } else if (fn[len-1] == '/') {
+ fn[--len] = '\0';
+ if (len == 1 && *fn == '.')
+ name_type = DOT_NAME;
+ else
+ name_type = SLASH_ENDING_NAME;