devkitPPC: remove can delete directories

This commit is contained in:
Dave Murphy 2022-01-01 20:00:51 +00:00
parent 092f657e81
commit 98aac78959

View File

@ -6680,10 +6680,10 @@ index 000000000..1d7b7e8e7
+}
diff --git a/libgloss/libsysbase/rmdir.c b/libgloss/libsysbase/rmdir.c
new file mode 100644
index 000000000..2692a2997
index 000000000..b8640b87d
--- /dev/null
+++ b/libgloss/libsysbase/rmdir.c
@@ -0,0 +1,25 @@
@@ -0,0 +1,34 @@
+#include "config.h"
+#include <_ansi.h>
+#include <_syslist.h>
@ -6691,24 +6691,33 @@ index 000000000..2692a2997
+#include <errno.h>
+#include <sys/iosupport.h>
+
+int rmdir (const char *name) {
+ struct _reent *r = _REENT;
+int _rmdir_r (struct _reent *ptr, const char *name) {
+ int dev,ret=-1;
+
+ dev = FindDevice(name);
+ if(dev!=-1) {
+ if(devoptab_list[dev]->rmdir_r) {
+ r->deviceData = devoptab_list[dev]->deviceData;
+ ret = devoptab_list[dev]->rmdir_r(r,name);
+ ptr->deviceData = devoptab_list[dev]->deviceData;
+ ret = devoptab_list[dev]->rmdir_r(ptr,name);
+ } else {
+ r->_errno = ENOSYS;
+ ptr->_errno = ENOSYS;
+ }
+ } else {
+ r->_errno = ENODEV;
+ ptr->_errno = ENODEV;
+ }
+
+ return ret;
+}
+
+#ifndef _REENT_ONLY
+
+int
+rmdir (const char *filename)
+{
+ return _rmdir_r (_REENT, filename);
+}
+
+#endif
diff --git a/libgloss/libsysbase/sbrk.c b/libgloss/libsysbase/sbrk.c
new file mode 100644
index 000000000..83d922d85
@ -7416,6 +7425,18 @@ index 5c293c83d..75ccf89f5 100644
/* Under Cygwin, wchar_t (or its extension wint_t) is Unicode */
#define _jp2uc(c) (c)
#define _jp2uc_l(c, l) (c)
diff --git a/newlib/libc/include/reent.h b/newlib/libc/include/reent.h
index 2b01fbe8f..7af875b81 100644
--- a/newlib/libc/include/reent.h
+++ b/newlib/libc/include/reent.h
@@ -150,6 +150,7 @@ extern int _mkdir_r (struct _reent *, const char *, int);
extern int _open_r (struct _reent *, const char *, int, int);
extern _ssize_t _read_r (struct _reent *, int, void *, size_t);
extern int _rename_r (struct _reent *, const char *, const char *);
+extern int _rmdir_r (struct _reent *r, const char *name);
extern void *_sbrk_r (struct _reent *, ptrdiff_t);
extern int _stat_r (struct _reent *, const char *, struct stat *);
extern _CLOCK_T_ _times_r (struct _reent *, struct tms *);
diff --git a/newlib/libc/include/sys/dirent.h b/newlib/libc/include/sys/dirent.h
index a3fb5c02c..adb8e1083 100644
--- a/newlib/libc/include/sys/dirent.h
@ -8174,6 +8195,30 @@ index df8321461..eee4181cd 100644
{
/* no more input: return partial result */
#ifdef __SCLE
diff --git a/newlib/libc/stdio/remove.c b/newlib/libc/stdio/remove.c
index d8dfdbd82..a85b5a99b 100644
--- a/newlib/libc/stdio/remove.c
+++ b/newlib/libc/stdio/remove.c
@@ -57,13 +57,17 @@ Supporting OS subroutine required: <<unlink>>.
#include <_ansi.h>
#include <reent.h>
#include <stdio.h>
+#include <errno.h>
int
_remove_r (struct _reent *ptr,
const char *filename)
{
- if (_unlink_r (ptr, filename) == -1)
- return -1;
+ if (_unlink_r (ptr, filename) == -1) {
+ errno = 0;
+ if (_rmdir_r(ptr, filename) == -1)
+ return -1;
+ }
return 0;
}
diff --git a/newlib/libc/stdlib/aligned_alloc.c b/newlib/libc/stdlib/aligned_alloc.c
index feb22c24b..3dae0c9a9 100644
--- a/newlib/libc/stdlib/aligned_alloc.c