mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-04 18:28:30 +00:00
Add assimilate.com command for APE binaries
This commit is contained in:
parent
0cea6c560f
commit
60164a7266
23 changed files with 652 additions and 50 deletions
|
@ -20,6 +20,7 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/dirent.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
@ -59,8 +60,20 @@ static int rmrfdir(const char *dirpath) {
|
|||
* Recursively removes file or directory.
|
||||
*/
|
||||
int rmrf(const char *path) {
|
||||
int e;
|
||||
struct stat st;
|
||||
if (stat(path, &st) == -1) return -1;
|
||||
if (!S_ISDIR(st.st_mode)) return unlink(path);
|
||||
return rmrfdir(path);
|
||||
e = errno;
|
||||
if (stat(path, &st) == -1) {
|
||||
if (errno == ENOENT) {
|
||||
errno = e;
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (!S_ISDIR(st.st_mode)) {
|
||||
return unlink(path);
|
||||
} else {
|
||||
return rmrfdir(path);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue