Delete folder and contents?
Posted: Wed Feb 13, 2019 7:20 pm
Hi,
I wish to remove directory and and its contents like rm -rf <target> from SD card
I found this example:
But I get "fatal error: ftw.h: No such file or directory" even though I'm defining _XOPEN_SOURCE 500.
I tried to define XOPEN_SOURCE as
in the project Makefile, but that caused a lot of other idf components compilation errors.
I wish to remove directory and and its contents like rm -rf <target> from SD card
I found this example:
- #define _XOPEN_SOURCE 500
- #include <stdio.h>
- #include <ftw.h>
- #include <unistd.h>
- int unlink_cb(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf)
- {
- int rv = remove(fpath);
- if (rv)
- perror(fpath);
- return rv;
- }
- int rmrf(char *path)
- {
- return nftw(path, unlink_cb, 64, FTW_DEPTH | FTW_PHYS);
- }
I tried to define XOPEN_SOURCE as
Code: Select all
CFLAGS := -D_OXPEN_SOURCE=500