Fdelete_directory. */
int delete_by_moving_to_trash;
+Lisp_Object Qdelete_by_moving_to_trash;
+
/* Lisp function for moving files to trash. */
Lisp_Object Qmove_file_to_trash;
file names in the file system.
An initial `~/' expands to your home directory.
An initial `~USER/' expands to USER's home directory.
-See also the function `substitute-in-file-name'. */)
+See also the function `substitute-in-file-name'.
+
+For technical reasons, this function can return correct but
+non-intuitive results for the root directory; for instance,
+\(expand-file-name ".." "/") returns "/..". For this reason, use
+(directory-file-name (file-name-directory dirname)) to traverse a
+filesystem tree, not (expand-file-name ".." dirname). */)
(name, default_directory)
Lisp_Object name, default_directory;
{
/* These point to SDATA and need to be careful with string-relocation
during GC (via DECODE_FILE). */
unsigned char *nm, *newdir;
- int nm_in_name;
/* This should only point to alloca'd data. */
unsigned char *target;
}
nm = SDATA (name);
- nm_in_name = 1;
-#ifdef DOS_NT
- /* We will force directory separators to be either all \ or /, so make
- a local copy to modify, even if there ends up being no change. */
+ /* Make a local copy of nm[] to protect it from GC in DECODE_FILE below. */
nm = strcpy (alloca (strlen (nm) + 1), nm);
- nm_in_name = 0;
+#ifdef DOS_NT
/* Note if special escape prefix is present, but remove for now. */
if (nm[0] == '/' && nm[1] == ':')
{
}
return name;
#else /* not DOS_NT */
- if (nm == SDATA (name))
+ if (strcmp (nm, SDATA (name)) == 0)
return name;
return make_specified_string (nm, -1, strlen (nm), multibyte);
#endif /* not DOS_NT */
tem = build_string (newdir);
if (!STRING_MULTIBYTE (tem))
{
- /* FIXME: DECODE_FILE may GC, which may move SDATA(name),
- after which `nm' won't point to the right place any more. */
- int offset = nm - SDATA (name);
hdir = DECODE_FILE (tem);
newdir = SDATA (hdir);
- if (nm_in_name)
- nm = SDATA (name) + offset;
}
#ifdef DOS_NT
collapse_newdir = 0;
{
if (errno == EXDEV)
{
+ int count;
#ifdef S_IFLNK
symlink_target = Ffile_symlink_p (file);
if (! NILP (symlink_target))
NILP (ok_if_already_exists) ? Qnil : Qt,
Qt, Qt);
+ count = SPECPDL_INDEX ();
+ specbind (Qdelete_by_moving_to_trash, Qnil);
Fdelete_file (file);
+ unbind_to (count, Qnil);
}
else
report_file_error ("Renaming", list2 (file, newname));
"(let ((file (read-file-name \"File: \"))) \
(list file (read-file-modes nil file)))",
doc: /* Set mode bits of file named FILENAME to MODE (an integer).
-Only the 12 low bits of MODE are used. */)
+Only the 12 low bits of MODE are used.
+
+Interactively, mode bits are read by `read-file-modes', which accepts
+symbolic notation, like the `chmod' command from GNU Coreutils. */)
(filename, mode)
Lisp_Object filename, mode;
{
if (bufpos == inserted)
{
- specpdl_ptr--;
/* Truncate the buffer to the size of the file. */
if (same_at_start == same_at_end)
nochange = 1;
When non-nil, the function `move-file-to-trash' will be used by
`delete-file' and `delete-directory'. */);
delete_by_moving_to_trash = 0;
+ Qdelete_by_moving_to_trash = intern ("delete-by-moving-to-trash");
Qmove_file_to_trash = intern ("move-file-to-trash");
staticpro (&Qmove_file_to_trash);