CHECK_STRING (file);
CHECK_STRING (newname);
file = Fexpand_file_name (file, Qnil);
- newname = Fexpand_file_name (newname, Qnil);
+
+ if (!NILP (Ffile_directory_p (newname)))
+ newname = Fexpand_file_name (Ffile_name_nondirectory (file), newname);
+ else
+ newname = Fexpand_file_name (newname, Qnil);
/* If the file name has special constructs in it,
call the corresponding file handler. */
CHECK_STRING (file);
CHECK_STRING (newname);
file = Fexpand_file_name (file, Qnil);
- newname = Fexpand_file_name (newname, Qnil);
+
+ if (!NILP (Ffile_directory_p (newname)))
+ newname = Fexpand_file_name (Ffile_name_nondirectory (file), newname);
+ else
+ newname = Fexpand_file_name (newname, Qnil);
/* If the file name has special constructs in it,
call the corresponding file handler. */
we want to permit links to relative file names. */
if (SREF (filename, 0) == '~')
filename = Fexpand_file_name (filename, Qnil);
- linkname = Fexpand_file_name (linkname, Qnil);
+
+ if (!NILP (Ffile_directory_p (linkname)))
+ linkname = Fexpand_file_name (Ffile_name_nondirectory (file), linkname);
+ else
+ linkname = Fexpand_file_name (linkname, Qnil);
/* If the file name has special constructs in it,
call the corresponding file handler. */