comparison src/fileio.c @ 60572:d19eab3028e2

(Frename_file, Fadd_name_to_file) (Fmake_symbolic_link): If NEWNAME or LINKNAME is a directory, expand the basename of FILE relative to it.
author Richard M. Stallman <rms@gnu.org>
date Fri, 11 Mar 2005 23:49:25 +0000
parents ca116ec246d7
children f5607c3ce8fd
comparison
equal deleted inserted replaced
60571:999e917606e9 60572:d19eab3028e2
2689 symlink_target = encoded_file = encoded_newname = Qnil; 2689 symlink_target = encoded_file = encoded_newname = Qnil;
2690 GCPRO5 (file, newname, encoded_file, encoded_newname, symlink_target); 2690 GCPRO5 (file, newname, encoded_file, encoded_newname, symlink_target);
2691 CHECK_STRING (file); 2691 CHECK_STRING (file);
2692 CHECK_STRING (newname); 2692 CHECK_STRING (newname);
2693 file = Fexpand_file_name (file, Qnil); 2693 file = Fexpand_file_name (file, Qnil);
2694 newname = Fexpand_file_name (newname, Qnil); 2694
2695 if (!NILP (Ffile_directory_p (newname)))
2696 newname = Fexpand_file_name (Ffile_name_nondirectory (file), newname);
2697 else
2698 newname = Fexpand_file_name (newname, Qnil);
2695 2699
2696 /* If the file name has special constructs in it, 2700 /* If the file name has special constructs in it,
2697 call the corresponding file handler. */ 2701 call the corresponding file handler. */
2698 handler = Ffind_file_name_handler (file, Qrename_file); 2702 handler = Ffind_file_name_handler (file, Qrename_file);
2699 if (NILP (handler)) 2703 if (NILP (handler))
2772 GCPRO4 (file, newname, encoded_file, encoded_newname); 2776 GCPRO4 (file, newname, encoded_file, encoded_newname);
2773 encoded_file = encoded_newname = Qnil; 2777 encoded_file = encoded_newname = Qnil;
2774 CHECK_STRING (file); 2778 CHECK_STRING (file);
2775 CHECK_STRING (newname); 2779 CHECK_STRING (newname);
2776 file = Fexpand_file_name (file, Qnil); 2780 file = Fexpand_file_name (file, Qnil);
2777 newname = Fexpand_file_name (newname, Qnil); 2781
2782 if (!NILP (Ffile_directory_p (newname)))
2783 newname = Fexpand_file_name (Ffile_name_nondirectory (file), newname);
2784 else
2785 newname = Fexpand_file_name (newname, Qnil);
2778 2786
2779 /* If the file name has special constructs in it, 2787 /* If the file name has special constructs in it,
2780 call the corresponding file handler. */ 2788 call the corresponding file handler. */
2781 handler = Ffind_file_name_handler (file, Qadd_name_to_file); 2789 handler = Ffind_file_name_handler (file, Qadd_name_to_file);
2782 if (!NILP (handler)) 2790 if (!NILP (handler))
2839 /* If the link target has a ~, we must expand it to get 2847 /* If the link target has a ~, we must expand it to get
2840 a truly valid file name. Otherwise, do not expand; 2848 a truly valid file name. Otherwise, do not expand;
2841 we want to permit links to relative file names. */ 2849 we want to permit links to relative file names. */
2842 if (SREF (filename, 0) == '~') 2850 if (SREF (filename, 0) == '~')
2843 filename = Fexpand_file_name (filename, Qnil); 2851 filename = Fexpand_file_name (filename, Qnil);
2844 linkname = Fexpand_file_name (linkname, Qnil); 2852
2853 if (!NILP (Ffile_directory_p (linkname)))
2854 linkname = Fexpand_file_name (Ffile_name_nondirectory (file), linkname);
2855 else
2856 linkname = Fexpand_file_name (linkname, Qnil);
2845 2857
2846 /* If the file name has special constructs in it, 2858 /* If the file name has special constructs in it,
2847 call the corresponding file handler. */ 2859 call the corresponding file handler. */
2848 handler = Ffind_file_name_handler (filename, Qmake_symbolic_link); 2860 handler = Ffind_file_name_handler (filename, Qmake_symbolic_link);
2849 if (!NILP (handler)) 2861 if (!NILP (handler))