]>
git.proxmox.com Git - wasi-libc.git/blob - libc-bottom-half/cloudlibc/src/libc/unistd/unlinkat.c
1 // Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/
3 // SPDX-License-Identifier: BSD-2-Clause
5 #include <common/errno.h>
8 #ifdef __wasilibc_unmodified_upstream // unlink
10 #include <wasi/libc.h>
17 int unlinkat(int fd
, const char *path
, int flag
) {
18 #ifdef __wasilibc_unmodified_upstream // unlink
19 __wasi_ulflags_t ulflags
= 0;
20 if ((flag
& AT_REMOVEDIR
) != 0)
21 ulflags
|= __WASI_UNLINK_REMOVEDIR
;
22 __wasi_errno_t error
=
23 __wasi_file_unlink(fd
, path
, strlen(path
), ulflags
);
25 errno
= errno_fixup_directory(fd
, error
);
30 if ((flag
& AT_REMOVEDIR
) != 0) {
31 return __wasilibc_rmdirat(fd
, path
);
33 return __wasilibc_rmfileat(fd
, path
);