Skip to content

Commit

Permalink
fix: remove recursively for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
matteo-cristino committed Oct 7, 2024
1 parent 90e713f commit ee6e214
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,27 @@ bool write_to_file(char *path, char *filename, char *buf, unsigned int len) {
static int rm_ftw(const char *pathname,
const struct stat *sbuf,
int type, struct FTW *ftwb) {
#ifndef LIBC_MINGW32
if(remove(pathname) < 0) {
_err("Error: remove path %s",pathname);
_err("%s",strerror(errno));
return -1;
_err("Error: remove path %s",pathname);
_err("%s",strerror(errno));
return -1;
}
#else
if (type == FTW_F) {
if(DeleteFile(pathname) == 0) {
_err("Error: DeleteFile path %s",pathname);
_err("%s",strerror(errno));
return -1;
}
} else if (type == FTW_D) {
if(RemoveDirectory(pathname) == 0) {
_err("Error: RemoveDirectory path %s",pathname);
_err("%s",strerror(errno));
return -1;
}
}
#endif
return 0;
}
bool rm_recursive(char *path) {
Expand Down

0 comments on commit ee6e214

Please sign in to comment.