mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-03-09 06:30:32 -07:00
DELETE-FILE works on empty directories.
This commit is contained in:
parent
7beedc12c8
commit
8f9aeb2815
2 changed files with 23 additions and 14 deletions
|
|
@ -133,6 +133,8 @@ ECL 11.7.1:
|
|||
sequentially over it. Thus, if you use encodings such as UCS2 and UCS4, make
|
||||
sure that you choose the right endianness to match the shape of the array.
|
||||
|
||||
- DELETE-FILE works on empty directories.
|
||||
|
||||
;;; Local Variables: ***
|
||||
;;; mode:text ***
|
||||
;;; fill-column:79 ***
|
||||
|
|
|
|||
|
|
@ -536,18 +536,32 @@ SUCCESS:
|
|||
@(return newn old_truename new_truename)
|
||||
@)
|
||||
|
||||
static int
|
||||
directory_pathname_p(cl_object path)
|
||||
{
|
||||
return (path->pathname.name == Cnil) &&
|
||||
(path->pathname.type == Cnil);
|
||||
}
|
||||
|
||||
cl_object
|
||||
cl_delete_file(cl_object file)
|
||||
{
|
||||
cl_object filename = si_coerce_to_filename(file);
|
||||
cl_object path = cl_pathname(file);
|
||||
int isdir = directory_pathname_p(path);
|
||||
cl_object filename = si_coerce_to_filename(path);
|
||||
int ok;
|
||||
|
||||
ecl_disable_interrupts();
|
||||
ok = unlink((char*)filename->base_string.self);
|
||||
ok = (isdir? rmdir : unlink)((char*)filename->base_string.self);
|
||||
ecl_enable_interrupts();
|
||||
|
||||
if (ok < 0)
|
||||
FElibc_error("Cannot delete the file ~S.", 1, file);
|
||||
if (ok < 0) {
|
||||
const char *msg =
|
||||
isdir?
|
||||
"Cannot delete the file ~S." :
|
||||
"Cannot delete the directory ~S.";
|
||||
FElibc_error(msg, 1, file);
|
||||
}
|
||||
@(return Ct)
|
||||
}
|
||||
|
||||
|
|
@ -1068,16 +1082,9 @@ si_mkstemp(cl_object template)
|
|||
cl_object
|
||||
si_rmdir(cl_object directory)
|
||||
{
|
||||
int code;
|
||||
directory = si_coerce_to_filename(directory);
|
||||
|
||||
ecl_disable_interrupts();
|
||||
code = rmdir((char*)directory->base_string.self);
|
||||
ecl_enable_interrupts();
|
||||
|
||||
if (code != 0)
|
||||
FElibc_error("Can't remove directory ~A.", 1, directory);
|
||||
@(return Cnil)
|
||||
return cl_delete_file(cl_make_pathname(6, @':name', Cnil,
|
||||
@':type', Cnil,
|
||||
@':defaults', directory));
|
||||
}
|
||||
|
||||
cl_object
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue