Skip to content

Commit 98aac78

Browse files
committed
devkitPPC: remove can delete directories
1 parent 092f657 commit 98aac78

1 file changed

Lines changed: 53 additions & 8 deletions

File tree

dkppc/patches/newlib-4.1.0.patch

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6680,35 +6680,44 @@ index 000000000..1d7b7e8e7
66806680
+}
66816681
diff --git a/libgloss/libsysbase/rmdir.c b/libgloss/libsysbase/rmdir.c
66826682
new file mode 100644
6683-
index 000000000..2692a2997
6683+
index 000000000..b8640b87d
66846684
--- /dev/null
66856685
+++ b/libgloss/libsysbase/rmdir.c
6686-
@@ -0,0 +1,25 @@
6686+
@@ -0,0 +1,34 @@
66876687
+#include "config.h"
66886688
+#include <_ansi.h>
66896689
+#include <_syslist.h>
66906690
+#include <reent.h>
66916691
+#include <errno.h>
66926692
+#include <sys/iosupport.h>
66936693
+
6694-
+int rmdir (const char *name) {
6695-
+ struct _reent *r = _REENT;
6694+
+int _rmdir_r (struct _reent *ptr, const char *name) {
66966695
+ int dev,ret=-1;
66976696
+
66986697
+ dev = FindDevice(name);
66996698
+ if(dev!=-1) {
67006699
+ if(devoptab_list[dev]->rmdir_r) {
6701-
+ r->deviceData = devoptab_list[dev]->deviceData;
6702-
+ ret = devoptab_list[dev]->rmdir_r(r,name);
6700+
+ ptr->deviceData = devoptab_list[dev]->deviceData;
6701+
+ ret = devoptab_list[dev]->rmdir_r(ptr,name);
67036702
+ } else {
6704-
+ r->_errno = ENOSYS;
6703+
+ ptr->_errno = ENOSYS;
67056704
+ }
67066705
+ } else {
6707-
+ r->_errno = ENODEV;
6706+
+ ptr->_errno = ENODEV;
67086707
+ }
67096708
+
67106709
+ return ret;
67116710
+}
6711+
+
6712+
+#ifndef _REENT_ONLY
6713+
+
6714+
+int
6715+
+rmdir (const char *filename)
6716+
+{
6717+
+ return _rmdir_r (_REENT, filename);
6718+
+}
6719+
+
6720+
+#endif
67126721
diff --git a/libgloss/libsysbase/sbrk.c b/libgloss/libsysbase/sbrk.c
67136722
new file mode 100644
67146723
index 000000000..83d922d85
@@ -7416,6 +7425,18 @@ index 5c293c83d..75ccf89f5 100644
74167425
/* Under Cygwin, wchar_t (or its extension wint_t) is Unicode */
74177426
#define _jp2uc(c) (c)
74187427
#define _jp2uc_l(c, l) (c)
7428+
diff --git a/newlib/libc/include/reent.h b/newlib/libc/include/reent.h
7429+
index 2b01fbe8f..7af875b81 100644
7430+
--- a/newlib/libc/include/reent.h
7431+
+++ b/newlib/libc/include/reent.h
7432+
@@ -150,6 +150,7 @@ extern int _mkdir_r (struct _reent *, const char *, int);
7433+
extern int _open_r (struct _reent *, const char *, int, int);
7434+
extern _ssize_t _read_r (struct _reent *, int, void *, size_t);
7435+
extern int _rename_r (struct _reent *, const char *, const char *);
7436+
+extern int _rmdir_r (struct _reent *r, const char *name);
7437+
extern void *_sbrk_r (struct _reent *, ptrdiff_t);
7438+
extern int _stat_r (struct _reent *, const char *, struct stat *);
7439+
extern _CLOCK_T_ _times_r (struct _reent *, struct tms *);
74197440
diff --git a/newlib/libc/include/sys/dirent.h b/newlib/libc/include/sys/dirent.h
74207441
index a3fb5c02c..adb8e1083 100644
74217442
--- a/newlib/libc/include/sys/dirent.h
@@ -8174,6 +8195,30 @@ index df8321461..eee4181cd 100644
81748195
{
81758196
/* no more input: return partial result */
81768197
#ifdef __SCLE
8198+
diff --git a/newlib/libc/stdio/remove.c b/newlib/libc/stdio/remove.c
8199+
index d8dfdbd82..a85b5a99b 100644
8200+
--- a/newlib/libc/stdio/remove.c
8201+
+++ b/newlib/libc/stdio/remove.c
8202+
@@ -57,13 +57,17 @@ Supporting OS subroutine required: <<unlink>>.
8203+
#include <_ansi.h>
8204+
#include <reent.h>
8205+
#include <stdio.h>
8206+
+#include <errno.h>
8207+
8208+
int
8209+
_remove_r (struct _reent *ptr,
8210+
const char *filename)
8211+
{
8212+
- if (_unlink_r (ptr, filename) == -1)
8213+
- return -1;
8214+
+ if (_unlink_r (ptr, filename) == -1) {
8215+
+ errno = 0;
8216+
+ if (_rmdir_r(ptr, filename) == -1)
8217+
+ return -1;
8218+
+ }
8219+
8220+
return 0;
8221+
}
81778222
diff --git a/newlib/libc/stdlib/aligned_alloc.c b/newlib/libc/stdlib/aligned_alloc.c
81788223
index feb22c24b..3dae0c9a9 100644
81798224
--- a/newlib/libc/stdlib/aligned_alloc.c

0 commit comments

Comments
 (0)